dsh-remote-plugin 0.7.6 → 0.8.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +729 -18
- package/index.mjs +20 -5
- package/package.json +1 -1
- package/plugin-center.mjs +9 -2
- package/public/activity.js +126 -0
- package/public/admin.html +4 -0
- package/public/admin.js +4 -0
- package/public/announcements.json +8 -0
- package/public/app.js +330 -137
- package/public/chat-files.js +3 -1
- package/public/desktop/desktop.css +10 -10
- package/public/desktop/desktop.html +31 -9
- package/public/desktop/desktop.js +214 -68
- package/public/extensions.js +3 -2
- package/public/history.js +32 -11
- package/public/image-preview.js +132 -0
- package/public/index.html +39 -11
- package/public/md.js +41 -1
- package/public/motion.js +3 -3
- package/public/network.js +35 -5
- package/public/operations.js +109 -0
- package/public/relay-settings.css +2 -0
- package/public/relay-settings.js +128 -0
- package/public/styles.css +15 -15
- package/public/subagents.css +61 -0
- package/public/subagents.js +275 -0
- package/public/update.json +4 -4
- package/public/version.json +1 -1
- package/public/workflow.css +327 -0
- package/public/workflow.js +366 -0
package/public/extensions.js
CHANGED
|
@@ -84,7 +84,8 @@ window.DshExtensions = (() => {
|
|
|
84
84
|
if(!available[route]){navigate('manage');return}
|
|
85
85
|
if(s.route==='manage'){s.scroller=scrollParent(root);s.scroll=s.scroller?.scrollTop||0;window.DshPluginCenter?.pause()}
|
|
86
86
|
}
|
|
87
|
-
stopViews();s.route=route;view.replaceChildren();header.hidden=route==='manage';manager.hidden=route!=='manage';view.hidden=route==='manage';root.className='ext-page'+(route==='manage'?' is-manage':'')
|
|
87
|
+
stopViews();s.route=route;view.replaceChildren();header.hidden=route==='manage'&&!config.back;manager.hidden=route!=='manage';view.hidden=route==='manage';root.className='ext-page'+(route==='manage'?' is-manage':'')
|
|
88
|
+
back.textContent=route==='manage'?(window.I18N?.lang==='en'?'← Back to More':'← 返回更多'):(window.I18N?.lang==='en'?'← Back to plugins':'← 返回插件列表')
|
|
88
89
|
if(route==='manage'){
|
|
89
90
|
if(!s.mounted){s.mounted=true;await window.DshPluginCenter.mount({...config,onFeature:navigate},manager)}
|
|
90
91
|
else {if(s.scroller)s.scroller.scrollTop=s.scroll;void window.DshPluginCenter.resume()}
|
|
@@ -92,7 +93,7 @@ window.DshExtensions = (() => {
|
|
|
92
93
|
else window.DshInsights.mount({tab:'cost',hostOverview:true,allowedTabs:['cost'],connection:config.connection,url:config.url},view)
|
|
93
94
|
if(valid()&&route!=='manage')config.scrollTop?.()
|
|
94
95
|
}
|
|
95
|
-
back.addEventListener('click',()=>{if(valid())void navigate('manage')})
|
|
96
|
+
back.addEventListener('click',()=>{if(valid()){if(s.route==='manage')config.back?.();else void navigate('manage')}})
|
|
96
97
|
void navigate('manage').then(()=>{if(initial!=='manage'&&initial!=='home'&&valid())void navigate(initial)})
|
|
97
98
|
}
|
|
98
99
|
function scrollParent(el) {
|
package/public/history.js
CHANGED
|
@@ -24,17 +24,20 @@
|
|
|
24
24
|
}
|
|
25
25
|
class HistoryView {
|
|
26
26
|
constructor(box, options) {
|
|
27
|
-
this.box=box; this.options=options; this.entries=[]; this.start=0; this.end=0; this.nodes=new Map(); this.reading=false; this.suppress=false; this.frame=0; this.pendingOlder=false
|
|
27
|
+
this.box=box; this.options=options; this.entries=[]; this.start=0; this.end=0; this.nodes=new Map(); this.disclosures=new Map(); this.reading=false; this.suppress=false; this.frame=0; this.pendingOlder=false
|
|
28
28
|
this.more=document.createElement('button'); this.more.type='button'; this.more.className='history-page-control'; this.more.textContent=options.olderLabel()
|
|
29
29
|
this.more.addEventListener('click',()=>this.older())
|
|
30
30
|
this.empty=document.createElement('div'); this.empty.className='history-empty'
|
|
31
31
|
this.live=document.createElement('div'); this.live.className='history-live'
|
|
32
|
+
box.addEventListener('toggle',event=>{const detail=event.target;if(detail?.dataset?.activityKey)this.rememberDisclosure(detail)},true)
|
|
32
33
|
const intent=()=>{this.intentUntil=Date.now()+1200}
|
|
33
34
|
const hold=()=>{intent();this.reading=true;this.options.changed?.(this)}
|
|
34
35
|
box.addEventListener('wheel',event=>{intent();if(event.deltaY<0)hold()},{passive:true})
|
|
35
36
|
box.addEventListener('touchstart',event=>{this.touchY=event.touches?.[0]?.clientY;this.lastScrollTop=box.scrollTop},{passive:true})
|
|
36
37
|
box.addEventListener('touchmove',event=>{const y=event.touches?.[0]?.clientY;intent();if(y>this.touchY)hold();this.touchY=y},{passive:true})
|
|
37
|
-
|
|
38
|
+
// Pressing a card or selecting text pauses following, but only when actually
|
|
39
|
+
// scrolled away from the tail: tapping at the bottom must not fake "new content".
|
|
40
|
+
box.addEventListener('pointerdown',()=>{this.lastScrollTop=box.scrollTop;this.intentUntil=0;if(!this.atBottom)this.reading=true;this.options.changed?.(this)},{passive:true})
|
|
38
41
|
box.addEventListener('keydown',event=>{if(['ArrowUp','PageUp','Home'].includes(event.key))hold();else if(['ArrowDown','PageDown','End'].includes(event.key))intent()})
|
|
39
42
|
box.addEventListener('scroll',()=>{
|
|
40
43
|
if(this.suppress || this.frame)return
|
|
@@ -48,8 +51,14 @@
|
|
|
48
51
|
}
|
|
49
52
|
get unread() {return Math.max(0,this.entries.length-this.end)}
|
|
50
53
|
get hasPending() {return this.unread>0||(this.pendingLive||'')!==(this.liveHtml||'')}
|
|
54
|
+
/** Real viewport position, not an intent flag: a stale `reading` must never keep the jump button up at the bottom. */
|
|
55
|
+
get atBottom() {const box=this.box;return box.scrollHeight-box.scrollTop-box.clientHeight<=24}
|
|
51
56
|
set(entries, {reset=false, follow=false, live='', hasMore=false, loading=false, emptyLabel=''}={}) {
|
|
52
57
|
if(this.paused){this.pending={entries:entries.slice(),options:{reset,follow,live,hasMore,loading,emptyLabel}};return}
|
|
58
|
+
// A stale flag is cleaned up only when no gesture is in progress: while the user is
|
|
59
|
+
// actively scrolling up from the bottom a stream update must not clear `reading`,
|
|
60
|
+
// otherwise every chunk snaps the view back to the tail.
|
|
61
|
+
if(this.reading&&Date.now()>(this.intentUntil||0)&&this.atBottom&&this.end>=this.entries.length)this.reading=false
|
|
53
62
|
this.pendingLive=live
|
|
54
63
|
// Reading is explicit user intent. A stream update never changes it by proximity.
|
|
55
64
|
if(this.reading&&!reset)live=this.liveHtml||''
|
|
@@ -70,15 +79,26 @@
|
|
|
70
79
|
this.liveHtml=this.reading&&!reset ? this.liveHtml||'' : this.end===entries.length?live:''
|
|
71
80
|
this.render(anchor,reset || (!this.reading && this.end===entries.length))
|
|
72
81
|
}
|
|
82
|
+
rememberDisclosure(detail) {
|
|
83
|
+
const key=detail.dataset.activityKey;if(!key)return
|
|
84
|
+
this.disclosures.delete(key);this.disclosures.set(key,!!detail.open)
|
|
85
|
+
if(this.disclosures.size>512)this.disclosures.delete(this.disclosures.keys().next().value)
|
|
86
|
+
}
|
|
87
|
+
captureDisclosures(node) {for(const detail of node.querySelectorAll('details[data-activity-key]'))this.rememberDisclosure(detail)}
|
|
88
|
+
restoreDisclosures(node) {for(const detail of node.querySelectorAll('details[data-activity-key]'))if(this.disclosures.has(detail.dataset.activityKey))detail.open=this.disclosures.get(detail.dataset.activityKey)}
|
|
73
89
|
render(anchor, bottom=false) {
|
|
74
90
|
const box=this.box, slice=this.entries.slice(this.start,Math.min(this.end,this.start+WINDOW_SIZE)), desired=[]
|
|
91
|
+
this.captureDisclosures(box)
|
|
75
92
|
this.end=this.start+slice.length
|
|
76
93
|
const rangeKey=this.start+':'+this.end
|
|
77
94
|
let changed=rangeKey!==this.lastRange || this.live.innerHTML!==this.liveHtml
|
|
78
95
|
this.lastRange=rangeKey
|
|
79
96
|
for(const entry of slice) {
|
|
97
|
+
// Hidden events render an empty string; keeping their node would leave dead gaps.
|
|
98
|
+
const html=this.options.html(entry)
|
|
99
|
+
if(!html){if(this.nodes.delete(entry.seq))changed=true;continue}
|
|
80
100
|
const key=signature(entry);let cached=this.nodes.get(entry.seq)
|
|
81
|
-
if(!cached || cached.key!==key){changed=true;const node=document.createElement('div');node.className='history-entry';node.dataset.historySeq=String(entry.seq);node.innerHTML=this.
|
|
101
|
+
if(!cached || cached.key!==key){changed=true;const node=document.createElement('div');node.className='history-entry';node.dataset.historySeq=String(entry.seq);node.innerHTML=html;this.restoreDisclosures(node);cached={key,node};this.nodes.set(entry.seq,cached)}
|
|
82
102
|
desired.push(cached.node)
|
|
83
103
|
}
|
|
84
104
|
this.more.hidden=this.start===0&&!this.hasMore
|
|
@@ -89,7 +109,7 @@
|
|
|
89
109
|
let cursor=this.more.nextSibling
|
|
90
110
|
for(const node of desired){if(node===cursor)cursor=cursor.nextSibling;else box.insertBefore(node,cursor)}
|
|
91
111
|
if(!slice.length && !this.liveHtml){if(this.empty.parentNode!==box)box.append(this.empty)}else this.empty.remove()
|
|
92
|
-
if(this.live.innerHTML!==this.liveHtml)this.live.innerHTML=this.liveHtml
|
|
112
|
+
if(this.live.innerHTML!==this.liveHtml){this.live.innerHTML=this.liveHtml;this.restoreDisclosures(this.live)}
|
|
93
113
|
if(this.live.parentNode!==box)box.append(this.live)
|
|
94
114
|
if(bottom)box.scrollTop=box.scrollHeight
|
|
95
115
|
else if(anchor){const current=this.nodes.get(anchor.seq)?.node;if(current?.parentNode===box)box.scrollTop+=current.getBoundingClientRect().top-anchor.top}
|
|
@@ -100,14 +120,15 @@
|
|
|
100
120
|
this.options.changed?.(this)
|
|
101
121
|
}
|
|
102
122
|
onScroll() {
|
|
103
|
-
const box=this.box
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
123
|
+
const box=this.box, atBottom=this.atBottom
|
|
124
|
+
// Position wins over the intent flag: reaching the bottom always resumes following,
|
|
125
|
+
// no matter whether the scroll came from a wheel, a drag, a rail jump or momentum.
|
|
126
|
+
if(atBottom)this.reading=false
|
|
127
|
+
else if(Date.now()<this.intentUntil&&box.scrollTop<(this.lastScrollTop??box.scrollTop))this.reading=true
|
|
108
128
|
this.lastScrollTop=box.scrollTop
|
|
109
129
|
if(box.scrollTop<80 && Date.now()<this.intentUntil)this.older()
|
|
110
|
-
else if(box.scrollHeight-box.scrollTop-box.clientHeight<120 && this.end<this.entries.length && Date.now()<this.intentUntil){const anchor=this.anchor();this.end=Math.min(this.entries.length,this.end+WINDOW_STEP);this.start=Math.max(0,this.end-WINDOW_SIZE);this.liveHtml=this.end===this.entries.length?this.pendingLive||'':'';this.render(anchor)}
|
|
130
|
+
else if(box.scrollHeight-box.scrollTop-box.clientHeight<120 && this.end<this.entries.length && Date.now()<this.intentUntil){const anchor=this.anchor();this.end=Math.min(this.entries.length,this.end+WINDOW_STEP);this.start=Math.max(0,this.end-WINDOW_SIZE);this.liveHtml=this.end===this.entries.length?this.pendingLive||'':'';this.render(anchor,atBottom)}
|
|
131
|
+
else if(atBottom&&this.end>=this.entries.length&&this.liveHtml!==(this.pendingLive||'')){this.liveHtml=this.pendingLive||'';this.render(null,true)}
|
|
111
132
|
this.options.scrolled?.(this)
|
|
112
133
|
this.domChanged=false
|
|
113
134
|
this.options.changed?.(this)
|
|
@@ -127,7 +148,7 @@
|
|
|
127
148
|
this.paused=false;this.box.scrollTop=this.savedScroll||0
|
|
128
149
|
const pending=this.pending;this.pending=null;if(pending)this.set(pending.entries,pending.options)
|
|
129
150
|
}
|
|
130
|
-
reset() {cancelAnimationFrame(this.frame);cancelAnimationFrame(this.releaseFrame);this.frame=0;this.entries=[];this.start=this.end=this.previousLength=0;this.lastRange='';this.nodes.clear();this.reading=false;this.pendingOlder=false;this.suppress=false;this.intentUntil=0;this.pendingLive='';this.pending=null;this.paused=false;this.lastScrollTop=0;this.box.replaceChildren()}
|
|
151
|
+
reset() {cancelAnimationFrame(this.frame);cancelAnimationFrame(this.releaseFrame);this.frame=0;this.entries=[];this.start=this.end=this.previousLength=0;this.lastRange='';this.nodes.clear();this.disclosures.clear();this.reading=false;this.pendingOlder=false;this.suppress=false;this.intentUntil=0;this.pendingLive='';this.pending=null;this.paused=false;this.lastScrollTop=0;this.box.replaceChildren()}
|
|
131
152
|
}
|
|
132
153
|
let cacheEpoch=0
|
|
133
154
|
let database
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* Shared chat image lightbox. No dependencies, mobile and desktop. */
|
|
2
|
+
'use strict';
|
|
3
|
+
;(function(root){
|
|
4
|
+
const english=()=>root.I18N?.lang==='en'
|
|
5
|
+
let lightbox=null,stage=null,image=null,closeButton=null,hint=null,opener=null
|
|
6
|
+
let resolver=null,observer=null,mutation=null
|
|
7
|
+
function labels(){
|
|
8
|
+
if(!lightbox)return
|
|
9
|
+
lightbox.setAttribute('aria-label',english()?'Image preview':'图片预览')
|
|
10
|
+
if(closeButton)closeButton.setAttribute('aria-label',english()?'Close':'关闭')
|
|
11
|
+
if(hint)hint.textContent=isZoomed()?(english()?'Double-tap to fit · tap outside to close':'双击还原 · 点空白处关闭'):(english()?'Double-tap to zoom · tap outside to close':'双击放大 · 点空白处关闭')
|
|
12
|
+
}
|
|
13
|
+
function isZoomed(){return !!lightbox?.classList.contains('is-zoomed')}
|
|
14
|
+
function setZoom(on){
|
|
15
|
+
if(!lightbox)return
|
|
16
|
+
lightbox.classList.toggle('is-zoomed',!!on)
|
|
17
|
+
if(image){
|
|
18
|
+
if(on&&image.naturalWidth){image.style.width=image.naturalWidth*2+'px';image.style.height=image.naturalHeight*2+'px'}
|
|
19
|
+
else{image.style.width='';image.style.height=''}
|
|
20
|
+
}
|
|
21
|
+
if(on&&stage)root.requestAnimationFrame?.(()=>{stage.scrollLeft=(stage.scrollWidth-stage.clientWidth)/2;stage.scrollTop=(stage.scrollHeight-stage.clientHeight)/2})
|
|
22
|
+
labels()
|
|
23
|
+
}
|
|
24
|
+
function toggleZoom(){setZoom(!isZoomed())}
|
|
25
|
+
function isOpen(){return !!lightbox&&!lightbox.classList.contains('hidden')}
|
|
26
|
+
function open(src,alt=''){
|
|
27
|
+
if(!src||!elements())return
|
|
28
|
+
opener=root.document.activeElement||null
|
|
29
|
+
image.src=src
|
|
30
|
+
image.alt=alt||(english()?'Image':'图片')
|
|
31
|
+
lightbox.classList.remove('hidden')
|
|
32
|
+
root.document.body?.classList.add('image-preview-open')
|
|
33
|
+
setZoom(false)
|
|
34
|
+
root.requestAnimationFrame?.(()=>lightbox.focus?.({preventScroll:true}))
|
|
35
|
+
}
|
|
36
|
+
function close(){
|
|
37
|
+
if(!lightbox||lightbox.classList.contains('hidden'))return
|
|
38
|
+
setZoom(false)
|
|
39
|
+
lightbox.classList.add('hidden')
|
|
40
|
+
root.document.body?.classList.remove('image-preview-open')
|
|
41
|
+
image.removeAttribute?.('src')
|
|
42
|
+
const target=opener;opener=null
|
|
43
|
+
target?.focus?.({preventScroll:true})
|
|
44
|
+
}
|
|
45
|
+
// Markdown images may point at a local file. The host shell supplies an authenticated
|
|
46
|
+
// request for that path; load lazily and swap the placeholder for a real previewable image.
|
|
47
|
+
function configure(options={}){
|
|
48
|
+
if(typeof options.resolvePath==='function')resolver=options.resolvePath
|
|
49
|
+
if(!mutation&&typeof root.MutationObserver==='function'&&root.document?.body){
|
|
50
|
+
// History renders (paging, streaming, cache restore) replace nodes without a full render call.
|
|
51
|
+
mutation=new root.MutationObserver(records=>{
|
|
52
|
+
for(const record of records)for(const node of record.addedNodes)if(node?.nodeType===1)hydrate(node)
|
|
53
|
+
})
|
|
54
|
+
mutation.observe(root.document.body,{childList:true,subtree:true})
|
|
55
|
+
}
|
|
56
|
+
hydrate(root.document)
|
|
57
|
+
}
|
|
58
|
+
function watcher(){
|
|
59
|
+
if(observer)return observer
|
|
60
|
+
if(typeof root.IntersectionObserver!=='function')return null
|
|
61
|
+
observer=new root.IntersectionObserver(entries=>{
|
|
62
|
+
for(const entry of entries){
|
|
63
|
+
if(!entry.isIntersecting)continue
|
|
64
|
+
observer.unobserve(entry.target)
|
|
65
|
+
void loadPathImage(entry.target)
|
|
66
|
+
}
|
|
67
|
+
},{rootMargin:'320px'})
|
|
68
|
+
return observer
|
|
69
|
+
}
|
|
70
|
+
function hydrate(scope){
|
|
71
|
+
if(!resolver||!scope?.querySelectorAll)return
|
|
72
|
+
const candidates=[...(scope.matches?.('[data-chat-image][data-chat-image-path]')?[scope]:[]),...scope.querySelectorAll('[data-chat-image][data-chat-image-path]')]
|
|
73
|
+
for(const button of candidates){
|
|
74
|
+
if(button.dataset.chatImageLoading||button.dataset.chatImageLoaded)continue
|
|
75
|
+
button.dataset.chatImageLoading='1'
|
|
76
|
+
const watch=watcher()
|
|
77
|
+
if(watch)watch.observe(button)
|
|
78
|
+
else void loadPathImage(button)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function loadPathImage(button){
|
|
82
|
+
const path=button.dataset.chatImagePath
|
|
83
|
+
if(!path||!resolver)return
|
|
84
|
+
try{
|
|
85
|
+
const source=await resolver(path)
|
|
86
|
+
const request=typeof source==='string'?{url:source}:source||{}
|
|
87
|
+
const response=await (root.fetch||fetch)(request.url,{headers:request.headers||{}})
|
|
88
|
+
if(!response.ok)throw new Error('HTTP '+response.status)
|
|
89
|
+
const blob=await response.blob()
|
|
90
|
+
if(!blob||!blob.size)throw new Error('empty image')
|
|
91
|
+
const url=root.URL?.createObjectURL?root.URL.createObjectURL(blob):''
|
|
92
|
+
if(!url)throw new Error('no blob url')
|
|
93
|
+
const node=root.document.createElement('img')
|
|
94
|
+
node.src=url;node.alt=button.dataset.chatImageAlt||'';node.draggable=false;node.loading='lazy'
|
|
95
|
+
node.addEventListener('error',()=>pathImageFailed(button))
|
|
96
|
+
node.addEventListener('load',()=>{button.classList.remove('is-loading');button.classList.add('is-loaded')})
|
|
97
|
+
button.replaceChildren(node)
|
|
98
|
+
button.dataset.chatImageLoaded='1'
|
|
99
|
+
delete button.dataset.chatImagePath
|
|
100
|
+
}catch(error){pathImageFailed(button)}
|
|
101
|
+
}
|
|
102
|
+
function pathImageFailed(button){
|
|
103
|
+
button.classList.remove('is-loading')
|
|
104
|
+
button.classList.add('is-error')
|
|
105
|
+
const status=button.querySelector?.('.chat-image-status')
|
|
106
|
+
if(status)status.textContent=english()?'Image unavailable':'图片无法加载'
|
|
107
|
+
}
|
|
108
|
+
function elements(){
|
|
109
|
+
if(lightbox)return lightbox
|
|
110
|
+
lightbox=root.document?.getElementById('image-lightbox')
|
|
111
|
+
if(!lightbox)return null
|
|
112
|
+
stage=lightbox.querySelector('[data-image-lightbox-stage]')
|
|
113
|
+
image=lightbox.querySelector('[data-image-lightbox-img]')
|
|
114
|
+
closeButton=lightbox.querySelector('[data-image-lightbox-close]')
|
|
115
|
+
hint=lightbox.querySelector('[data-image-lightbox-hint]')
|
|
116
|
+
closeButton?.addEventListener('click',close)
|
|
117
|
+
lightbox.addEventListener('click',event=>{const target=event.target;if(target===lightbox||target===stage)close()})
|
|
118
|
+
stage?.addEventListener('click',event=>{if(event.target===stage)close()})
|
|
119
|
+
image?.addEventListener('dblclick',event=>{event.preventDefault?.();toggleZoom()})
|
|
120
|
+
root.document.addEventListener('keydown',event=>{if(event.key==='Escape'&&isOpen()){event.preventDefault?.();close()}})
|
|
121
|
+
// Chat images live inside rendered history: delegate instead of rebinding per message.
|
|
122
|
+
root.document.addEventListener('click',event=>{
|
|
123
|
+
const trigger=event.target?.closest?.('[data-chat-image]')
|
|
124
|
+
if(!trigger)return
|
|
125
|
+
const img=trigger.querySelector?.('img')
|
|
126
|
+
if(img?.src)open(img.src,img.alt||'')
|
|
127
|
+
})
|
|
128
|
+
return lightbox
|
|
129
|
+
}
|
|
130
|
+
root.DshImagePreview={open,close,isOpen,zoom:toggleZoom,mount:elements,configure,hydrate}
|
|
131
|
+
root.document?.addEventListener('DOMContentLoaded',()=>{elements();hydrate(root.document)})
|
|
132
|
+
})(typeof window==='undefined'?globalThis:window)
|
package/public/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="mobile-web-app-capable" content="yes">
|
|
8
8
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
9
9
|
<title>DSH Remote</title>
|
|
10
|
-
<script>/* 统一入口: 桌面浏览器(宽屏且 UA 非移动)访问根地址自动切换到桌面端, 手机/窄窗口继续 App 界面 */ (function(){try{var proto=location.protocol;var ua=navigator.userAgent||'';var mobile=/Android|iPhone|iPad|iPod|Mobile|Windows Phone/i.test(ua);if((proto==='http:'||proto==='https:')&&!mobile&&window.innerWidth>=1024){var p=location.pathname;if(p==='/'||/\/index\.html$/.test(p)){location.replace('desktop/desktop.html'+location.search)}}}catch(e){}})()</script>
|
|
10
|
+
<script>/* 统一入口: 桌面浏览器(宽屏且 UA 非移动)访问根地址自动切换到桌面端, 手机/窄窗口继续 App 界面 */ (function(){try{if(new URLSearchParams(location.search).get('layout')==='mobile'){sessionStorage.setItem('dshRemoteLayout','mobile');return}if(sessionStorage.getItem('dshRemoteLayout')==='mobile')return;var proto=location.protocol;var ua=navigator.userAgent||'';var mobile=/Android|iPhone|iPad|iPod|Mobile|Windows Phone/i.test(ua);if((proto==='http:'||proto==='https:')&&!mobile&&window.innerWidth>=1024){var p=location.pathname;if(p==='/'||/\/index\.html$/.test(p)){location.replace('desktop/desktop.html'+location.search)}}}catch(e){}})()</script>
|
|
11
11
|
<script>/* 首帧前应用皮肤, 避免闪白/闪黑 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'){t=window.matchMedia('(prefers-color-scheme: light)').matches?'light':'default'}document.documentElement.setAttribute('data-theme',t)}catch(e){}})()</script>
|
|
12
12
|
<link rel="manifest" href="manifest.webmanifest">
|
|
13
13
|
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<link rel="stylesheet" href="skills.css">
|
|
18
18
|
<link rel="stylesheet" href="extensions.css">
|
|
19
19
|
<link rel="stylesheet" href="insights.css">
|
|
20
|
+
<link rel="stylesheet" href="workflow.css">
|
|
21
|
+
<link rel="stylesheet" href="relay-settings.css">
|
|
22
|
+
<link rel="stylesheet" href="subagents.css">
|
|
20
23
|
</head>
|
|
21
24
|
<body>
|
|
22
25
|
<header class="topbar">
|
|
@@ -113,6 +116,7 @@
|
|
|
113
116
|
<button id="session-title" class="session-title" type="button" aria-haspopup="dialog" aria-controls="session-info" data-i18n="session.loading">加载中…</button>
|
|
114
117
|
|
|
115
118
|
</div>
|
|
119
|
+
<button id="btn-subagents" class="subagents-entry" type="button" aria-haspopup="dialog" aria-controls="subagent-page" data-i18n="subagent.title">子代理</button>
|
|
116
120
|
<button id="btn-session-more" class="icon-btn" type="button" aria-haspopup="dialog" aria-controls="session-actions" data-i18n-aria="session.more">⋯</button>
|
|
117
121
|
<button id="btn-fs-send" class="session-send-btn hidden" type="button">发送</button>
|
|
118
122
|
|
|
@@ -391,6 +395,7 @@
|
|
|
391
395
|
</div>
|
|
392
396
|
|
|
393
397
|
<div id="settings-page-servers" class="settings-subpage hidden" data-motion-panel>
|
|
398
|
+
<div id="relay-settings"></div>
|
|
394
399
|
<div class="settings-group">
|
|
395
400
|
<div class="setting-row" data-settings-back style="cursor:pointer">
|
|
396
401
|
<button class="mini-btn" data-i18n="settings.back">‹ 返回</button>
|
|
@@ -440,8 +445,7 @@
|
|
|
440
445
|
<label class="switch"><input type="checkbox" id="opt-notify"><span class="slider"></span></label>
|
|
441
446
|
</div>
|
|
442
447
|
<div class="setting-row">
|
|
443
|
-
<div><div class="setting-name" data-i18n="settings.peakRemindTitle"
|
|
444
|
-
<label class="switch"><input type="checkbox" id="opt-peak-remind"><span class="slider"></span></label>
|
|
448
|
+
<div><div class="setting-name" data-i18n="settings.peakRemindTitle">峰谷计费提醒 · dsh-cost-meter</div><div class="setting-desc" data-i18n="settings.peakRemindDesc">由 dsh-cost-meter 统一管理,请在 DSH「设置 → 费用 → 峰谷计价」配置。提醒由 DSH 页面触发,Remote 不再独立后台计时。</div></div>
|
|
445
449
|
</div>
|
|
446
450
|
<div class="setting-row">
|
|
447
451
|
<div><div class="setting-name" data-i18n="settings.testNotifyTitle">测试通知</div><div class="setting-desc" data-i18n="settings.testNotifyDesc">立即排一条 3 秒后的本地通知,用于排查系统通知限制</div></div>
|
|
@@ -511,6 +515,8 @@
|
|
|
511
515
|
<div class="setting-row">
|
|
512
516
|
<div><div class="setting-name" data-i18n="settings.updateTitle">检查更新</div><div class="setting-desc" id="update-desc" data-i18n="settings.updateLoading">加载中…</div>
|
|
513
517
|
<button id="btn-download-update" class="mini-btn hidden" style="margin-top:6px" data-i18n="settings.downloadUpdate">下载并安装更新</button>
|
|
518
|
+
<button id="btn-force-download-update" class="mini-btn" style="margin-top:6px" data-i18n="settings.redownloadApk">重新下载安装包</button>
|
|
519
|
+
<div class="setting-desc expanded" data-i18n="settings.redownloadApkDesc">同版本补丁也可重新下载,以当前主机提供的安装包为准。</div>
|
|
514
520
|
<div id="update-download-progress" class="update-download-progress hidden">
|
|
515
521
|
<div id="update-download-status" role="status" aria-live="polite"></div>
|
|
516
522
|
<progress id="update-download-bar" max="100" aria-label="APK download progress"></progress>
|
|
@@ -731,6 +737,14 @@
|
|
|
731
737
|
</div>
|
|
732
738
|
</div>
|
|
733
739
|
|
|
740
|
+
<div id="image-lightbox" class="image-lightbox hidden" role="dialog" aria-modal="true" aria-label="图片预览" tabindex="-1">
|
|
741
|
+
<button id="image-lightbox-close" class="image-lightbox-close" type="button" data-image-lightbox-close aria-label="关闭">×</button>
|
|
742
|
+
<div class="image-lightbox-stage" data-image-lightbox-stage>
|
|
743
|
+
<img data-image-lightbox-img alt="" draggable="false">
|
|
744
|
+
</div>
|
|
745
|
+
<div class="image-lightbox-hint" data-image-lightbox-hint>双击放大 · 点空白处关闭</div>
|
|
746
|
+
</div>
|
|
747
|
+
|
|
734
748
|
<div id="modal-archive" class="modal hidden" role="dialog" aria-modal="true">
|
|
735
749
|
<div class="modal-card archive-modal-card">
|
|
736
750
|
<div class="modal-title" data-i18n="session.archiveTitle">确认归档会话</div>
|
|
@@ -962,16 +976,16 @@
|
|
|
962
976
|
'speed.switched': '已切换到最快服务器:{url}({ms}ms)', 'speed.alreadyBest': '当前已是最快:{url}({ms}ms)',
|
|
963
977
|
'speed.allDown': '全部服务器不可达',
|
|
964
978
|
'servers.empty': '未添加备用服务器 · 默认使用当前页面地址', 'servers.untested': '未测速',
|
|
965
|
-
'servers.current': ' · 当前', 'servers.unreachable': '不可达', 'servers.delete': '删除服务器', 'servers.tokenSet': '令牌已配置', 'servers.tokenMissing': '未配置令牌',
|
|
979
|
+
'servers.current': ' · 当前', 'servers.currentOnly': '当前', 'servers.unreachable': '不可达', 'servers.delete': '删除服务器', 'servers.tokenSet': '令牌已配置', 'servers.tokenMissing': '未配置令牌',
|
|
966
980
|
'servers.currentDesc': '当前: {url}', 'servers.notSet': '未设置服务器', 'servers.defaultDesc': '默认 = 当前页面地址',
|
|
967
981
|
'servers.needAddress': '请输入服务器地址', 'servers.badProtocol': '地址需以 http:// 或 https:// 开头',
|
|
968
982
|
'servers.duplicate': '相同地址和令牌已在列表中', 'servers.added': '已添加服务器', 'servers.removedActive': '已删除当前服务器,重新测速…',
|
|
969
|
-
'servers.currentDescGroup': '当前:{group} · {url}
|
|
983
|
+
'servers.currentDescGroup': '当前:{group} · {url}',
|
|
970
984
|
'servers.edit': '编辑', 'servers.manualSelected': '已切换至:{url}',
|
|
971
985
|
'servers.promptNote': '服务器备注(可留空):', 'servers.promptEditNote': '编辑备注({url}):', 'servers.promptEditToken': '编辑服务器令牌(留空保持不变):',
|
|
972
986
|
'servers.promptEditUrl': '编辑服务器地址:', 'servers.promptEditGroup': '所属组:', 'servers.edited': '服务器已更新',
|
|
973
987
|
'speed.switchedOrigin': '已切换到当前页面(同源)', 'speed.manualUsing': '手动模式:{url}({ms})',
|
|
974
|
-
'groups.current': '当前组', 'groups.add': '+ 组', 'groups.noServer': '组内暂无服务器',
|
|
988
|
+
'groups.current': '当前组', 'groups.currentLabel': '当前组:{group}', 'groups.add': '+ 组', 'groups.noServer': '组内暂无服务器',
|
|
975
989
|
'groups.speedTest': '测速', 'groups.autoSelect': '自动选择最快', 'groups.delete': '删除组',
|
|
976
990
|
'groups.autoOn': '{group} 已切换为自动选择', 'groups.autoOff': '{group} 已切换为手动选择',
|
|
977
991
|
'groups.switched': '已切换到组:{group}', 'groups.switchHint': '点击切换当前组,双击重命名', 'groups.promptAdd': '新组名:', 'groups.duplicate': '组名已存在',
|
|
@@ -994,6 +1008,7 @@
|
|
|
994
1008
|
'event.taskStart': '▶ 任务开始', 'event.taskEnd': '■ 任务结束',
|
|
995
1009
|
'event.systemReminder': '系统提示',
|
|
996
1010
|
'block.image': '图片', 'block.thinking': '🧠 思考过程', 'block.thinkingLive': '🧠 思考中…', 'block.toolCall': '工具调用', 'block.toolResult': '工具结果', 'block.unknown': '块 · {type}',
|
|
1011
|
+
'activity.group': '工具与思考 · {n} 项', 'activity.groupRunning': '运行中',
|
|
997
1012
|
'truncated': '…(截断)',
|
|
998
1013
|
'insights.title': '上下文与费用',
|
|
999
1014
|
'insights.contextTitle': '上下文分析',
|
|
@@ -1007,6 +1022,7 @@
|
|
|
1007
1022
|
'goal.actionFailed': '目标操作失败', 'goal.actionSubmitted': '目标操作已提交',
|
|
1008
1023
|
'goal.cannotEmpty': '目标不能为空', 'goal.updateFailed': '更新失败', 'goal.updated': '目标已更新',
|
|
1009
1024
|
'todos.title': '任务清单',
|
|
1025
|
+
'session.migrationRequired': '请先在 DSH 中打开原会话完成迁移,然后刷新。',
|
|
1010
1026
|
'subagent.title': '子代理', 'subagent.count': '子代理 · {n} 个', 'subagent.expand': '展开子代理', 'subagent.collapse': '收起子代理', 'subagent.diagnostic': '诊断项', 'subagent.running': '· 运行中', 'subagent.interrupt': '中断',
|
|
1011
1027
|
'subagent.confirmInterrupt': '中断这个子代理当前回合?', 'subagent.interruptFailed': '中断失败', 'subagent.interruptSubmitted': '中断请求已提交',
|
|
1012
1028
|
'queue.title': '排队消息', 'queue.steer': '插话', 'queue.steerUnavailable': '仅运行中可插话', 'queue.steerSubmitted': '插话请求已提交', 'queue.steerFailed': '插话失败:{msg}', 'queue.image': '图片消息',
|
|
@@ -1054,6 +1070,8 @@
|
|
|
1054
1070
|
'update.checkFailedDesc': '检查失败:{msg}', 'update.checkFailed': '检查更新失败:{msg}',
|
|
1055
1071
|
'update.phase.downloading': '正在下载…', 'update.phase.verifying': '正在校验安装包…', 'update.phase.complete': '下载完成', 'update.phase.legacy': '系统正在下载安装包;安装新版后可显示完整进度', 'update.busy': '已有更新下载正在进行',
|
|
1056
1072
|
'update.downloadStarted': '开始下载,完成后会弹出安装页', 'update.downloadFailed': '无法启动下载:{msg}',
|
|
1073
|
+
'update.phase.checking': '正在获取主机安装包信息…', 'settings.redownloadApk': '重新下载安装包', 'settings.redownloadApkDesc': '同版本补丁也可重新下载,以当前主机提供的安装包为准。',
|
|
1074
|
+
'update.patchMismatch': '安装包与校验信息不一致,请同步主机安装包后重试。',
|
|
1057
1075
|
'update.corrupted': '下载文件损坏,请重试', 'update.serverFileMissing': '服务器上还没有对应版本的文件,请稍后再试',
|
|
1058
1076
|
'update.hashMissing': '更新包缺少 SHA-256 校验值,已取消下载',
|
|
1059
1077
|
'update.installUnsupported': '当前版本不支持 App 内安装,已转浏览器下载',
|
|
@@ -1095,7 +1113,7 @@
|
|
|
1095
1113
|
'settings.notifyTitle': '通知', 'settings.notifyDesc': '收到审批/提问时推送', 'settings.announcementHistoryTitle': '历史公告', 'settings.announcementHistoryDesc': '查看以前收到的公告', 'settings.announcementHistory': '查看记录',
|
|
1096
1114
|
'settings.testNotifyTitle': '测试通知', 'settings.testNotifyDesc': '立即排一条 3 秒后的本地通知,用于排查系统通知限制', 'settings.testNotify': '发送测试通知',
|
|
1097
1115
|
'settings.testNotifySent': '测试通知已排定,3 秒后到达', 'settings.testNotifyFailed': '发送测试通知失败:{msg}', 'settings.testNotifyUnavailable': '测试通知仅在 App 内可用',
|
|
1098
|
-
'settings.peakRemindTitle': '峰谷计费提醒', 'settings.peakRemindDesc': '
|
|
1116
|
+
'settings.peakRemindTitle': '峰谷计费提醒 · dsh-cost-meter', 'settings.peakRemindDesc': '由 dsh-cost-meter 统一管理,请在 DSH「设置 → 费用 → 峰谷计价」配置。提醒由 DSH 页面触发,Remote 不再独立后台计时。',
|
|
1099
1117
|
'peakRemind.enterPeak': '已进入高峰计费时段', 'peakRemind.enterOff': '已进入空闲计费时段',
|
|
1100
1118
|
'peakRemind.peak0912': '高峰 9:00-12:00', 'peakRemind.off1214': '空闲 12:00-14:00',
|
|
1101
1119
|
'peakRemind.peak1418': '高峰 14:00-18:00', 'peakRemind.off1809': '空闲 18:00-次日 9:00',
|
|
@@ -1203,16 +1221,16 @@
|
|
|
1203
1221
|
'speed.switched': 'Switched to fastest server: {url} ({ms}ms)', 'speed.alreadyBest': 'Already on fastest: {url} ({ms}ms)',
|
|
1204
1222
|
'speed.allDown': 'All servers unreachable',
|
|
1205
1223
|
'servers.empty': 'No backup servers · using the current page URL', 'servers.untested': 'Untested',
|
|
1206
|
-
'servers.current': ' · current', 'servers.unreachable': 'Unreachable', 'servers.delete': 'Remove server', 'servers.tokenSet': 'Token set', 'servers.tokenMissing': 'No token',
|
|
1224
|
+
'servers.current': ' · current', 'servers.currentOnly': 'Current', 'servers.unreachable': 'Unreachable', 'servers.delete': 'Remove server', 'servers.tokenSet': 'Token set', 'servers.tokenMissing': 'No token',
|
|
1207
1225
|
'servers.currentDesc': 'Current: {url}', 'servers.notSet': 'No server set', 'servers.defaultDesc': 'Default = current page URL',
|
|
1208
1226
|
'servers.needAddress': 'Enter a server address', 'servers.badProtocol': 'Address must start with http:// or https://',
|
|
1209
1227
|
'servers.duplicate': 'The same address and token is already in the list', 'servers.added': 'Server added', 'servers.removedActive': 'Removed active server, re-testing…',
|
|
1210
|
-
'servers.currentDescGroup': 'Current: {group} · {url}
|
|
1228
|
+
'servers.currentDescGroup': 'Current: {group} · {url}',
|
|
1211
1229
|
'servers.edit': 'Edit', 'servers.manualSelected': 'Switched to: {url}',
|
|
1212
1230
|
'servers.promptNote': 'Server note (optional):', 'servers.promptEditNote': 'Edit note ({url}):', 'servers.promptEditToken': 'Edit server token (blank keeps the current token):',
|
|
1213
1231
|
'servers.promptEditUrl': 'Edit server URL:', 'servers.promptEditGroup': 'Group:', 'servers.edited': 'Server updated',
|
|
1214
1232
|
'speed.switchedOrigin': 'Switched to current page (same origin)', 'speed.manualUsing': 'Manual mode: {url} ({ms})',
|
|
1215
|
-
'groups.current': 'Current group', 'groups.add': '+ Group', 'groups.noServer': 'No servers in this group',
|
|
1233
|
+
'groups.current': 'Current group', 'groups.currentLabel': 'Current group: {group}', 'groups.add': '+ Group', 'groups.noServer': 'No servers in this group',
|
|
1216
1234
|
'groups.speedTest': 'Speed test', 'groups.autoSelect': 'Auto-select fastest', 'groups.delete': 'Delete group',
|
|
1217
1235
|
'groups.autoOn': '{group} is now auto-select', 'groups.autoOff': '{group} is now manual',
|
|
1218
1236
|
'groups.switched': 'Switched to group: {group}', 'groups.switchHint': 'Click to switch group, double-click to rename', 'groups.promptAdd': 'New group name:', 'groups.duplicate': 'Group already exists',
|
|
@@ -1235,6 +1253,7 @@
|
|
|
1235
1253
|
'event.taskStart': '▶ Task started', 'event.taskEnd': '■ Task finished',
|
|
1236
1254
|
'event.systemReminder': 'System reminder',
|
|
1237
1255
|
'block.image': 'Image', 'block.thinking': '🧠 Thinking', 'block.thinkingLive': '🧠 Thinking…', 'block.toolCall': 'Tool call', 'block.toolResult': 'Tool result', 'block.unknown': 'Block · {type}',
|
|
1256
|
+
'activity.group': 'Tools and thinking · {n}', 'activity.groupRunning': 'Running',
|
|
1238
1257
|
'truncated': '…(truncated)',
|
|
1239
1258
|
'insights.title': 'Context & costs',
|
|
1240
1259
|
'insights.contextTitle': 'Context analysis',
|
|
@@ -1248,6 +1267,7 @@
|
|
|
1248
1267
|
'goal.actionFailed': 'Goal action failed', 'goal.actionSubmitted': 'Goal action submitted',
|
|
1249
1268
|
'goal.cannotEmpty': 'Goal cannot be empty', 'goal.updateFailed': 'Update failed', 'goal.updated': 'Goal updated',
|
|
1250
1269
|
'todos.title': 'Todos',
|
|
1270
|
+
'session.migrationRequired': 'Open the source session in DSH to complete migration, then refresh.',
|
|
1251
1271
|
'subagent.title': 'Subagents', 'subagent.count': 'Subagents · {n}', 'subagent.expand': 'Expand subagents', 'subagent.collapse': 'Collapse subagents', 'subagent.diagnostic': 'Diagnostic', 'subagent.running': '· running', 'subagent.interrupt': 'Interrupt',
|
|
1252
1272
|
'subagent.confirmInterrupt': 'Interrupt this subagent\'s current turn?', 'subagent.interruptFailed': 'Interrupt failed', 'subagent.interruptSubmitted': 'Interrupt requested',
|
|
1253
1273
|
'queue.title': 'Queued messages', 'queue.steer': 'Interject', 'queue.steerUnavailable': 'Only available while running', 'queue.steerSubmitted': 'Interjection requested', 'queue.steerFailed': 'Interjection failed: {msg}', 'queue.image': 'Image message',
|
|
@@ -1295,6 +1315,8 @@
|
|
|
1295
1315
|
'update.checkFailedDesc': 'Check failed: {msg}', 'update.checkFailed': 'Update check failed: {msg}',
|
|
1296
1316
|
'update.phase.downloading': 'Downloading…', 'update.phase.verifying': 'Verifying APK…', 'update.phase.complete': 'Download complete', 'update.phase.legacy': 'System download started; install this update for full progress', 'update.busy': 'An update is already downloading',
|
|
1297
1317
|
'update.downloadStarted': 'Downloading, the install page will open when ready', 'update.downloadFailed': 'Could not start download: {msg}',
|
|
1318
|
+
'update.phase.checking': 'Fetching the host package information…', 'settings.redownloadApk': 'Download package again', 'settings.redownloadApkDesc': 'Download same-version patches too. The package comes from the current host.',
|
|
1319
|
+
'update.patchMismatch': 'Package checksum mismatch. Refresh the package on the host, then try again.',
|
|
1298
1320
|
'update.corrupted': 'Downloaded file is corrupted, please retry', 'update.serverFileMissing': 'The file for this version is not on the server yet, please try again later',
|
|
1299
1321
|
'update.hashMissing': 'The update package has no SHA-256 checksum; download cancelled',
|
|
1300
1322
|
'update.installUnsupported': 'This version cannot install in-app, opening browser download',
|
|
@@ -1336,7 +1358,7 @@
|
|
|
1336
1358
|
'settings.notifyTitle': 'Notifications', 'settings.notifyDesc': 'Push on approvals / questions', 'settings.announcementHistoryTitle': 'Announcement history', 'settings.announcementHistoryDesc': 'Review announcements you received before', 'settings.announcementHistory': 'View history',
|
|
1337
1359
|
'settings.testNotifyTitle': 'Test notification', 'settings.testNotifyDesc': 'Schedule a local notification in 3 seconds to verify the notification pipeline', 'settings.testNotify': 'Send test notification',
|
|
1338
1360
|
'settings.testNotifySent': 'Test notification scheduled, arriving in 3s', 'settings.testNotifyFailed': 'Failed to send test notification: {msg}', 'settings.testNotifyUnavailable': 'Test notification is only available in the app',
|
|
1339
|
-
'settings.peakRemindTitle': 'Peak/off-peak reminders', 'settings.peakRemindDesc': '
|
|
1361
|
+
'settings.peakRemindTitle': 'Peak/off-peak reminders · dsh-cost-meter', 'settings.peakRemindDesc': 'Managed by dsh-cost-meter. Configure in DSH Settings → Cost → Peak pricing. Alerts require the DSH page; Remote no longer runs a separate background timer.',
|
|
1340
1362
|
'peakRemind.enterPeak': 'Peak pricing period started', 'peakRemind.enterOff': 'Off-peak pricing period started',
|
|
1341
1363
|
'peakRemind.peak0912': 'Peak 9:00-12:00', 'peakRemind.off1214': 'Off-peak 12:00-14:00',
|
|
1342
1364
|
'peakRemind.peak1418': 'Peak 14:00-18:00', 'peakRemind.off1809': 'Off-peak 18:00-9:00 next day',
|
|
@@ -1413,8 +1435,14 @@
|
|
|
1413
1435
|
<script src="insights.js"></script>
|
|
1414
1436
|
<script src="extensions.js"></script>
|
|
1415
1437
|
<script src="history.js"></script>
|
|
1438
|
+
<script src="activity.js"></script>
|
|
1439
|
+
<script src="image-preview.js"></script>
|
|
1416
1440
|
<script src="link-check.js"></script>
|
|
1417
1441
|
<script src="network.js"></script>
|
|
1442
|
+
<script src="operations.js"></script>
|
|
1443
|
+
<script src="workflow.js"></script>
|
|
1444
|
+
<script src="relay-settings.js"></script>
|
|
1445
|
+
<script src="subagents.js"></script>
|
|
1418
1446
|
<script src="app.js"></script>
|
|
1419
1447
|
</body>
|
|
1420
1448
|
</html>
|
package/public/md.js
CHANGED
|
@@ -23,7 +23,46 @@
|
|
|
23
23
|
})
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function decodeEntities(s) {
|
|
27
|
+
const entities = { '&': '&', '"': '"', ''': "'", '<': '<', '>': '>' }
|
|
28
|
+
return String(s).replace(/&(?:amp|quot|lt|gt|#39);/g, entity => entities[entity])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let imageLabel = '图片'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Markdown images become preview buttons. Remote/data URLs can load directly;
|
|
35
|
+
* local paths are placeholders that the client resolves through the authenticated file API.
|
|
36
|
+
* Returns null when the target is neither an image URL nor a local path.
|
|
37
|
+
*/
|
|
38
|
+
function imageHtml(altEscaped, urlEscaped, fileLinks) {
|
|
39
|
+
let raw = String(urlEscaped || '').trim()
|
|
40
|
+
if (raw.startsWith('<') && raw.endsWith('>')) raw = raw.slice(4, -4)
|
|
41
|
+
let target = decodeEntities(raw)
|
|
42
|
+
if (/^file:/i.test(target) && files?.pathOf) target = files.pathOf(target) || target
|
|
43
|
+
const alt = decodeEntities(String(altEscaped || '')).replace(/<[^>]*>/g, '').trim()
|
|
44
|
+
const label = escapeHtml(alt || imageLabel)
|
|
45
|
+
if (/^(?:data:image\/|https?:\/\/|\/api\/)/i.test(target)) {
|
|
46
|
+
return '<button type="button" class="chat-image" data-chat-image aria-label="' + label + '">' +
|
|
47
|
+
'<img src="' + escapeHtml(target) + '" alt="' + label + '" loading="lazy" draggable="false"></button>'
|
|
48
|
+
}
|
|
49
|
+
if (!fileLinks) return null
|
|
50
|
+
const local = /^(?:[A-Za-z]:[\\/]|\\\\|\/|\.{1,2}[\\/]|[^:\s]+[\\/])/.test(target)
|
|
51
|
+
|| /^[^:\s]+\.(?:png|jpe?g|gif|webp|bmp|svg|avif)$/i.test(target)
|
|
52
|
+
if (!local) return null
|
|
53
|
+
return '<button type="button" class="chat-image is-loading" data-chat-image data-chat-image-path="' + escapeHtml(target) +
|
|
54
|
+
'" data-chat-image-alt="' + label + '" aria-label="' + label + '"><span class="chat-image-status">' + label + '</span></button>'
|
|
55
|
+
}
|
|
56
|
+
|
|
26
57
|
function inline(s, fileLinks) {
|
|
58
|
+
// Pull images out before inline emphasis/link rules so alt text and URLs stay intact.
|
|
59
|
+
const images = []
|
|
60
|
+
s = s.replace(/!\[([^\]]*)\]\(([^)\n]+)\)/g, function (m, alt, url) {
|
|
61
|
+
const html = imageHtml(alt, url, fileLinks)
|
|
62
|
+
if (!html) return m
|
|
63
|
+
images.push(html)
|
|
64
|
+
return '\u0000IMAGE' + (images.length - 1) + '\u0000'
|
|
65
|
+
})
|
|
27
66
|
s = s.replace(/`([^`]+)`/g, '<code>$1</code>')
|
|
28
67
|
s = s.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
|
|
29
68
|
s = s.replace(/(^|[^*])\*([^*\n]+)\*/g, '$1<em>$2</em>')
|
|
@@ -40,7 +79,7 @@
|
|
|
40
79
|
if (!/^https?:\/\//i.test(url) || /\s/.test(url)) return m
|
|
41
80
|
return '<a href="' + url + '" target="_blank" rel="noopener noreferrer">' + text + '</a>'
|
|
42
81
|
})
|
|
43
|
-
return s
|
|
82
|
+
return images.length ? s.replace(/\u0000IMAGE(\d+)\u0000/g, (m, index) => images[Number(index)] || '') : s
|
|
44
83
|
}
|
|
45
84
|
|
|
46
85
|
function tableCells(line) {
|
|
@@ -172,6 +211,7 @@
|
|
|
172
211
|
}
|
|
173
212
|
|
|
174
213
|
function mdToHtml(text, options) {
|
|
214
|
+
if (options?.imageLabel) imageLabel = String(options.imageLabel)
|
|
175
215
|
var raw = String(text == null ? '' : text)
|
|
176
216
|
var parts = raw.split(/```/)
|
|
177
217
|
var out = ''
|
package/public/motion.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
const targets = children.length ? children : [view]
|
|
49
49
|
gsap.killTweensOf([view, ...targets])
|
|
50
50
|
gsap.set(view, { autoAlpha: 1, clearProps: 'transform' })
|
|
51
|
-
if (reduced) {
|
|
51
|
+
if (reduced || document.body?.classList?.contains('workflow-v8')) {
|
|
52
52
|
clear([view, ...targets])
|
|
53
53
|
return
|
|
54
54
|
}
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
if (container.dataset.motionListSignature === signature) return
|
|
75
75
|
container.dataset.motionListSignature = signature
|
|
76
76
|
gsap.killTweensOf(items)
|
|
77
|
-
if (reduced) {
|
|
77
|
+
if (reduced || document.body?.classList?.contains('workflow-v8')) {
|
|
78
78
|
clear(items)
|
|
79
79
|
return
|
|
80
80
|
}
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
gsap.killTweensOf(existing)
|
|
98
98
|
render()
|
|
99
99
|
const next = [...container.querySelectorAll(selector)]
|
|
100
|
-
if (reduced) {
|
|
100
|
+
if (reduced || document.body?.classList?.contains('workflow-v8')) {
|
|
101
101
|
clear(next)
|
|
102
102
|
return true
|
|
103
103
|
}
|