dsh-remote-plugin 0.8.2 → 0.8.4

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.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/apk/dsh-remote.apk +0 -0
  3. package/approval-summary.mjs +115 -0
  4. package/gateway.cjs +708 -70
  5. package/index.mjs +12 -0
  6. package/insights.mjs +6 -4
  7. package/market.mjs +4 -1
  8. package/package.json +2 -1
  9. package/plugin-center.mjs +208 -24
  10. package/plugin-transaction.mjs +29 -6
  11. package/public/admin.html +33 -34
  12. package/public/admin.js +12 -24
  13. package/public/announcements.json +31 -0
  14. package/public/app.js +99 -80
  15. package/public/approval-summary.js +78 -0
  16. package/public/build.json +2 -2
  17. package/public/cache-upgrade.js +51 -0
  18. package/public/chat-copy.js +59 -0
  19. package/public/desktop/desktop.css +23 -34
  20. package/public/desktop/desktop.html +83 -96
  21. package/public/desktop/desktop.js +68 -51
  22. package/public/e2ee-transport.js +147 -0
  23. package/public/extensions.js +6 -6
  24. package/public/history.js +88 -6
  25. package/public/image-cache.js +141 -0
  26. package/public/image-preview.js +48 -5
  27. package/public/index.html +86 -104
  28. package/public/md.js +39 -15
  29. package/public/motion.js +1 -1
  30. package/public/plugin-center.css +1 -0
  31. package/public/plugin-center.js +93 -12
  32. package/public/plugin.html +27 -20
  33. package/public/relay-devices.js +74 -0
  34. package/public/relay-settings.css +7 -0
  35. package/public/relay-settings.js +17 -9
  36. package/public/session-deck.css +7 -1
  37. package/public/session-deck.js +1 -1
  38. package/public/skins/blue-fish/DESIGN.md +24 -0
  39. package/public/skins/blue-fish/preview.html +12 -289
  40. package/public/skins/blue-fish/skin.css +95 -585
  41. package/public/skins/blue-fish/sparkles.svg +18 -0
  42. package/public/skins/bocchi/DESIGN.md +99 -0
  43. package/public/skins/bocchi/face.png +0 -0
  44. package/public/skins/bocchi/grain.png +0 -0
  45. package/public/skins/bocchi/icon-blush.png +0 -0
  46. package/public/skins/bocchi/icon-sleep.png +0 -0
  47. package/public/skins/bocchi/icon-smile.png +0 -0
  48. package/public/skins/bocchi/icon-star.png +0 -0
  49. package/public/skins/bocchi/icon-wink.png +0 -0
  50. package/public/skins/bocchi/icon.png +0 -0
  51. package/public/skins/bocchi/pattern-soft.png +0 -0
  52. package/public/skins/bocchi/pattern.png +0 -0
  53. package/public/skins/bocchi/preview.html +55 -0
  54. package/public/skins/bocchi/skin.css +233 -0
  55. package/public/skins/bocchi/stage-bg.png +0 -0
  56. package/public/skins/bocchi/stage-soft.png +0 -0
  57. package/public/skins/bocchi/stand.png +0 -0
  58. package/public/skins/bocchi/sticker-guitar.png +0 -0
  59. package/public/skins/kessoku/DESIGN.md +38 -0
  60. package/public/skins/kessoku/grain.png +0 -0
  61. package/public/skins/kessoku/skin.css +212 -0
  62. package/public/skins/kita/SOURCES.json +51 -0
  63. package/public/skins/kita/face.png +0 -0
  64. package/public/skins/kita/icon-live.png +0 -0
  65. package/public/skins/kita/icon-reddress.png +0 -0
  66. package/public/skins/kita/icon-seifuku.png +0 -0
  67. package/public/skins/kita/pattern.png +0 -0
  68. package/public/skins/kita/preview.html +56 -0
  69. package/public/skins/kita/skin.css +26 -0
  70. package/public/skins/kita/stand.png +0 -0
  71. package/public/skins/kita/sticker-live.png +0 -0
  72. package/public/skins/nijika/SOURCES.json +51 -0
  73. package/public/skins/nijika/face.png +0 -0
  74. package/public/skins/nijika/icon-live.png +0 -0
  75. package/public/skins/nijika/icon-reddress.png +0 -0
  76. package/public/skins/nijika/icon-seifuku.png +0 -0
  77. package/public/skins/nijika/pattern.png +0 -0
  78. package/public/skins/nijika/preview.html +56 -0
  79. package/public/skins/nijika/skin.css +25 -0
  80. package/public/skins/nijika/stand.png +0 -0
  81. package/public/skins/nijika/sticker-live.png +0 -0
  82. package/public/skins/penguin/DESIGN.md +33 -0
  83. package/public/skins/penguin/SOURCES.json +22 -0
  84. package/public/skins/penguin/aic-blueprint.svg +24 -0
  85. package/public/skins/penguin/endfield-triangles.svg +4 -0
  86. package/public/skins/penguin/face.png +0 -0
  87. package/public/skins/penguin/icon-blush.png +0 -0
  88. package/public/skins/penguin/icon-dizzy.png +0 -0
  89. package/public/skins/penguin/icon-laugh.png +0 -0
  90. package/public/skins/penguin/icon-sleep.png +0 -0
  91. package/public/skins/penguin/icon-smile.png +0 -0
  92. package/public/skins/penguin/icon-star.png +0 -0
  93. package/public/skins/penguin/icon-wink.png +0 -0
  94. package/public/skins/penguin/icon.png +0 -0
  95. package/public/skins/penguin/mascot.png +0 -0
  96. package/public/skins/penguin/pattern-night.png +0 -0
  97. package/public/skins/penguin/pattern.png +0 -0
  98. package/public/skins/penguin/preview.html +12 -0
  99. package/public/skins/penguin/skin.css +212 -0
  100. package/public/skins/ryo/SOURCES.json +51 -0
  101. package/public/skins/ryo/face.png +0 -0
  102. package/public/skins/ryo/icon-live.png +0 -0
  103. package/public/skins/ryo/icon-reddress.png +0 -0
  104. package/public/skins/ryo/icon-seifuku.png +0 -0
  105. package/public/skins/ryo/pattern.png +0 -0
  106. package/public/skins/ryo/preview.html +56 -0
  107. package/public/skins/ryo/skin.css +25 -0
  108. package/public/skins/ryo/stand.png +0 -0
  109. package/public/skins/ryo/sticker-live.png +0 -0
  110. package/public/sponsor-entry.js +21 -0
  111. package/public/styles.css +29 -19
  112. package/public/teams.js +2 -2
  113. package/public/theme-picker.css +58 -0
  114. package/public/theme-vars.css +532 -5
  115. package/public/theme.js +111 -3
  116. package/public/update.json +12 -12
  117. package/public/version.json +1 -1
  118. package/public/workflow.css +2 -1
  119. package/public/workflow.js +27 -5
  120. package/skills/dsh-remote-doctor/references/wiki/plugins.md +1 -1
  121. package/task-board.mjs +2 -2
  122. package/teams.mjs +7 -2
package/public/md.js CHANGED
@@ -6,9 +6,9 @@
6
6
  * 同时支持浏览器全局 window.mdToHtml 与 Node CommonJS module.exports。
7
7
  */
