dsh-remote-plugin 0.7.5 → 0.8.0-rc.2
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 +708 -12
- package/index.mjs +20 -5
- package/package.json +1 -1
- package/plugin-center.mjs +9 -2
- package/public/admin.html +4 -0
- package/public/admin.js +4 -0
- package/public/app.js +237 -37
- package/public/chat-files.js +74 -4
- package/public/desktop/desktop.css +16 -2
- package/public/desktop/desktop.html +6 -0
- package/public/desktop/desktop.js +106 -29
- package/public/index.html +9 -3
- package/public/md.js +14 -7
- package/public/motion.js +3 -3
- package/public/network.js +7 -1
- package/public/operations.js +109 -0
- package/public/relay-settings.css +2 -0
- package/public/relay-settings.js +119 -0
- package/public/styles.css +20 -2
- package/public/update.json +6 -6
- package/public/version.json +1 -1
- package/public/workflow.css +151 -0
- package/public/workflow.js +286 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/* 0.8 task navigation. Existing controllers retain all protocol ownership. */
|
|
2
|
+
;(function(root) {
|
|
3
|
+
'use strict'
|
|
4
|
+
let config, sheet, connectionButton, attention, operationList
|
|
5
|
+
let receiptIdentity=''
|
|
6
|
+
const $ = id => document.getElementById(id)
|
|
7
|
+
const label = (zh,en) => root.I18N?.lang === 'en' ? en : zh
|
|
8
|
+
function element(tag,cls,text) { const el=document.createElement(tag);if(cls)el.className=cls;if(text)el.textContent=text;return el }
|
|
9
|
+
function icon(name) {
|
|
10
|
+
const paths={host:'M3 4h18v12H3zM8 21h8m-4-5v5',plugins:'M9 3h6v6h6v6h-6v6H9v-6H3V9h6z',
|
|
11
|
+
receipts:'M6 3h12v18l-3-2-3 2-3-2-3 2zM9 8h6m-6 4h6',general:'M12 3v3m0 12v3M3 12h3m12 0h3M6 6l2 2m8 8 2 2M6 18l2-2M16 8l2-2M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0',
|
|
12
|
+
model:'m12 3 9 5-9 5-9-5zM3 12l9 5 9-5M3 16l9 5 9-5',notify:'M6 9a6 6 0 0 1 12 0c0 7 3 7 3 8H3c0-1 3-1 3-8m4 12h4',about:'M12 11v6m0-10v.1M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0'}
|
|
13
|
+
const svg=document.createElementNS('http://www.w3.org/2000/svg','svg')
|
|
14
|
+
for(const [key,value] of Object.entries({viewBox:'0 0 24 24',fill:'none',stroke:'currentColor','stroke-width':'1.7','stroke-linecap':'round','stroke-linejoin':'round','aria-hidden':'true'}))svg.setAttribute(key,value)
|
|
15
|
+
const path=document.createElementNS(svg.namespaceURI,'path');path.setAttribute('d',paths[name]||paths.host);svg.append(path);return svg
|
|
16
|
+
}
|
|
17
|
+
function button(zh,en,action,cls='workflow-button') {
|
|
18
|
+
const el=element('button',cls),caption=element('span');el.type='button';caption.dataset.flowZh=zh;caption.dataset.flowEn=en;el.append(caption)
|
|
19
|
+
el.addEventListener('click',action);return el
|
|
20
|
+
}
|
|
21
|
+
function rename(target,zh,en) {
|
|
22
|
+
if(!target)return
|
|
23
|
+
target.removeAttribute('data-i18n');target.dataset.flowZh=zh;target.dataset.flowEn=en
|
|
24
|
+
}
|
|
25
|
+
function openSheet(title,content) {
|
|
26
|
+
sheet.querySelector('h2').textContent=title
|
|
27
|
+
const body=sheet.querySelector('.workflow-sheet-body')
|
|
28
|
+
for(const child of [...body.children])if(child.id==='workflow-model-content'){child.hidden=true;document.body.append(child)}
|
|
29
|
+
if(content.id==='workflow-model-content')content.hidden=false
|
|
30
|
+
body.replaceChildren(content)
|
|
31
|
+
if(!sheet.open)sheet.showModal()
|
|
32
|
+
}
|
|
33
|
+
function close() { sheet?.close() }
|
|
34
|
+
function openModels() {
|
|
35
|
+
const content=$('workflow-model-content')
|
|
36
|
+
if(content)openSheet(label('模型与思考深度','Model and reasoning'),content)
|
|
37
|
+
config.models?.()
|
|
38
|
+
}
|
|
39
|
+
async function showOperations() {
|
|
40
|
+
const content=element('div');operationList=content
|
|
41
|
+
openSheet(label('操作确认','Operation receipts'),content)
|
|
42
|
+
if(config.operations)await root.DshOperations?.restore(config.operations())
|
|
43
|
+
void refreshOperations()
|
|
44
|
+
}
|
|
45
|
+
async function refreshOperations() {
|
|
46
|
+
if(!operationList||!sheet.open)return
|
|
47
|
+
const target=operationList;target.replaceChildren()
|
|
48
|
+
const rows=root.DshOperations?.pending()||[]
|
|
49
|
+
if(!rows.length)target.append(element('p','workflow-muted',label('没有待确认操作。','No unconfirmed operations.')))
|
|
50
|
+
for(const row of rows){
|
|
51
|
+
const item=element('div','workflow-receipt')
|
|
52
|
+
item.append(element('strong','',row.method),element('code','',row.id),element('span','workflow-muted',label('结果待确认,不会自动重复提交','Unconfirmed; never automatically submitted again')))
|
|
53
|
+
const check=button('查询结果','Check result',async()=>{
|
|
54
|
+
check.disabled=true
|
|
55
|
+
try {
|
|
56
|
+
const value=await root.DshOperations.check(row.id)
|
|
57
|
+
if(!sheet.open||target!==operationList)return
|
|
58
|
+
item.append(element('p','',value?label('当前状态:','Status: ')+value.phase:label('暂时无法确认,请核对会话。','Unable to confirm. Check the conversation.')))
|
|
59
|
+
if(value?.phase==='complete'){config.refresh();config.recover?.(row,value);check.remove()}
|
|
60
|
+
}catch{item.append(element('p','',label('网络不可达,可稍后查询。','Network unavailable. Check later.')))}
|
|
61
|
+
finally{check.disabled=false}
|
|
62
|
+
});item.append(check)
|
|
63
|
+
if(row.phase==='unknown')item.append(button('核对后结束跟踪','Finish tracking after checking',()=>{
|
|
64
|
+
if(!root.confirm(label('请先核对主机会话记录。结束跟踪后,相同操作将作为新请求提交;如果原操作已执行,再次提交会重复。确定结束跟踪?','Check the conversation on the host first. After tracking ends, the same action will create a new request and may duplicate a completed action. Finish tracking?')))return
|
|
65
|
+
if(root.DshOperations.dismiss(row.id))void refreshOperations()
|
|
66
|
+
}))
|
|
67
|
+
target.append(item)
|
|
68
|
+
}
|
|
69
|
+
translate()
|
|
70
|
+
}
|
|
71
|
+
async function preview(connection,path,name) {
|
|
72
|
+
if(!connection.valid())return
|
|
73
|
+
const content=element('div'),status=element('p','workflow-muted',label('正在读取…','Loading…'));content.append(status)
|
|
74
|
+
openSheet(name,content)
|
|
75
|
+
try{
|
|
76
|
+
const url=new URL(connection.server+'/fs/preview',location.href);url.searchParams.set('path',path)
|
|
77
|
+
const response=await root.fetch(url,{headers:connection.headers,signal:AbortSignal.timeout(root.DshNetwork?.profile().readTimeout||45000)})
|
|
78
|
+
const value=await response.json()
|
|
79
|
+
if(!connection.valid()||!sheet.open||!sheet.contains(content))return
|
|
80
|
+
if(!response.ok)throw Error(value.error||('HTTP '+response.status))
|
|
81
|
+
content.replaceChildren(element('code','workflow-muted',value.path||path))
|
|
82
|
+
const source=element('pre','workflow-file-source',value.content||'');content.append(source)
|
|
83
|
+
if(/\.md$|\.markdown$/i.test(name)&&root.mdToHtml){
|
|
84
|
+
const rendered=element('div','workflow-file-markdown');rendered.innerHTML=root.mdToHtml(value.content||'');content.append(rendered);source.hidden=true
|
|
85
|
+
const toggle=button('源码 / 预览','Source / preview',()=>{source.hidden=!source.hidden;rendered.hidden=!rendered.hidden})
|
|
86
|
+
content.prepend(toggle);translate()
|
|
87
|
+
}
|
|
88
|
+
}catch(error){if(connection.valid()&&sheet.open&&sheet.contains(content))status.textContent=label('无法预览:','Unable to preview: ')+error.message}
|
|
89
|
+
}
|
|
90
|
+
function connectionDetails() {
|
|
91
|
+
const content=element('div','workflow-connection-content'),snapshot=config.snapshot()
|
|
92
|
+
content.append(element('p','',snapshot.host||label('当前页面主机','Current host')))
|
|
93
|
+
content.append(element('p','workflow-muted',label('连接主机后,工作区与会话始终归属这台主机。','Workspaces and conversations belong to the selected host.')))
|
|
94
|
+
const links=$(config.desktop?'view-overview':'view-activity')
|
|
95
|
+
if(links){
|
|
96
|
+
const details=element('details','workflow-technical'),summary=element('summary','',label('连接与运行详情','Connection details'))
|
|
97
|
+
details.append(summary);const clone=element('div','workflow-link-status')
|
|
98
|
+
for(const [key,name] of [['gateway','网关 / Gateway'],['dsh','DSH'],['mux','实时 / mux'],['hostEvents','主机事件 / host']]){
|
|
99
|
+
clone.append(element('p','',name+' · '+(snapshot[key]?label('在线','Online'):label('未就绪','Not ready'))))
|
|
100
|
+
}
|
|
101
|
+
details.append(clone);content.append(details)
|
|
102
|
+
}
|
|
103
|
+
content.append(button('重新检查','Check connection',()=>{config.retry();close()}),button('主机与连接','Hosts and connections',()=>{close();config.settings('servers')}))
|
|
104
|
+
if(snapshot.gateway)content.append(button('打开管理控制台','Open management console',()=>config.admin()))
|
|
105
|
+
openSheet(label('当前主机','Current host'),content);translate()
|
|
106
|
+
}
|
|
107
|
+
function setupMore() {
|
|
108
|
+
const home=$('settings-home');if(!home)return
|
|
109
|
+
const intro=element('div','workflow-page-head');const heading=element('h1');rename(heading,'更多','More');intro.append(heading);home.prepend(intro)
|
|
110
|
+
const plugins=button('主机插件','Host plugins',()=>config.plugins(),'workflow-setting-link')
|
|
111
|
+
const receipts=button('操作确认','Operation receipts',showOperations,'workflow-setting-link')
|
|
112
|
+
const main=home.querySelector('.settings-group,.ds-settings');main?.prepend(plugins);main?.append(receipts)
|
|
113
|
+
const names={servers:['主机与连接','Hosts and connections'],general:['外观与输入','Appearance and input'],model:['模型与提供方','Models and providers'],notify:['通知与后台','Notifications and background'],about:['关于与维护','About and maintenance']}
|
|
114
|
+
for(const [key,nameset] of Object.entries(names)){
|
|
115
|
+
const row=home.querySelector(`[data-settings-group="${key}"]`)
|
|
116
|
+
rename(row?.querySelector('.setting-name,.ds-setting-name'),...nameset)
|
|
117
|
+
const page=$('settings-page-'+key)
|
|
118
|
+
rename(page?.querySelector('[data-settings-back] .setting-name,[data-settings-back] .ds-setting-name'),...nameset)
|
|
119
|
+
if(row){const mark=element('span','workflow-setting-icon');mark.append(icon(key==='servers'?'host':key));row.prepend(mark)}
|
|
120
|
+
}
|
|
121
|
+
for(const [target,name] of [[plugins,'plugins'],[receipts,'receipts']]){const mark=element('span','workflow-setting-icon');mark.append(icon(name));target.prepend(mark)}
|
|
122
|
+
const work=element('section','workflow-more-group'),preferences=element('section','workflow-more-group')
|
|
123
|
+
const workTitle=element('h2'),preferenceTitle=element('h2');rename(workTitle,'连接与工作','Connections and work');rename(preferenceTitle,'偏好与维护','Preferences and maintenance')
|
|
124
|
+
const workList=element('div','workflow-settings-list'),preferenceList=element('div','workflow-settings-list')
|
|
125
|
+
const host=home.querySelector('[data-settings-group="servers"]');if(host)workList.append(host)
|
|
126
|
+
workList.append(plugins,receipts);work.append(workTitle,workList)
|
|
127
|
+
for(const name of ['general','model','notify','about']){const row=home.querySelector(`[data-settings-group="${name}"]`);if(row)preferenceList.append(row)}
|
|
128
|
+
preferences.append(preferenceTitle,preferenceList);home.append(work,preferences)
|
|
129
|
+
home.querySelector('[data-settings-group="tests"]')?.remove()
|
|
130
|
+
home.querySelector('[data-settings-group="theme"]')?.remove()
|
|
131
|
+
const general=$('settings-page-general'),theme=$('settings-page-theme')
|
|
132
|
+
if(general&&theme){
|
|
133
|
+
const groups=config.desktop?[...theme.querySelectorAll(':scope > .ds-setting-row')].slice(1):[...theme.querySelectorAll('.settings-group')].slice(1)
|
|
134
|
+
for(const group of groups)general.append(group)
|
|
135
|
+
}
|
|
136
|
+
const defaultMode=$('busy-send-mode')?.closest('.setting-row');if(defaultMode)defaultMode.hidden=true
|
|
137
|
+
const gesture=$('opt-steer-send')?.closest('.setting-row')
|
|
138
|
+
rename(gesture?.querySelector('.setting-name'),'长按快捷插队','Hold to steer')
|
|
139
|
+
rename(gesture?.querySelector('.setting-desc'),'运行时长按发送可插队;普通点击仍排队。','Hold to steer while running; clicking still queues.')
|
|
140
|
+
for(const id of ['btn-change-token','token-desc','desktop-token-input']){
|
|
141
|
+
const row=$(id)?.closest('.setting-row,.ds-setting-row,.desktop-connect-form')
|
|
142
|
+
if(row&&home.contains(row))$('settings-page-servers')?.append(row)
|
|
143
|
+
}
|
|
144
|
+
const language=$('btn-lang')?.closest('.setting-row,.ds-setting-row')
|
|
145
|
+
if(language&&home.contains(language))general?.append(language)
|
|
146
|
+
const about=$('settings-page-about'),servers=$('settings-page-servers')
|
|
147
|
+
if(about&&config.feedback)about.append(button('提交反馈','Send feedback',config.feedback))
|
|
148
|
+
for(const id of ['btn-dsh-start','btn-host-describe']){const row=$(id)?.closest('.setting-row,.ds-setting-row');if(row&&about?.contains(row))servers?.append(row)}
|
|
149
|
+
const support=home.querySelector('.feedback-card');if(support)about?.append(support)
|
|
150
|
+
home.querySelector('p.about')?.remove()
|
|
151
|
+
const data=element('section','workflow-data-settings');data.append(element('h3','',label('本地数据','Local data')))
|
|
152
|
+
data.append(button('清除历史缓存','Clear history cache',()=>config.clear('history')),button('移除当前连接','Remove current connection',()=>config.clear('connection')),button('清除全部本地配置','Clear all local settings',()=>config.clear('all'),'workflow-button workflow-danger'))
|
|
153
|
+
about?.append(data)
|
|
154
|
+
const reset=$('btn-reset')?.closest('.setting-row,.ds-setting-row');if(reset)reset.hidden=true
|
|
155
|
+
for(const group of home.querySelectorAll('.settings-group,.ds-settings')){
|
|
156
|
+
if(!group.children.length)group.remove()
|
|
157
|
+
else if([...group.children].every(child=>child.hidden||child.classList.contains('hidden')))group.hidden=true
|
|
158
|
+
}
|
|
159
|
+
const wb=$(config.desktop?'workbench-box':'workbench-bar')
|
|
160
|
+
if(wb&&servers){const details=element('details','workflow-technical'),summary=element('summary','',label('高级目录组织(原工作台)','Advanced folder organization'))
|
|
161
|
+
details.append(summary,wb,button('发现并登记子目录','Discover subfolders',()=>config.discover()));servers.append(details)}
|
|
162
|
+
if(servers)servers.append(button('打开管理控制台','Open management console',()=>config.admin()))
|
|
163
|
+
const workspace=$('modal-workspace')?.querySelector('.modal-body,.ds-modal-body')
|
|
164
|
+
if(workspace&&config.register)workspace.append(button('使用当前目录,不新建文件夹','Use current folder',()=>config.register()))
|
|
165
|
+
const noWorkspaces=$('new-session-empty')
|
|
166
|
+
if(noWorkspaces)noWorkspaces.after(button('浏览主机目录','Browse host folders',()=>{config.browse?.()}))
|
|
167
|
+
const notify=$('settings-page-notify')
|
|
168
|
+
if(notify){
|
|
169
|
+
const more=element('details','workflow-technical');more.append(element('summary','',label('后台间隔与通知排障','Background interval and diagnostics')))
|
|
170
|
+
for(const id of ['bg-interval','btn-test-notify','opt-peak-remind']){const row=$(id)?.closest('.setting-row');if(row)more.append(row)}
|
|
171
|
+
notify.append(more)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function setupComposer() {
|
|
175
|
+
if(!config.desktop){
|
|
176
|
+
const content=element('div');content.id='workflow-model-content'
|
|
177
|
+
for(const id of ['menu-models','menu-effort-group']){const row=$(id);if(row)content.append(id==='menu-models'?row.closest('.menu-group'):row)}
|
|
178
|
+
content.hidden=true;document.body.append(content)
|
|
179
|
+
const controls=element('div','workflow-composer-config')
|
|
180
|
+
const models=button('模型','Model',()=>{content.hidden=false;openModels()});models.id='workflow-models';models.prepend(icon('model'));controls.append(models)
|
|
181
|
+
$('composer-wrap')?.querySelector('.composer')?.append(controls)
|
|
182
|
+
rename($('btn-plus'),'指令','Commands')
|
|
183
|
+
}
|
|
184
|
+
const send=$('btn-send');if(!send)return
|
|
185
|
+
const alternate=button('插队发送','Steer',()=>config.send('steer'),'workflow-button workflow-steer')
|
|
186
|
+
alternate.id='workflow-steer';send.after(alternate)
|
|
187
|
+
const actions=$('session-actions')
|
|
188
|
+
if(actions){
|
|
189
|
+
actions.append(button('查看工作区文件','Workspace files',()=>{actions.close();config.files()}),
|
|
190
|
+
button('导出会话','Export conversation',()=>{actions.close();void config.command('/export')}),
|
|
191
|
+
button('压缩上下文','Compact context',()=>{actions.close();void config.command('/compact')}))
|
|
192
|
+
}
|
|
193
|
+
for(const el of document.querySelectorAll('[data-cmd="/compact"],[data-cmd="/export"],[data-ds-cmd="/compact"],[data-ds-cmd="/export"]'))el.remove()
|
|
194
|
+
}
|
|
195
|
+
function setupStart() {
|
|
196
|
+
const desktop=config.desktop,home=$(desktop?'view-sessions':'view-home');if(!home)return
|
|
197
|
+
const head=element('section','workflow-start')
|
|
198
|
+
const title=element('div','workflow-page-head'),heading=element('h1');rename(heading,desktop?'会话':'工作空间',desktop?'Conversations':'Workspace');title.append(heading)
|
|
199
|
+
connectionButton=button('检查连接…','Checking connection…',connectionDetails,'workflow-connection');connectionButton.id='workflow-connection'
|
|
200
|
+
connectionButton.removeAttribute('data-flow-zh');connectionButton.removeAttribute('data-flow-en')
|
|
201
|
+
title.append(connectionButton);head.append(title)
|
|
202
|
+
if(!desktop){
|
|
203
|
+
const workspace=$('workspace-nav'),create=$('btn-new-session')
|
|
204
|
+
if(workspace)head.append(workspace)
|
|
205
|
+
if(create){create.classList.add('workflow-new-session');head.append(create)}
|
|
206
|
+
rename(home.querySelector('.section-head > span:first-child'),'最近会话','Recent conversations')
|
|
207
|
+
}
|
|
208
|
+
attention=element('section','workflow-attention');attention.id='workflow-attention'
|
|
209
|
+
const attentionTitle=element('h2');rename(attentionTitle,'待处理','Needs attention');attention.append(attentionTitle)
|
|
210
|
+
const pending=$(desktop?'ds-overview-attention-list':'overview-attention-list');if(pending)attention.append(pending)
|
|
211
|
+
head.append(attention)
|
|
212
|
+
const notice=element('div','workflow-notice');notice.id='workflow-unconfirmed';notice.hidden=true
|
|
213
|
+
notice.append(element('span','',label('有操作结果待确认','Some operation results are unconfirmed')),button('查看回执','Check receipts',showOperations));head.append(notice)
|
|
214
|
+
home.prepend(head)
|
|
215
|
+
const announcements=$('overview-announcement-board')
|
|
216
|
+
if(announcements)$('settings-page-about')?.append(announcements)
|
|
217
|
+
const stat=$('stat-strip');if(stat)stat.hidden=true
|
|
218
|
+
}
|
|
219
|
+
function translate() {
|
|
220
|
+
const english=root.I18N?.lang==='en'
|
|
221
|
+
for(const el of document.querySelectorAll('[data-flow-zh]'))el.textContent=english?el.dataset.flowEn:el.dataset.flowZh
|
|
222
|
+
if(!config.desktop&&$('btn-plus')){
|
|
223
|
+
$('btn-plus').setAttribute('aria-label',label('指令与权限','Commands and permissions'))
|
|
224
|
+
$('btn-plus').title=label('指令与权限','Commands and permissions')
|
|
225
|
+
}
|
|
226
|
+
$('workflow-models')?.setAttribute('aria-label',label('模型与思考深度','Model and reasoning'))
|
|
227
|
+
}
|
|
228
|
+
function update() {
|
|
229
|
+
if(!config)return
|
|
230
|
+
const snapshot=config.snapshot(),english=root.I18N?.lang==='en'
|
|
231
|
+
if(snapshot.token&&config.operations&&root.DshOperations){
|
|
232
|
+
const context=config.operations(),identity=JSON.stringify([context.url('/api/operations'),context.headers.authorization])
|
|
233
|
+
if(identity!==receiptIdentity){receiptIdentity=identity;void root.DshOperations.restore(context).then(()=>{if(identity===receiptIdentity)update()}).catch(()=>{})}
|
|
234
|
+
}
|
|
235
|
+
if(connectionButton){
|
|
236
|
+
const status=!snapshot.token?label('连接主机','Connect host'):snapshot.gateway&&snapshot.dsh?label('已连接','Connected'):label('正在恢复连接','Reconnecting')
|
|
237
|
+
connectionButton.textContent=status+' · '+(snapshot.host||label('当前主机','Current host'))
|
|
238
|
+
connectionButton.classList.toggle('is-online',!!snapshot.gateway&&!!snapshot.dsh)
|
|
239
|
+
}
|
|
240
|
+
if(attention)attention.hidden=!snapshot.pending
|
|
241
|
+
const alternate=$('workflow-steer');if(alternate){alternate.hidden=!snapshot.busy;alternate.disabled=!!snapshot.sending}
|
|
242
|
+
const send=$('btn-send');if(send&&!snapshot.sending){send.textContent=snapshot.busy?label('排队发送','Queue'):label('发送','Send');send.setAttribute('aria-label',send.textContent)}
|
|
243
|
+
const unconfirmed=$('workflow-unconfirmed');if(unconfirmed)unconfirmed.hidden=!(root.DshOperations?.pending().some(row=>row.phase==='unknown'))
|
|
244
|
+
document.documentElement.dataset.workflowLang=english?'en':'zh'
|
|
245
|
+
translate()
|
|
246
|
+
}
|
|
247
|
+
function mount(options) {
|
|
248
|
+
if(config)return;config=options;document.body.classList.add('workflow-v8')
|
|
249
|
+
sheet=element('dialog','workflow-sheet');sheet.id='workflow-sheet'
|
|
250
|
+
const header=element('header','workflow-sheet-head');header.append(element('h2'),button('关闭','Close',close));sheet.append(header,element('div','workflow-sheet-body'));document.body.append(sheet)
|
|
251
|
+
sheet.addEventListener('click',event=>{if(event.target===sheet)close()})
|
|
252
|
+
setupMore();setupStart();setupComposer();config.start?.()
|
|
253
|
+
const relaySettings=$('relay-settings')
|
|
254
|
+
if(relaySettings){$('settings-page-servers')?.append(relaySettings);root.DshRelaySettings?.mount(relaySettings,{connection:config.operations})}
|
|
255
|
+
const overview=$('view-activity');if(overview)overview.dataset.workflowLegacy='overview'
|
|
256
|
+
if(!config.desktop){
|
|
257
|
+
const badge=$('nav-pending')
|
|
258
|
+
if(badge)badge.remove()
|
|
259
|
+
for(const el of document.querySelectorAll('.bottom-nav [data-view="view-activity"],.bottom-nav [data-view="view-plugins"],nav [data-view="view-activity"],nav [data-view="view-plugins"]'))el.remove()
|
|
260
|
+
rename(document.querySelector('nav [data-view="view-settings"] [data-i18n]'),'更多','More')
|
|
261
|
+
if(badge)document.querySelector('nav [data-view="view-home"]')?.append(badge)
|
|
262
|
+
for(const id of ['btn-donate','btn-feedback']){const el=$(id);if(el)el.hidden=true}
|
|
263
|
+
}else{
|
|
264
|
+
const sessions=document.querySelector('.ds-nav-item[data-view="view-overview"]')
|
|
265
|
+
if(sessions){sessions.dataset.view='view-sessions';rename(sessions.querySelector('[data-i18n]'),'会话','Conversations')}
|
|
266
|
+
for(const el of document.querySelectorAll('.ds-nav-item[data-view="view-plugins"]'))el.hidden=true
|
|
267
|
+
rename(document.querySelector('[data-view="view-settings"] [data-i18n]'),'更多','More')
|
|
268
|
+
const feedback=$('btn-feedback');if(feedback)feedback.hidden=true
|
|
269
|
+
}
|
|
270
|
+
new MutationObserver(update).observe(document.documentElement,{attributes:true,attributeFilter:['lang']})
|
|
271
|
+
root.addEventListener('dsh-operation-change',update)
|
|
272
|
+
update()
|
|
273
|
+
}
|
|
274
|
+
function clearStorage() {
|
|
275
|
+
const keys=new Set(['activeServer','busySendMode','dsShowArchivedV1','dshAdminDoctorCollapsed','dshAdminToken',
|
|
276
|
+
'dshLang','dshNetworkModeV1','dshTheme','fsWorkspaceIdV1','lastNewSessionWorkspaceV1','mobileEnterAction',
|
|
277
|
+
'notify','peakRemind','server','servers','servers-v1','servers-v2','sessionSort','showArchivedV1','showTools',
|
|
278
|
+
'steerSendingEnabled','token','workspaceFilterV1','dshRemoteClientIdV2','dshPromptPresets','seenNotesVersion',
|
|
279
|
+
'dshCollapsedGoalsV1','workbenchOrderV1','seenAnnouncementsV1','announcementHistoryV1','announcementVotesV1',
|
|
280
|
+
'dshAdminEnabledHostIPsV1','dshAdminManualHostIPsV1','dshRemoteOperationReceiptsV1'])
|
|
281
|
+
for(const key of Object.keys(localStorage))if(keys.has(key)||/^(?:sessions|history)Cache/.test(key))localStorage.removeItem(key)
|
|
282
|
+
sessionStorage.removeItem('dshRemoteOperationReceiptsV1')
|
|
283
|
+
sessionStorage.removeItem('dshRemoteLayout')
|
|
284
|
+
}
|
|
285
|
+
root.DshWorkflow={mount,update,close,connectionDetails,showOperations,clearStorage,preview,isMounted:()=>!!config}
|
|
286
|
+
})(window)
|