8
8
  (function (root, factory) {
9
- if (typeof module === 'object' && module.exports) module.exports = factory(require('./genui.js'), require('./chat-files.js'))
10
- else root.mdToHtml = factory(root.DshGenUi, root.DshChatFiles)
11
- })(typeof self !== 'undefined' ? self : this, function (genui, files) {
9
+ if (typeof module === 'object' && module.exports) module.exports = factory(require('./genui.js'), require('./chat-files.js'), () => require('./chat-copy.js'))
10
+ else root.mdToHtml = factory(root.DshGenUi, root.DshChatFiles, () => root.DshChatCopy)
11
+ })(typeof self !== 'undefined' ? self : this, function (genui, files, chatCopy) {
12
12
  'use strict'
13
13
 
14
14
  function escapeHtml(s) {
@@ -267,32 +267,56 @@
267
267
  return html
268
268
  }
269
269
 
270
+ function codeHtml(code, options, language) {
271
+ var pre = '<pre><code>' + escapeHtml(code) + '</code></pre>'
272
+ return options?.copyCode && chatCopy()?.code ? chatCopy().code(code, language, { label: options.copyCodeLabel, scope: options.copyScope }) : pre
273
+ }
274
+ // Match complete fence lines so Markdown containing its own ``` blocks can
275
+ // use a longer outer fence without splitting the content being copied.
276
+ function fencedParts(raw) {
277
+ var parts = [], cursor = 0, open = /^ {0,3}(`{3,}|~{3,})([^\n]*)(?:\n|$)/gm, match
278
+ while ((match = open.exec(raw))) {
279
+ if (match[1][0] === '`' && match[2].includes('`')) continue
280
+ if (match.index > cursor) parts.push({ text: raw.slice(cursor, match.index) })
281
+ var close = new RegExp('^ {0,3}' + match[1][0] + '{' + match[1].length + ',}[ \\t]*(?:\\n|$)', 'gm')
282
+ close.lastIndex = open.lastIndex
283
+ var end = close.exec(raw)
284
+ var source = raw.slice(open.lastIndex, end ? end.index : raw.length).replace(/\n$/, '')
285
+ var indent = match[0].match(/^ */)[0].length
286
+ if (indent) source = source.replace(new RegExp('^ {0,' + indent + '}', 'gm'), '')
287
+ parts.push({ code: source, info: match[2].trim(), closed: !!end })
288
+ cursor = end ? close.lastIndex : raw.length
289
+ open.lastIndex = cursor
290
+ if (!end) break
291
+ }
292
+ if (cursor < raw.length) parts.push({ text: raw.slice(cursor) })
293
+ return parts
294
+ }
270
295
  function mdToHtml(text, options) {
271
296
  if (options?.imageLabel) imageLabel = String(options.imageLabel)
272
297
  var raw = String(text == null ? '' : text).replace(/\r\n?/g, '\n')
273
- var parts = raw.split(/```/)
298
+ var parts = fencedParts(raw)
274
299
  var out = ''
275
300
  for (var i = 0; i < parts.length; i++) {
276
- if (i % 2 === 1) {
277
- var code = parts[i]
278
- code = code.replace(/^\n/, '')
279
- if (code.slice(-1) === '\n') code = code.slice(0, -1)
280
- var fence = code.match(/^([^\n]*)\n([\s\S]*)$/)
301
+ var part = parts[i]
302
+ if (part.code !== undefined) {
303
+ var code = part.code
304
+ var language = part.info.toLowerCase()
281
305
  // Wait for the closing fence: streaming partial JSON stays readable as source.
282
- if (options?.richContent !== false && genui && fence && i < parts.length - 1 && fence[2].length <= 200000) {
283
- var language = fence[1].trim().toLowerCase()
306
+ if (options?.richContent !== false && genui && part.closed && code.length <= 200000) {
284
307
  try {
285
308
  if (/^(?:dsh-ui|json dsh-ui|dsh-ui json)$/.test(language)) {
286
- out += genui.render(JSON.parse(fence[2])); continue
309
+ out += genui.render(JSON.parse(code)); continue
287
310
  }
288
311
  if (language === 'html' || language === 'htm') {
289
- out += genui.html(fence[2]) + '<details><summary>HTML / 源码</summary><pre><code>' + escapeHtml(fence[2]) + '</code></pre></details>'; continue
312
+ out += genui.html(code) + '<details><summary>HTML / 源码</summary>' + codeHtml(code, options, language) + '</details>'; continue
290
313
  }
291
314
  } catch (_) { /* Invalid or over-budget specs remain source, never execute. */ }
292
315
  }
293
- out += '<pre><code>' + escapeHtml(code) + '</code></pre>'
316
+ // A language header belongs to the fence, not to the copied source.
317
+ out += codeHtml(code, options, part.info.split(/\s+/)[0])
294
318
  } else {
295
- var escaped = escapeHtml(parts[i])
319
+ var escaped = escapeHtml(part.text)
296
320
  out += renderLines(escaped.split('\n').map(function (line) {
297
321
  return line.replace(/^[ \t]+/, function (indent) {
298
322
  var spaces = ''
package/public/motion.js CHANGED
@@ -549,7 +549,7 @@
549
549
  if (!becameVisible) continue
550
550
  if (node.matches('.view, .ds-view, [data-motion-view]')) view(node)
551
551
  else if (node.matches('.modal, .ds-modal, .sheet-backdrop, .sheet, .ds-drawer')) overlay(node)
552
- else if (node.matches('.composer-menu, .ds-group-menu, .ds-feedback-menu, .fb-menu')) popover(node)
552
+ else if (node.matches('.composer-menu, .ds-group-menu, .fb-menu')) popover(node)
553
553
  else if (node.matches('[data-motion-panel], .wb-panel, .ds-wb-panel, .doctor-body, .settings-subpage')) panel(node)
554
554
  }
555
555
  })
@@ -28,6 +28,7 @@
28
28
  .pc-recovery button{margin-top:10px}
29
29
  .pc-controls{border:1px solid var(--dsr-line,#30363d);border-radius:14px;padding:12px;margin-bottom:20px;background:var(--dsr-panel,#161b22)}
30
30
  .pc-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px}
31
+ .pc-toolbar{flex-wrap:wrap}.pc-toolbar-actions{display:flex;gap:6px;align-items:center;margin-left:auto}.pc-dialog .pc-update-all{padding:8px 10px;color:var(--dsr-accent-strong,#79c0ff)}
31
32
  .pc-tabs{display:flex;gap:3px;min-width:0;padding:3px;border-radius:10px;background:var(--dsr-bg-2,#11161e)}
32
33
  .pc-tabs button{white-space:nowrap;padding:8px 14px;background:transparent;border-color:transparent;color:var(--dsr-muted,#a7b0bc);border-radius:8px}
33
34
  .pc-tabs button.active{background:var(--dsr-accent-soft,#58a6ff1f);color:var(--dsr-accent-strong,#79c0ff)}
@@ -5,7 +5,7 @@ window.DshPluginCenter = (() => {
5
5
  const expandedDetails = new Map()
6
6
  const marketCompatibility = new Map()
7
7
  let renderedInstalled = '', renderedJobs = '', filter = '', statusFilter = 'all', refreshSequence = 0, trackedOperation = '', experimentalExpanded = false
8
- const labels = { install: '安装', update: '更新', remove: '卸载', restore: '恢复', enable: '启用', disable: '停用', queued: '等待执行', running: '执行中', complete: '已完成', failed: '失败', interrupted: '已中断', active: '运行中', pending: '等待依赖', loading: '加载中', disposed: '未运行', unloading: '卸载中', inactive: '未运行' }
8
+ const labels = { install: '安装', update: '更新', 'update-all': '批量更新', remove: '卸载', restore: '恢复', enable: '启用', disable: '停用', queued: '等待执行', running: '执行中', complete: '已完成', failed: '失败', interrupted: '已中断', active: '运行中', pending: '等待依赖', loading: '加载中', disposed: '未运行', unloading: '卸载中', inactive: '未运行' }
9
9
  const stages = { queued: '等待主机启动', backup: '备份配置', snapshot: '备份插件文件', restore: '恢复并校验', 'profile-lock': '检查配置锁', cli: '执行插件命令', verify: '保存并核验', complete: '完成' }
10
10
  function compareVersions(left, right) {
11
11
  const parse = value => {
@@ -56,12 +56,19 @@ window.DshPluginCenter = (() => {
56
56
  return el
57
57
  }
58
58
  function message(text) { dialog.querySelector('.pc-message').textContent = text }
59
+ function updateAllControl() {
60
+ const control = dialog.querySelector('.pc-update-all')
61
+ control.hidden = tab !== 'installed'
62
+ control.disabled = pending || !snapshot?.writable || snapshot.busy || snapshot.capabilities?.updateAll !== true
63
+ control.title = snapshot?.capabilities?.updateAll ? '检查全部已安装的 registry 插件,确认后批量更新' : '需要升级主机端 Remote 插件以支持批量更新'
64
+ for (const tab of dialog.querySelectorAll('[data-pc-tab]')) tab.disabled = pending
65
+ }
59
66
  async function api(path, body) {
60
67
  if (!connection.valid()) throw new Error('连接已切换,请关闭后重新打开插件中心')
61
68
  const current = generation
62
69
  const response = await fetch(connection.url('/remote/api/plugins' + path), {
63
70
  method: body ? 'POST' : 'GET', headers: { ...connection.headers, 'content-type': 'application/json' },
64
- ...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout(30000),
71
+ ...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout(path === '/preflight' ? 130000 : 30000),
65
72
  })
66
73
  if (current !== generation || !dialog.open || !connection.valid()) throw new Error('连接已切换,请重新打开插件中心')
67
74
  let data
@@ -233,6 +240,7 @@ window.DshPluginCenter = (() => {
233
240
  try { data = await api('/state') } catch (error) { if (sequence === refreshSequence) throw error; return }
234
241
  if (sequence !== refreshSequence) return
235
242
  snapshot = data
243
+ updateAllControl()
236
244
  window.DshExtensions?.remember(connection, snapshot)
237
245
  const tracked = snapshot.operations.find(job => job.id === trackedOperation)
238
246
  if (tracked && !['queued', 'running'].includes(tracked.phase)) {
@@ -284,6 +292,7 @@ window.DshPluginCenter = (() => {
284
292
  el.append(node('p', jobProgress(job), 'pc-job-progress'))
285
293
  el.append(node('p', job.message || '任务在主机端执行,可关闭窗口后回来查看。'))
286
294
  if (job.log) el.append(node('pre', job.log))
295
+ for (const target of job.targets || []) el.append(node('p', target.name + ' · ' + target.fromVersion + ' → ' + target.version + ' · ' + (labels[target.phase] || target.phase) + (target.message ? ' · ' + target.message : ''), 'pc-batch-result'))
287
296
  if (job.canRestore) {
288
297
  const restore = button('恢复更新前状态', () => reviewRestore(job))
289
298
  restore.disabled = !snapshot.writable || snapshot.busy || pending
@@ -408,36 +417,101 @@ window.DshPluginCenter = (() => {
408
417
  renderInline(target, button)
409
418
  }
410
419
  }
411
- async function mutate(action, name, version) {
420
+ async function updateAll() {
421
+ if (pending || snapshot?.busy || !snapshot?.writable || !snapshot.capabilities?.updateAll) return
422
+ const current = generation, sequence = ++detailSequence, area = dialog.querySelector('.pc-detail')
423
+ const valid = () => current === generation && sequence === detailSequence && connection.valid()
424
+ const skipped = [], targets = []
425
+ pending = true; updateAllControl(); renderInstalled(); renderedInstalled = ''
426
+ const status = node('p', '正在读取最新插件列表…')
427
+ const cancel = button('取消检查', () => {
428
+ detailSequence++; pending = false; updateAllControl(); area.replaceChildren(); renderInstalled(); renderedInstalled = ''
429
+ })
430
+ area.replaceChildren(status, cancel)
431
+ try {
432
+ await refresh()
433
+ if (!valid()) return
434
+ if (snapshot.busy || !snapshot.writable) throw new Error('主机已有任务或当前环境只读,请稍后重试')
435
+ const revision = snapshot.revision, candidates = []
436
+ for (const item of snapshot.items) {
437
+ let reason = !(item.managed && item.bundle || item.selfUpdate) ? '由主机维护或不是插件'
438
+ : /[:/\\]/.test(item.requested || '') || !item.requested || item.requested.startsWith('.') ? '本地、链接或自定义来源,请单独维护'
439
+ : compareVersions(item.version, item.version) === null ? '已装版本无法比较,请单独维护' : ''
440
+ if (reason) skipped.push(item.name + ':' + reason)
441
+ else candidates.push(item)
442
+ }
443
+ if (candidates.length > 100) throw new Error('插件超过单次批量更新的 100 项上限,请分开维护')
444
+ let checked = 0
445
+ // Each detail request has its own timeout; a large profile does not need one giant HTTP request.
446
+ for (let i = 0; i < candidates.length && valid(); i += 4) await Promise.all(candidates.slice(i, i + 4).map(async item => {
447
+ try {
448
+ const { item: latest } = await api('/details?name=' + encodeURIComponent(item.name))
449
+ if (!valid()) return
450
+ const order = compareVersions(latest?.version, item.version)
451
+ if (latest?.bundle && order !== null && order > 0) targets.push({ name: item.name, version: latest.version })
452
+ else skipped.push(item.name + ':' + (order !== null && order <= 0 ? '当前版本已是最新或高于 latest' : '目标不是可比较的 DSH 插件版本'))
453
+ } catch (error) { if (valid()) skipped.push(item.name + ':检查失败,' + error.message) }
454
+ finally { if (valid()) status.textContent = '正在检查更新:' + (++checked) + '/' + candidates.length }
455
+ }))
456
+ if (!valid()) return
457
+ await refresh()
458
+ if (!valid()) return
459
+ if (snapshot.revision !== revision || snapshot.busy) throw new Error('检查期间插件列表或任务状态已变化,请重新检查')
460
+ targets.sort((a, b) => (a.name === 'dsh-remote-plugin') - (b.name === 'dsh-remote-plugin') || a.name.localeCompare(b.name))
461
+ pending = false; updateAllControl()
462
+ if (!targets.length) {
463
+ area.replaceChildren(node('p', '没有可自动更新的插件。'))
464
+ for (const text of skipped.sort()) area.append(node('p', text))
465
+ return
466
+ }
467
+ await mutate('update-all', 'all-plugins', undefined, { targets, skipped: skipped.sort() })
468
+ } catch (error) {
469
+ if (valid()) area.replaceChildren(node('p', error.message, 'pc-detail-error'), button('重新检查全部更新', updateAll))
470
+ } finally {
471
+ if (valid()) { pending = false; updateAllControl(); renderInstalled(); renderedInstalled = '' }
472
+ }
473
+ }
474
+ async function mutate(action, name, version, batch) {
412
475
  if (pending) return
413
476
  const current = generation
414
477
  const reviewSequence = ++detailSequence
415
478
  // LAN HTTP is not a secure context; an idempotency key does not need WebCrypto.
416
479
  const id = globalThis.crypto?.randomUUID?.() || `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`
417
480
  const body = { id, action, name, ...(version ? { version } : {}), revision: snapshot.revision }
481
+ if (batch) body.targets = batch.targets
418
482
  if (name === 'dsh-remote-plugin' && action === 'update') body.confirmSelfUpdate = true
483
+ if (batch?.targets.some(target => target.name === 'dsh-remote-plugin')) body.confirmSelfUpdate = true
419
484
  const area = dialog.querySelector('.pc-detail')
420
485
  let plan
421
- if (['install', 'update', 'remove'].includes(action)) {
486
+ if (['install', 'update', 'remove', 'update-all'].includes(action)) {
422
487
  pending = true
488
+ updateAllControl()
423
489
  area.replaceChildren(node('p', '正在预检目标版本、锁文件与发布年龄策略…'))
424
490
  try {
425
491
  const response = await api('/preflight', body)
426
492
  if (current !== generation || reviewSequence !== detailSequence) return
427
493
  plan = response.plan
428
494
  if (!plan?.key) throw new Error('主机未返回可确认的预检计划,请升级主机 Remote 插件')
495
+ if (batch && (!Array.isArray(plan.targets) || !plan.targets.length)) throw new Error('主机未返回完整批量更新列表,请重新检查')
429
496
  body.preflightKey = plan.key
430
497
  } catch (error) {
431
498
  if (current !== generation || reviewSequence !== detailSequence) return
432
- area.replaceChildren(node('p', error.message, 'pc-detail-error'), button('重新预检', () => mutate(action, name, version)))
499
+ area.replaceChildren(node('p', error.message, 'pc-detail-error'), button('重新预检', () => mutate(action, name, version, batch)))
433
500
  return
434
- } finally { if (current === generation) pending = false }
501
+ } finally { if (current === generation) { pending = false; updateAllControl(); if (tab !== 'market') { renderInstalled(); renderedInstalled = '' } } }
435
502
  }
436
503
  if (current !== generation || reviewSequence !== detailSequence || !connection.valid()) return
437
- const review = card('确认' + labels[action], name + (version ? '@' + version : ''))
504
+ const review = card('确认' + labels[action], batch ? '共 ' + plan.targets.length + ' 个插件' : name + (version ? '@' + version : ''))
505
+ if (batch) {
506
+ for (const target of plan.targets) review.append(node('p', target.name + ' · ' + target.fromVersion + ' → ' + target.version))
507
+ review.append(node('p', '逐个更新,遇到失败停止后续项;操作记录显示每项结果。关闭页面后主机继续执行。恢复备份会撤销整批更新。'))
508
+ const skipped = node('details'); skipped.append(node('summary', '未更新的项目(' + batch.skipped.length + ')'))
509
+ for (const text of batch.skipped) skipped.append(node('p', text))
510
+ review.append(skipped)
511
+ }
438
512
  review.append(node('p', '目标环境:' + snapshot.profile + '。配置修改后需要重启 DSH;不会自动重启。'))
439
513
  if (body.confirmSelfUpdate) review.append(node('p', '更新当前主机的 Remote 插件本体,先备份配置与旧包,后台执行。重启 DSH 后新版本生效,连接可能短暂中断;此操作不会升级手机 App。'))
440
- const confirm = button('确认' + labels[action], () => executeMutation(body)); confirm.className = action === 'remove' ? 'pc-danger-confirm' : 'pc-primary'
514
+ const confirm = button('确认' + labels[action], () => { if (reviewSequence === detailSequence) return executeMutation(body) }); confirm.className = action === 'remove' ? 'pc-danger-confirm' : 'pc-primary'
441
515
  if (plan) {
442
516
  review.append(node('p', '执行前备份全部插件文件和配置;安装后核验配置、锁文件与已安装版本。失败可在操作记录恢复更新前状态。'))
443
517
  if (plan.baselineWarning) review.append(node('p', '更新前已存在待修复状态:' + plan.baselineWarning + '。恢复备份会回到这一状态;只有安装后一致性核验通过才会报告完成。', 'pc-detail-error'))
@@ -458,7 +532,7 @@ window.DshPluginCenter = (() => {
458
532
  review.append(label, node('p', '不批准也可取消,等待上述版本达到发布年龄后重新预检。'))
459
533
  }
460
534
  }
461
- review.append(confirm, button('取消', () => area.replaceChildren()))
535
+ review.append(confirm, button('取消', () => { detailSequence++; area.replaceChildren() }))
462
536
  area.replaceChildren(review); area.scrollIntoView({ block: 'nearest' })
463
537
  }
464
538
  function reviewRestore(job) {
@@ -473,6 +547,7 @@ window.DshPluginCenter = (() => {
473
547
  if (pending) return
474
548
  const current = generation
475
549
  pending = true
550
+ updateAllControl()
476
551
  if (tab !== 'market') { renderInstalled(); renderedInstalled = '' }
477
552
  for (const control of dialog.querySelector('.pc-detail').querySelectorAll('button')) control.disabled = true
478
553
  try {
@@ -485,7 +560,7 @@ window.DshPluginCenter = (() => {
485
560
  if (current !== generation) return
486
561
  if (error.status === 409 && body.preflightKey) {
487
562
  message(error.message)
488
- dialog.querySelector('.pc-detail').replaceChildren(button('重新预检', () => mutate(body.action, body.name, body.version)))
563
+ dialog.querySelector('.pc-detail').replaceChildren(button('重新预检', () => body.action === 'update-all' ? updateAll() : mutate(body.action, body.name, body.version)))
489
564
  return
490
565
  }
491
566
  message(error.message + ';请先查看操作记录,避免重复提交。')
@@ -511,7 +586,10 @@ window.DshPluginCenter = (() => {
511
586
  }
512
587
  timer = setTimeout(poll, 4000)
513
588
  }
514
- function pause() { generation++; refreshSequence++; clearTimeout(timer); if (dialog) dialog.open = false }
589
+ function pause() {
590
+ generation++; refreshSequence++; detailSequence++; clearTimeout(timer); pending = false
591
+ if (dialog) { dialog.open = false; dialog.querySelector('.pc-detail').replaceChildren() }
592
+ }
515
593
  async function resume() {
516
594
  if (!dialog || !connection.valid()) return
517
595
  dialog.open = true; const current = ++generation
@@ -532,6 +610,7 @@ window.DshPluginCenter = (() => {
532
610
  window.DshSkillsCenter?.close()
533
611
  tab = value; detailSequence++; expandedDetails.clear(); renderedInstalled = ''; dialog.querySelector('.pc-detail').replaceChildren()
534
612
  renderTabs(); message('')
613
+ updateAllControl()
535
614
  dialog.querySelector('.pc-market-tools').hidden = value !== 'market'; dialog.querySelector('.pc-filters').hidden = value === 'market'
536
615
  if (value === 'market') { offset = 0; return search() }
537
616
  return refresh()
@@ -539,7 +618,9 @@ window.DshPluginCenter = (() => {
539
618
  control.dataset.pcTab = value; toolbar.append(control)
540
619
  }
541
620
  const refreshButton = button('刷新', () => tab === 'market' ? (offset = 0, search(true)) : refresh()); refreshButton.className = 'pc-refresh'
542
- const toolbarRow = node('div', null, 'pc-toolbar'); toolbarRow.append(toolbar, refreshButton)
621
+ const updateAllButton = button('一键更新', updateAll); updateAllButton.className = 'pc-update-all'; updateAllButton.disabled = true
622
+ const toolbarActions = node('div', null, 'pc-toolbar-actions'); toolbarActions.append(updateAllButton, refreshButton)
623
+ const toolbarRow = node('div', null, 'pc-toolbar'); toolbarRow.append(toolbar, toolbarActions)
543
624
  const filters = node('div', null, 'pc-filters')
544
625
  const query = node('input'); query.placeholder = '筛选已安装插件'; query.setAttribute('aria-label', '筛选已安装插件')
545
626
  query.addEventListener('input', () => { filter = query.value.trim(); renderInstalled() })
@@ -1,17 +1,24 @@
1
1
  <!doctype html>
2
2
  <html lang="zh-CN">
3
3
  <head>
4
+ <meta name="dsh-remote-build" content="d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
4
5
  <meta charset="utf-8">
5
6
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6
7
  <title>DSH Remote</title>
7
- <script>(function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
8
- <link rel="stylesheet" href="theme-vars.css">
9
- <link rel="stylesheet" href="setup.css">
10
- <link rel="stylesheet" href="insights.css">
11
- <link rel="stylesheet" href="remote-ui.css">
12
- <link rel="stylesheet" href="doctor.css">
13
- <link rel="stylesheet" href="skins/blue-fish/skin.css">
14
- <style>html[data-theme="light"],html[data-theme="neutral"],html[data-theme="fish"]{color-scheme:light}</style>
8
+ <script>(function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'&&t!=='penguin'&&t!=='penguin-night'&&t!=='bocchi'&&t!=='nijika'&&t!=='ryo'&&t!=='kita'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
9
+ <link rel="stylesheet" href="theme-vars.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
10
+ <link rel="stylesheet" href="setup.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
11
+ <link rel="stylesheet" href="insights.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
12
+ <link rel="stylesheet" href="remote-ui.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
13
+ <link rel="stylesheet" href="doctor.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
14
+ <link rel="stylesheet" href="skins/blue-fish/skin.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
15
+ <link rel="stylesheet" href="skins/penguin/skin.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
16
+ <link rel="stylesheet" href="skins/bocchi/skin.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
17
+ <link rel="stylesheet" href="skins/kessoku/skin.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
18
+ <link rel="stylesheet" href="skins/nijika/skin.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
19
+ <link rel="stylesheet" href="skins/ryo/skin.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
20
+ <link rel="stylesheet" href="skins/kita/skin.css?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e">
21
+ <style>html[data-theme="light"],html[data-theme="neutral"],html[data-theme="fish"],html[data-theme="penguin"],html[data-theme="bocchi"],html[data-theme="nijika"],html[data-theme="ryo"],html[data-theme="kita"]{color-scheme:light}</style>
15
22
  </head>
16
23
  <body class="remote-panel-body">
17
24
  <main class="plugin-shell" data-motion-view>
@@ -45,17 +52,17 @@
45
52
  </section>
46
53
  <footer class="plugin-foot"><span id="plugin-version">—</span><a id="plugin-about" href="/remote/admin/#remote/settings" target="_blank" rel="noopener">关于与支持</a></footer>
47
54
  </main>
48
- <script src="i18n.js"></script>
49
- <script src="vendor/gsap/gsap.min.js"></script>
50
- <script src="motion.js"></script>
51
- <script type="module" src="morphicons-init.js"></script>
52
- <script src="qrcode.min.js"></script>
53
- <script src="remote-state.js"></script>
54
- <script src="remote-ui.js"></script>
55
- <script src="setup.js"></script>
56
- <script src="insights.js"></script>
57
- <script src="plugin.js"></script>
58
- <script src="doctor.js"></script>
59
- <script src="doctor-entry.js"></script>
55
+ <script src="i18n.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
56
+ <script src="vendor/gsap/gsap.min.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
57
+ <script src="motion.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
58
+ <script type="module" src="morphicons-init.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
59
+ <script src="qrcode.min.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
60
+ <script src="remote-state.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
61
+ <script src="remote-ui.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
62
+ <script src="setup.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
63
+ <script src="insights.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
64
+ <script src="plugin.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
65
+ <script src="doctor.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
66
+ <script src="doctor-entry.js?dsr-build=d269ebf822f3b66656a0f760a7c3063abdcc46fd700f90edb9e8e6fdb8efb83e"></script>
60
67
  </body>
61
68
  </html>
@@ -0,0 +1,74 @@
1
+ /* Host-local device administration. Pairing secrets live only in this page's memory. */
2
+ ;(function(root) {
3
+ 'use strict'
4
+ const text=(zh,en)=>root.I18N?.lang==='en'?en:zh
5
+ const make=(tag,value)=>{const e=document.createElement(tag);if(value)e.textContent=value;return e}
6
+ root.DshRelayDevices={mount(target,{connection,path,credentials}){
7
+ const title=make('h3',text('中转设备与配对','Relay devices and pairing'))
8
+ const hint=make('p',text('设备管理请在主机本地地址打开。每台设备独立配对,最长有效 30 天;到期后重新创建并导入。浏览器暂不支持此加密入口。','Open a local host address to manage devices. Each device has a separate pairing valid for up to 30 days. Create and import a new pairing after expiry. This encrypted entry does not support browsers yet.'))
9
+ const panel=make('div'),enable=make('button',text('启用主机加密入口','Enable encrypted host entry')),refresh=make('button',text('刷新设备','Refresh devices'))
10
+ const form=make('form'),label=make('input'),days=make('select'),create=make('button',text('创建设备配对','Create device pairing'))
11
+ form.className='relay-device-form'
12
+ label.placeholder=text('设备名称,例如:我的手机','Device name, e.g. My phone');label.maxLength=80;label.required=true;label.setAttribute('aria-label',label.placeholder)
13
+ days.setAttribute('aria-label',text('配对有效期','Pairing validity'))
14
+ for(const n of [7,14,30]){const option=make('option',text(n+' 天',n+' days'));option.value=String(n);days.append(option)}
15
+ days.value='30';create.type='submit';form.append(label,days,create)
16
+ const list=make('div'),rotate=make('button',text('更换主机证书并清除全部配对','Rotate host certificate and clear all pairings'))
17
+ const notice=make('p'),download=make('button',text('保存配对文件(仅本次可用)','Save pairing file (available this time only)'))
18
+ notice.setAttribute('role','status');download.hidden=true
19
+ for(const b of [enable,refresh,rotate,download])b.type='button'
20
+ panel.append(enable,form,refresh,list,rotate,download);target.append(title,hint,panel,notice)
21
+ let host=null,data=null,identity='',busy=false,abort=null,pairing=null,disposed=false
22
+ function ctx(){
23
+ const c=connection(),endpoint=new URL(c.url(path.replace(/\/e2ee$/,'')),root.location?.href||'http://localhost/')
24
+ // Workflow adapters may return a fixed relay endpoint regardless of route.
25
+ endpoint.pathname=endpoint.pathname.replace(/\/$/,'')+'/e2ee'
26
+ return {...c,endpoint:endpoint.href}
27
+ }
28
+ function valid(c){return !disposed&&c.valid()&&identity===JSON.stringify([c.endpoint,c.headers?.authorization||''])}
29
+ function render(){
30
+ panel.hidden=host?.canManageDevices!==true
31
+ enable.hidden=host?.e2ee?.enabled===true;form.hidden=!host?.e2ee?.enabled;rotate.hidden=!host?.configured
32
+ for(const b of [enable,refresh,rotate,create,label,days])b.disabled=busy
33
+ download.hidden=!pairing;list.replaceChildren()
34
+ for(const d of data?.devices||[]){
35
+ const row=make('div');row.className='relay-device-row'
36
+ const name=make('span',d.label+' · '+(d.active?text('有效至 ','Valid until ')+new Date(d.expiresAt).toLocaleString():d.revokedAt?text('已撤销','Revoked'):text('已到期','Expired')))
37
+ const revoke=make('button',text('撤销','Revoke'));revoke.type='button';revoke.disabled=busy||!d.active
38
+ revoke.addEventListener('click',()=>{if(root.confirm(text('撤销此设备?连接会立即断开,需要新配对才能再次访问。\n','Revoke this device? Its connections will close and a new pairing will be required.\n')+d.label))void run({action:'revoke-device',id:d.id})})
39
+ row.append(name,revoke);list.append(row)
40
+ }
41
+ if(data&&!data.devices?.length)list.append(make('p',text('尚无设备,请创建配对后在 Android App 导入。','No devices. Create a pairing and import it in the Android app.')))
42
+ }
43
+ async function run(value){
44
+ const c=ctx();if(busy||host?.canManageDevices!==true)return
45
+ busy=true;abort?.abort();abort=new AbortController();const own=abort,timer=setTimeout(()=>own.abort(),20000)
46
+ pairing=null;notice.textContent='';render()
47
+ try{
48
+ const response=await root.fetch(c.endpoint,{method:value?'POST':'GET',headers:{...c.headers,...(value?{'content-type':'application/json'}:{})},credentials,cache:'no-store',signal:own.signal,...(value?{body:JSON.stringify(value)}:{})})
49
+ const result=await response.json();if(!valid(c))return
50
+ if(!response.ok)throw Error(result.error||'E2EE_OPERATION_FAILED')
51
+ data=result;host={...host,...result};pairing=result.pairing||null
52
+ if(pairing)notice.textContent=text('配对已创建。请立即保存文件并安全传到对应设备;文件包含访问凭据,不能公开。创建或撤销会短暂断开其他中转连接。','Pairing created. Save it now and transfer it securely to the intended device. It contains access credentials. Creating or revoking a device briefly disconnects other relay clients.')
53
+ else if(value)notice.textContent=text('已保存。中转连接会重新建立;已受理任务继续运行。','Saved. Relay connections will reconnect; accepted tasks continue.')
54
+ }catch(error){if(valid(c))notice.textContent=error.message==='E2EE_DISABLED_BY_POLICY'?text('主机环境已明确关闭加密,请先在主机取消 DSH_REMOTE_RELAY_E2EE=0 并重启网关。','The host environment disables encryption. Remove DSH_REMOTE_RELAY_E2EE=0 and restart the gateway first.'):text('未能确认结果,请刷新设备列表后再决定是否重试。错误:','Result unconfirmed. Refresh the device list before deciding whether to retry. Error: ')+error.message}
55
+ finally{clearTimeout(timer);if(valid(c)){busy=false;render()}}
56
+ }
57
+ form.addEventListener('submit',e=>{e.preventDefault();if(!label.value.trim())return;void run({action:'create-device',label:label.value.trim(),days:Number(days.value)})})
58
+ refresh.addEventListener('click',()=>void run())
59
+ enable.addEventListener('click',()=>{if(root.confirm(text('启用后旧公网入口将停止使用,需要先为 Android 创建并导入配对。当前中转连接会断开,请保留本地管理页面。','Enabling disables the legacy public entry. Create and import an Android pairing. Relay clients will disconnect; keep this local management page open.')))void run({action:'enable-encryption'})})
60
+ rotate.addEventListener('click',()=>{if(root.confirm(text('确认更换主机证书?全部现有配对立即失效,所有设备需要重新配对。此操作无法撤销。','Rotate the host certificate? All existing pairings become invalid and every device must pair again. This cannot be undone.')))void run({action:'rotate-identity',confirm:'REPAIR_ALL_DEVICES'})})
61
+ download.addEventListener('click',()=>{
62
+ if(!pairing)return
63
+ const url=URL.createObjectURL(new Blob([JSON.stringify(pairing,null,2)+'\n'],{type:'application/json'})),a=make('a')
64
+ a.href=url;a.download='dsh-remote-device-'+pairing.deviceId+'.json';a.click();setTimeout(()=>URL.revokeObjectURL(url),1000)
65
+ })
66
+ return {update(value){
67
+ const c=ctx(),next=JSON.stringify([c.endpoint,c.headers?.authorization||''])
68
+ if(next!==identity){abort?.abort();identity=next;host=null;data=null;pairing=null;busy=false;label.value='';notice.textContent=''}
69
+ const first=value?.canManageDevices===true&&host?.canManageDevices!==true
70
+ // Keep fresh device-operation state until the next host status read.
71
+ host=value;render();if(first)void run()
72
+ },destroy(){disposed=true;abort?.abort();pairing=null;data=null;label.value='';list.replaceChildren()}}
73
+ }}
74
+ })(typeof window!=='undefined'?window:globalThis)
@@ -1,2 +1,9 @@
1
1
  .relay-settings{margin:18px 0;padding:20px;border:1px solid var(--dsr-line,var(--border,#ffffff20));border-radius:16px;background:var(--dsr-panel,var(--bg-card,transparent));color:inherit;min-width:0}
2
+ .relay-encryption-switch{display:flex;align-items:center;gap:10px;min-height:44px;font-size:14px}.relay-encryption-switch input{width:20px;height:20px;accent-color:var(--dsr-accent,var(--accent,#527dab))}.relay-encryption-status{font-size:13px;line-height:1.65;overflow-wrap:anywhere}.relay-encryption-status[data-security=legacy]{padding:12px;border:1px solid var(--warning,#d98758);border-radius:9px;color:var(--warning,#d98758)}
3
+ .relay-sponsor{margin:14px 0;padding:14px;border:1px solid var(--dsr-accent-line,var(--border,#ffffff25));border-radius:10px;background:var(--dsr-accent-soft,#527dab18);font-size:13px;line-height:1.7}.relay-sponsor .sponsor-entry{margin:0}.sponsor-entry a{color:var(--dsr-accent-strong,var(--accent,#6ea9e8));font-weight:600}.sponsor-entry span{display:block;font-size:12px;opacity:.75;margin-top:5px}
2
4
  .relay-settings [hidden]{display:none!important}.relay-heading,.relay-address,.relay-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.relay-heading{justify-content:space-between}.relay-heading h3{font-size:16px;line-height:1.4;margin:0}.relay-badge{font-size:12px;padding:5px 9px;border-radius:20px;background:#77889920}.relay-badge[data-phase=online]{background:#36b48522;color:var(--success,#35b58a)}.relay-badge[data-phase=quota-exceeded],.relay-badge[data-phase=error]{background:#da704522;color:var(--warning,#d98758)}.relay-muted{font-size:12px;line-height:1.65;opacity:.7;margin:10px 0}.relay-status,.relay-notice,.relay-quota p{font-size:13px;line-height:1.6}.relay-address{padding:12px 0}.relay-address a{color:var(--dsr-accent,var(--accent,#6ea9e8));overflow-wrap:anywhere;flex:1;min-width:120px}.relay-form{display:grid;gap:12px;padding:12px 0}.relay-form label{display:grid;gap:7px;font-size:13px}.relay-form input{width:100%;box-sizing:border-box;min-height:44px;border:1px solid var(--dsr-line,var(--border,#ffffff25));background:transparent;color:inherit;border-radius:9px;padding:10px 12px;font:inherit}.relay-settings button{min-height:44px;border:1px solid var(--dsr-line,var(--border,#ffffff25));border-radius:9px;padding:9px 14px;font:inherit;font-size:13px;cursor:pointer;background:transparent;color:inherit}.relay-settings .relay-primary{background:var(--dsr-accent,var(--accent,#527dab));color:var(--dsr-bg,#fff);justify-self:start;border-color:transparent}.relay-settings button:disabled{opacity:.5;cursor:default}.relay-settings :focus-visible{outline:2px solid var(--dsr-accent,var(--accent,#6ea9e8));outline-offset:3px}.relay-quota progress{display:block;width:100%;height:7px;accent-color:var(--dsr-accent,var(--accent,#6ea9e8))}.relay-notice:empty{display:none}.relay-notice{padding:10px 12px;border-radius:9px;background:#71839c16}.relay-actions{margin-top:6px}@media(max-width:480px){.relay-settings{padding:16px}.relay-heading{align-items:flex-start}.relay-address{align-items:flex-start}.relay-form .relay-primary{width:100%;justify-self:stretch}}
5
+ .relay-device-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:8px 0;overflow-wrap:anywhere}
6
+ .relay-device-row>span{min-width:0}
7
+ .relay-device-form{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
8
+ .relay-device-form input{min-width:0;flex:1 1 180px}
9
+ .relay-device-form input,.relay-device-form select{min-height:44px;background:var(--dsr-panel,var(--bg-card,transparent));color:inherit;border:1px solid var(--dsr-line,var(--border,#77889950));border-radius:9px;padding:8px;box-sizing:border-box}
@@ -20,16 +20,19 @@
20
20
  const heading=el('div','relay-heading'),title=el('h3'),badge=el('span','relay-badge')
21
21
  heading.append(title,badge)
22
22
  const intro=el('p','relay-muted'),status=el('p','relay-status');status.setAttribute('aria-live','polite')
23
+ const sponsor=el('div','relay-sponsor');root.DshSponsor?.mount(sponsor)
23
24
  const address=el('div','relay-address'),link=el('a'),copy=el('button');copy.type='button';link.target='_blank';link.rel='noopener noreferrer';address.append(link,copy)
24
25
  const quota=el('div','relay-quota'),meter=el('progress'),usage=el('p'),reset=el('p','relay-muted');meter.max=100;quota.append(usage,meter,reset)
25
- const binding=el('p','relay-muted'),form=el('form','relay-form'),keyLabel=el('label'),keyInput=el('input')
26
+ const plan=el('p','relay-muted'),binding=el('p','relay-muted'),form=el('form','relay-form'),keyLabel=el('label'),keyInput=el('input')
26
27
  keyInput.type='password';keyInput.autocomplete='off';keyInput.spellcheck=false;keyInput.maxLength=128;keyInput.name='relay-key'
27
28
  keyLabel.append(el('span'),keyInput)
28
29
  const adminLabel=el('label'),adminInput=el('input');adminInput.type='password';adminInput.autocomplete='off';adminInput.name='relay-admin';adminLabel.append(el('span'),adminInput)
29
30
  const submit=el('button','relay-primary');submit.type='submit';form.append(keyLabel,adminLabel,submit)
30
31
  const actions=el('div','relay-actions'),toggle=el('button'),refresh=el('button'),takeover=el('button');toggle.type=refresh.type=takeover.type='button';actions.append(takeover,toggle,refresh)
31
32
  const hint=el('p','relay-muted'),notice=el('p','relay-notice');notice.setAttribute('role','status')
32
- target.append(heading,intro,status,address,quota,binding,form,actions,hint,notice)
33
+ target.append(heading,intro,sponsor,status,address,plan,quota,binding,form,actions,hint,notice)
34
+ const deviceTarget=el('div');target.append(deviceTarget)
35
+ const devices=root.DshRelayDevices?.mount(deviceTarget,{connection,path:path+'/e2ee',credentials})
33
36
  let identity='',value=null,lastRead=0,busy=false,loading=false,controller=null,destroyed=false,readError=false,failures=0
34
37
  function context() { const ctx=connection();return { ...ctx, endpoint:ctx.url(path) } }
35
38
  function current(ctx) { return !destroyed && ctx.valid() && identity===JSON.stringify([ctx.endpoint,ctx.headers?.authorization||'']) }
@@ -39,23 +42,28 @@
39
42
  return ctx
40
43
  }
41
44
  function render() {
45
+ devices?.update(value)
46
+ root.DshSponsor?.mount(sponsor)
42
47
  title.textContent=text('云服务器中转','Cloud relay')
43
48
  intro.textContent=text('让手机通过公网连接这台主机。每位用户使用自己的中转密钥,首次开通会绑定此主机。','Connect to this host over the internet. Your personal relay key binds to this host when activated.')
44
49
  const phase=value?.phase||(readError?'unavailable':loading?'loading':'unconfigured')
45
50
  const names={loading:['正在读取','Loading'],unavailable:['状态读取失败','Status unavailable'],unconfigured:['尚未开通','Not configured'],disabled:['已停用','Disabled'],connecting:['正在连接','Connecting'],online:['已连接','Connected'],reconnecting:['正在重连','Reconnecting'],expired:['授权已到期','Expired'],'authorization-inactive':['授权已撤销或到期','Authorization inactive'],'quota-exceeded':['今日流量已用完','Daily quota reached'],'quota-unavailable':['流量服务暂不可用','Quota service unavailable'],error:['连接异常','Connection error']}
46
- badge.textContent=text(...(names[phase]||names.error));badge.dataset.phase=phase
51
+ badge.textContent=phase==='quota-exceeded'&&value?.daily?.period==='month'?text('本月流量已用完','Monthly quota reached'):text(...(names[phase]||names.error));badge.dataset.phase=phase
47
52
  status.textContent=busy?text('正在保存并绑定,请稍候…','Saving and binding…'):value?.error?text('请检查主机配置或刷新状态。','Check the host configuration or refresh.'):text('开通后会随 Remote 网关启动,无需单独运行工具。','Starts with the Remote gateway after activation.')
48
53
  let safeUrl=''
49
54
  try { const url=new URL(value?.publicUrl);if(url.protocol==='https:'&&!url.username&&!url.password)safeUrl=url.origin } catch {}
50
55
  address.hidden=!safeUrl;link.textContent=safeUrl;link.href=safeUrl||'#';copy.textContent=text('复制地址','Copy URL')
51
56
  const daily=value?.daily
57
+ plan.hidden=value?.quotaPeriod!=='month'&&daily?.period!=='month'
58
+ plan.textContent=plan.hidden?'':text('基础中转 · 一个服务月 5GB · 单网关绑定 · 支持对话图片,不含文件传输。','Basic relay · 5GB per service month · One gateway · Chat images supported; file transfer excluded.')
52
59
  quota.hidden=!daily
53
- if(daily?.unavailable){usage.textContent=text('无法确认今日额度,云端暂停传输。','Quota unavailable; cloud transfer is paused.');meter.hidden=true;reset.textContent=''}
60
+ if(daily?.unavailable){usage.textContent=text('无法确认流量额度,云端暂停传输。','Quota unavailable; cloud transfer is paused.');meter.hidden=true;reset.textContent=''}
54
61
  else if(daily){
55
62
  meter.hidden=false;meter.value=Math.min(100,Math.max(0,Number(daily.usedBytes)/Number(daily.limitBytes)*100))
56
63
  const gb=bytes=>(Math.max(0,Number(bytes)||0)/1e9).toFixed(2)
57
- usage.textContent=text(`今日已用 ${gb(daily.usedBytes)} / ${gb(daily.limitBytes)} GB · 剩余 ${gb(daily.remainingBytes)} GB`,`Today ${gb(daily.usedBytes)} / ${gb(daily.limitBytes)} GB · ${gb(daily.remainingBytes)} GB left`)
58
- reset.textContent=text('上传与下载合计;北京时间每天 00:00 重置。','Uploads + downloads; resets daily at 00:00 Beijing time.')
64
+ const monthly=daily.period==='month'
65
+ usage.textContent=text(`${monthly?'本月':'今日'}已用 ${gb(daily.usedBytes)} / ${gb(daily.limitBytes)} GB · 剩余 ${gb(daily.remainingBytes)} GB`,`${monthly?'This month':'Today'} ${gb(daily.usedBytes)} / ${gb(daily.limitBytes)} GB · ${gb(daily.remainingBytes)} GB left`)
66
+ reset.textContent=monthly?text('上传与下载及对话图片合计;额度覆盖本次开通的服务月,不包含文件传输。','Uploads, downloads and chat images share this service month quota; file transfer is excluded.'):text('上传与下载合计;北京时间每天 00:00 重置。','Uploads + downloads; resets daily at 00:00 Beijing time.')
59
67
  }
60
68
  const expires=value?.expiresAt?new Date(value.expiresAt).toLocaleString():''
61
69
  binding.textContent=value?.fingerprint?text(`已绑定此主机 · ${value.fingerprint.slice(0,12)}${expires?' · 有效期至 '+expires:''}`,`Bound to this host · ${value.fingerprint.slice(0,12)}${expires?' · Until '+expires:''}`):''
@@ -69,7 +77,7 @@
69
77
  toggle.hidden=!value?.configured;toggle.disabled=busy;toggle.textContent=text(value?.enabled?'停用中转':'开启中转',value?.enabled?'Disable relay':'Enable relay')
70
78
  refresh.textContent=text('刷新状态','Refresh');refresh.disabled=busy||loading
71
79
  takeover.hidden=!value?.legacyAvailable;takeover.disabled=busy;takeover.textContent=text('接管已有试用连接','Take over existing trial')
72
- hint.textContent=value?.quotaPending?text('等待云端确认今日额度…','Waiting for cloud quota…'):text('手机使用此公网地址和原 Remote 访问令牌。停用会断开通过此入口的连接;授权到期或用满后,请通过本地地址管理。','Use this URL and your existing Remote access token. Disabling disconnects this route; use a local address after expiry or quota exhaustion.')
80
+ hint.textContent=value?.quotaPending?text('等待云端确认流量额度…','Waiting for cloud quota…'):value?.e2ee?.configured?text('请先在 App 导入主机本地的配对文件。端到端加密默认开启;关闭前须确认风险,普通浏览器暂不支持此配对入口。','Import the host’s local pairing file in the app. End-to-end encryption is on by default; disabling requires confirmation. Ordinary browsers do not support this paired entry.'):text('手机使用此公网地址和原 Remote 访问令牌。停用会断开通过此入口的连接;授权到期或用满后,请通过本地地址管理。','Use this URL and your existing Remote access token. Disabling disconnects this route; use a local address after expiry or quota exhaustion.')
73
81
  }
74
82
  async function load(force=false) {
75
83
  const ctx=syncIdentity()
@@ -84,7 +92,7 @@
84
92
  let data
85
93
  try{data=await response.json()}catch{throw Object.assign(Error('INVALID_RESPONSE'),{code:'INVALID_RESPONSE',status:response.status})}
86
94
  if(!current(ctx))return
87
- if(response.status===429&&data.daily){value={phase:'quota-exceeded',daily:data.daily,configured:false};notice.textContent=text('今日额度已用完。请用主机本地地址进入设置,或等待零点恢复。','Daily quota reached. Use the local host address or wait until reset.');return}
95
+ if(response.status===429&&data.daily){value={phase:'quota-exceeded',daily:data.daily,configured:false};notice.textContent=data.daily.period==='month'?text('本月额度已用完。请用主机本地地址管理;续期需在当前资格到期后重新申请。','Monthly quota reached. Manage through the local host; apply again after expiry.'):text('今日额度已用完。请用主机本地地址进入设置,或等待零点恢复。','Daily quota reached. Use the local host address or wait until reset.');return}
88
96
  if(!response.ok)throw Object.assign(Error(data.error||'HTTP_'+response.status),{code:data.error,status:response.status})
89
97
  if(data.supported!==true)throw Object.assign(Error('UNSUPPORTED_GATEWAY'),{code:'UNSUPPORTED_GATEWAY'})
90
98
  value=data;notice.textContent='';readError=false;failures=0
@@ -122,7 +130,7 @@
122
130
  })
123
131
  function tick(){if(destroyed)return;syncIdentity();render();void load()}
124
132
  const timer=setInterval(tick,1000);tick()
125
- return { refresh:()=>load(true),destroy:()=>{destroyed=true;clearInterval(timer);controller?.abort();keyInput.value='';adminInput.value=''} }
133
+ return { refresh:()=>load(true),destroy:()=>{destroyed=true;clearInterval(timer);controller?.abort();devices?.destroy();keyInput.value='';adminInput.value=''} }
126
134
  }
127
135
  root.DshRelaySettings={mount}
128
136
  })(typeof window!=='undefined'?window:globalThis)
@@ -54,7 +54,7 @@
54
54
  .deck-argument-preview { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--dsr-muted); font-size:11px; line-height:1.5; }
55
55
  .deck-review-footer { display:flex; flex-wrap:wrap; align-items:flex-start; gap:6px; margin-top:7px; }
56
56
  .deck-review-footer > .deck-more { margin-left:auto; }
57
- .deck-decision { min-height:36px; padding:5px 11px; border:1px solid var(--dsr-line); border-radius:9px; background:var(--dsr-panel); color:var(--dsr-text); font:inherit; font-size:12px; cursor:pointer; }
57
+ .deck-decision { min-height:44px; padding:8px 12px; border:1px solid var(--dsr-line); border-radius:9px; background:var(--dsr-panel); color:var(--dsr-text); font:inherit; font-size:12px; cursor:pointer; }
58
58
  .deck-decision.primary { color:var(--dsr-accent-strong); background:var(--dsr-accent-soft); border-color:var(--dsr-accent-line); }
59
59
  .deck-decision:focus-visible,.deck-more > summary:focus-visible { outline:2px solid var(--dsr-accent); outline-offset:2px; }
60
60
  .session-deck .question-summary,.session-deck .ds-question-summary { -webkit-line-clamp:2; }
@@ -70,4 +70,10 @@
70
70
  .ds-view .session-deck [data-deck-kind="todos"] > .deck-more { grid-column:2; grid-row:1 / 3; align-self:center; }
71
71
  }
72
72
  .session-deck-sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
73
+ .approval-ai { grid-column:1; min-width:0; margin:8px 0; padding:8px 0; border-top:1px solid var(--dsr-line); }
74
+ .approval-ai .deck-summary-button { min-height:44px; padding:8px 12px; border:1px solid var(--dsr-line); border-radius:8px; color:var(--dsr-muted); background:var(--dsr-panel); font:inherit; font-size:12px; cursor:pointer; }
75
+ .approval-ai .deck-summary-button:disabled { opacity:.65; cursor:default; }
76
+ .approval-ai .deck-summary-button:focus-visible { outline:2px solid var(--dsr-accent); outline-offset:2px; }
77
+ .approval-ai-copy { margin:6px 0 0; color:var(--dsr-muted); font-size:12px; line-height:1.65; overflow-wrap:anywhere; }
78
+ .session-deck[data-mounted] [data-session-approval][data-deck-active]:has(.approval-ai) { max-height:min(42dvh,320px); }
73
79
  @media(max-width:360px) { .session-deck-tab { padding:5px 7px; font-size:11px; } .session-deck-control { width:26px; } }
@@ -47,7 +47,7 @@
47
47
  if (args && typeof args === 'object') {
48
48
  for (const key of ['command', 'cmd', 'script', 'path', 'file_path', 'url']) if (typeof args[key] === 'string' && args[key]) { preview = (['command', 'cmd', 'script'].includes(key) ? text('命令', 'Command') : key === 'url' ? text('地址', 'URL') : text('路径', 'Path')) + ': ' + args[key]; break }
49
49
  } else if (typeof args === 'string') preview = args
50
- return `<div class="deck-review-head"><strong>${esc(item.toolName || text('工具调用', 'Tool call'))}</strong>${badge ? `<span class="deck-review-badge">${esc(badge)}</span>` : ''}</div><p class="deck-review-reason">${esc(reason || text('主机未提供申请原因', 'The host provided no reason'))}</p>${preview ? `<div class="deck-argument-preview" title="${esc(preview)}">${esc(preview)}</div>` : ''}<div class="deck-review-footer"><button type="button" class="deck-decision primary" data-session-approve="1">${text('允许一次', 'Allow once')}</button><button type="button" class="deck-decision" data-session-approve="0">${text('拒绝', 'Reject')}</button><details class="deck-more" data-deck-details="approval"><summary>${text('完整请求', 'Full request')}</summary><pre class="deck-full-content">${esc(text('工具:', 'Tool: ') + (item.toolName || '') + '\n' + fullDetail)}</pre></details></div>`
50
+ return `<div class="deck-review-head"><strong>${esc(item.toolName || text('工具调用', 'Tool call'))}</strong>${badge ? `<span class="deck-review-badge">${esc(badge)}</span>` : ''}</div><p class="deck-review-reason">${esc(reason || text('主机未提供申请原因', 'The host provided no reason'))}</p>${preview ? `<div class="deck-argument-preview" title="${esc(preview)}">${esc(preview)}</div>` : ''}${root.DshApprovalSummary?.html(item) || ''}<div class="deck-review-footer"><button type="button" class="deck-decision primary" data-session-approve="1">${text('允许一次', 'Allow once')}</button><button type="button" class="deck-decision" data-session-approve="0">${text('拒绝', 'Reject')}</button><details class="deck-more" data-deck-details="approval"><summary>${text('完整请求', 'Full request')}</summary><pre class="deck-full-content">${esc(text('工具:', 'Tool: ') + (item.toolName || '') + '\n' + fullDetail)}</pre></details></div>`
51
51
  }
52
52
  let instance
53
53
  function mount(config) {