dsh-team-bots 0.2.289 → 0.2.347

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 (119) hide show
  1. package/README.md +60 -122
  2. package/docs/README.zh.md +61 -123
  3. package/docs/assets/channel-redesign.png +0 -0
  4. package/docs/assets/global-config-dark.png +0 -0
  5. package/docs/assets/global-config-light.png +0 -0
  6. package/docs/assets/global-config-light.zh.png +0 -0
  7. package/docs/assets/global-config-redesign.png +0 -0
  8. package/docs/assets/secrets-redesign.png +0 -0
  9. package/docs/assets/tasks.png +0 -0
  10. package/docs/assets/tasks.zh.png +0 -0
  11. package/docs/assets/usage-redesign-global.png +0 -0
  12. package/docs/assets/usage.png +0 -0
  13. package/docs/assets/usage.zh.png +0 -0
  14. package/package.json +17 -5
  15. package/scripts/doctor.mjs +4 -4
  16. package/src/api.js +6 -3
  17. package/src/botmsg.js +1 -1
  18. package/src/config.js +18 -8
  19. package/src/db-migrations.js +76 -9
  20. package/src/db.js +28 -2
  21. package/src/http.js +22 -3
  22. package/src/paths.js +32 -1
  23. package/src/pricing.js +2 -2
  24. package/src/runtime.js +1 -1
  25. package/src/secrets.js +4 -4
  26. package/src/service.js +14 -5
  27. package/src/services/approvals.js +109 -24
  28. package/src/services/backoff.js +34 -0
  29. package/src/services/bot-quota.js +242 -0
  30. package/src/services/bots.js +35 -6
  31. package/src/services/chat.js +15 -9
  32. package/src/services/core.js +33 -5
  33. package/src/services/hygiene.js +8 -4
  34. package/src/services/locale.js +17 -0
  35. package/src/services/memory.js +112 -1
  36. package/src/services/message-images.js +3 -3
  37. package/src/services/notify.js +169 -0
  38. package/src/services/projects.js +119 -10
  39. package/src/services/proposals.js +2 -3
  40. package/src/services/questions.js +75 -32
  41. package/src/services/review-watchdog.js +261 -30
  42. package/src/services/run-finish.js +186 -17
  43. package/src/services/runs.js +42 -13
  44. package/src/services/runtime/lifecycle.js +3 -1
  45. package/src/services/runtime/model-restore.js +5 -5
  46. package/src/services/runtime/prompt.js +106 -45
  47. package/src/services/runtime/session.js +38 -14
  48. package/src/services/runtime/trajectory.js +1 -1
  49. package/src/services/scheduler.js +146 -19
  50. package/src/services/secrets.js +1 -1
  51. package/src/services/system.js +23 -6
  52. package/src/services/task-dispatch.js +315 -0
  53. package/src/services/task-notify.js +55 -11
  54. package/src/services/task-runs.js +179 -0
  55. package/src/services/task-stage.js +4 -0
  56. package/src/services/tasks.js +51 -399
  57. package/src/services/terminal.js +2 -2
  58. package/src/services/vision-proxy.js +3 -3
  59. package/src/services/wechat.js +228 -7
  60. package/src/services/workspace-groups.js +4 -3
  61. package/src/skill-parse.js +1 -1
  62. package/src/skills.js +1 -1
  63. package/src/tools.js +275 -6
  64. package/src/updater.js +52 -0
  65. package/src/usage-reconcile.js +1 -1
  66. package/src/usage.js +52 -11
  67. package/src/wechat/channel.js +14 -20
  68. package/src/wechat/commands.js +129 -81
  69. package/src/wechat/format.js +247 -0
  70. package/src/wechat/store.js +30 -2
  71. package/ui/app.js +57 -53
  72. package/ui/i18n/en/chat.js +140 -0
  73. package/ui/i18n/en/common.js +187 -0
  74. package/ui/i18n/en/nav.js +89 -0
  75. package/ui/i18n/en/settings.js +352 -0
  76. package/ui/i18n/en/tasks.js +229 -0
  77. package/ui/i18n/en/usage.js +141 -0
  78. package/ui/i18n/en/wechat.js +23 -0
  79. package/ui/i18n/en.js +17 -237
  80. package/ui/i18n/zh/chat.js +140 -0
  81. package/ui/i18n/zh/common.js +187 -0
  82. package/ui/i18n/zh/nav.js +89 -0
  83. package/ui/i18n/zh/settings.js +352 -0
  84. package/ui/i18n/zh/tasks.js +229 -0
  85. package/ui/i18n/zh/usage.js +141 -0
  86. package/ui/i18n/zh/wechat.js +23 -0
  87. package/ui/i18n/zh.js +17 -236
  88. package/ui/modules/api.js +4 -3
  89. package/ui/modules/bot-quota.js +27 -0
  90. package/ui/modules/cards.js +96 -58
  91. package/ui/modules/chat.js +28 -30
  92. package/ui/modules/composer.js +41 -37
  93. package/ui/modules/dom-morph.js +292 -0
  94. package/ui/modules/events-board.js +22 -22
  95. package/ui/modules/events-click.js +100 -68
  96. package/ui/modules/events-misc.js +34 -34
  97. package/ui/modules/events-submit.js +28 -28
  98. package/ui/modules/global-pages.js +125 -116
  99. package/ui/modules/i18n.js +0 -5
  100. package/ui/modules/icons.js +0 -1
  101. package/ui/modules/markdown.js +1 -1
  102. package/ui/modules/modal-forms.js +196 -203
  103. package/ui/modules/modal-layer.js +6 -9
  104. package/ui/modules/page-shell.js +62 -0
  105. package/ui/modules/settings.js +211 -198
  106. package/ui/modules/solo-archive.js +0 -4
  107. package/ui/modules/state.js +57 -50
  108. package/ui/modules/tasks.js +167 -171
  109. package/ui/modules/typing-linger.js +1 -4
  110. package/ui/modules/usage.js +65 -78
  111. package/ui/modules/util.js +92 -25
  112. package/ui/styles/avatars.css +14 -0
  113. package/ui/styles/cards.css +49 -0
  114. package/ui/styles/chat-cards.css +17 -21
  115. package/ui/styles/global-config.css +56 -2
  116. package/ui/styles/modal.css +13 -0
  117. package/ui/styles/usage.css +3 -61
  118. package/CONTRIBUTING.md +0 -20
  119. package/docs/assets/usage-dark.png +0 -0
@@ -1,14 +1,26 @@
1
- // settings.js —— 设置/全局域:全局用量面板(含模型价格规则卡)、运行时效卡、运维卡、
2
- // 项目设置页与全局配置页(renderGlobal,含 DSH 路径/DSH 服务卡)。通道/密钥页见 global-pages.js。
3
1
  import { state } from './state.js'
4
2
  import { t } from './i18n.js'
5
3
  import { icon } from './icons.js'
6
4
  import { activeBots, activeProject, attr, botById, esc, pathCode, tildePath } from './util.js'
7
5
  import { notifyToggleView } from './cards.js'
8
6
  import { usageBotRow, usageCurrency, usageDayPanel, usageDayTitle, usageListPanel, usageMetricCards, usageModelPanel, usagePageHead, usageProjectRow, usageRunRow, usageSection, usageSnapshot, usageWindowText } from './usage.js'
7
+ import { pageHead, pageNav, pageSection, pageShell, refreshAction, slot } from './page-shell.js'
9
8
  import { refresh, noProject } from '../app.js'
10
9
  import { renderPriceCard } from './modal-forms.js'
11
10
 
11
+ // 分布面板的槽位排布:偶数张半宽成两列,奇数张时最后一张整行,避免留空网格单元。
12
+ // panels 可为数组或键值对象,order 给出展示顺序。
13
+ function usagePanelSlots(panels, order) {
14
+ const list = order.map(key => panels[key])
15
+ const last = list.length - 1
16
+ return list.map((body, index) => slot(index === last && list.length % 2 === 1 ? 'full' : 'half', body)).join('')
17
+ }
18
+
19
+ // 分组导航:只列当前视图真实存在的分组,避免死锚点。
20
+ function usageNav(items) {
21
+ return pageNav(items, t('usage.navLabel'))
22
+ }
23
+
12
24
  function renderUsageGlobal() {
13
25
  const usage = usageSnapshot()
14
26
  const tier = usage.tiers?.global
@@ -27,9 +39,9 @@ function renderUsageGlobal() {
27
39
  const unpriced = Number(totals.unpricedCalls ?? 0)
28
40
  const panels = {
29
41
  days: usageDayPanel(days),
30
- model: usageModelPanel(byModel, '分模型', `<span class="meta">${byModel.length} 个</span>`, currency),
31
- bot: usageListPanel('分 Bot', byBot.map(item => usageBotRow(item, maxBot, false, currency)), 'Bot'),
32
- project: usageListPanel('分项目', byProject.map(item => usageProjectRow(item, maxProject, currency)), '项目'),
42
+ model: usageModelPanel(byModel, t('分模型'), `<span class="meta">${t('usage.count', { count: byModel.length })}</span>`, currency),
43
+ bot: usageListPanel(t('分 Bot'), byBot.map(item => usageBotRow(item, maxBot, false, currency)), 'Bot'),
44
+ project: usageListPanel(t('分项目'), byProject.map(item => usageProjectRow(item, maxProject, currency)), t('usage.colProject')),
33
45
  }
34
46
  // 口径切换只调展示顺序,四个维度始终可见(关键信息不折叠)。
35
47
  const order = {
@@ -39,36 +51,33 @@ function renderUsageGlobal() {
39
51
  project: ['project', 'days', 'model', 'bot'],
40
52
  }[focus]
41
53
  const overviewNotes = [
42
- unpriced > 0 ? `<div class="note warn-note">${unpriced} 次调用未配置价格,成本为部分值。</div>` : '',
43
- Number(reconciliation?.mismatched ?? 0) > 0 ? `<div class="usage-note">${Number(reconciliation.mismatched)} 次运行的用量记录对不上,数据可能不完整。</div>` : '',
54
+ unpriced > 0 ? `<div class="note warn-note">${t('usage.unpricedNote', { count: unpriced })}</div>` : '',
55
+ Number(reconciliation?.mismatched ?? 0) > 0 ? `<div class="usage-note">${t('次运行的用量记录对不上,数据可能不完整。', { count: Number(reconciliation.mismatched) })}</div>` : '',
44
56
  ].join('')
45
- return `
46
- ${usagePageHead(usage, '全局口径,不随当前群聊 / 单聊上下文变化')}
47
- ${usageSection(
48
- '全局用量总览',
49
- `四项指标覆盖全部调用来源,按汇总窗口 ${windowText} 统计。`,
50
- `${overviewNotes}${usageMetricCards(totals, '全局', usage)}`,
51
- )}
52
- ${usageSection(
53
- '分布明细',
54
- `四个维度始终同时展示;按日面板只画 ${dayTitle},其余面板与上方汇总同为 ${windowText} 窗口。条形长度 = tokens 占比,琥珀色 = 含未计价调用,空条 = 零用量。`,
55
- `<div class="usage-grid">${order.map(key => panels[key]).join('')}</div>`,
56
- `<div class="usage-seg">
57
- <span class="usage-seg-label">面板顺序</span>
58
- <div class="seg" role="group" aria-label="面板顺序">
59
- <button data-action="usage-scope" data-scope="global" aria-pressed="${focus === 'global'}">趋势优先</button>
60
- <button data-action="usage-scope" data-scope="model" aria-pressed="${focus === 'model'}">模型优先</button>
61
- <button data-action="usage-scope" data-scope="bot" aria-pressed="${focus === 'bot'}">Bot 优先</button>
62
- <button data-action="usage-scope" data-scope="project" aria-pressed="${focus === 'project'}">项目优先</button>
63
- </div>
64
- </div>`,
65
- )}
66
- ${usageSection(
67
- '模型价格规则',
68
- '成本估算依赖这些价格规则,按每百万 token 计价;新增与编辑即时生效。',
69
- renderPriceCard(),
70
- )}
71
- `
57
+ return pageShell(
58
+ usagePageHead(usage, t('usage.headGlobalHint')),
59
+ usageNav([
60
+ { id: 'u-overview', label: t('usage.overview') },
61
+ { id: 'u-distribution', label: t('usage.distTitle') },
62
+ { id: 'u-price', label: t('usage.priceTitle') },
63
+ ]),
64
+ [
65
+ usageSection('01', 'u-overview', t('usage.overview'), t('usage.overviewGlobalDesc', { window: windowText }),
66
+ slot('full', `${overviewNotes}${usageMetricCards(totals, t('usage.scopeGlobal'), usage)}`)),
67
+ usageSection('02', 'u-distribution', t('usage.distTitle'), t('usage.distGlobalDesc', { dayTitle, window: windowText }),
68
+ usagePanelSlots(panels, order),
69
+ `<div class="usage-seg">
70
+ <span class="usage-seg-label">${t('usage.panelOrder')}</span>
71
+ <div class="seg" role="group" aria-label="${t('usage.panelOrder')}">
72
+ <button data-action="usage-scope" data-scope="global" aria-pressed="${focus === 'global'}">${t('usage.orderGlobal')}</button>
73
+ <button data-action="usage-scope" data-scope="model" aria-pressed="${focus === 'model'}">${t('usage.orderModel')}</button>
74
+ <button data-action="usage-scope" data-scope="bot" aria-pressed="${focus === 'bot'}">${t('usage.orderBot')}</button>
75
+ <button data-action="usage-scope" data-scope="project" aria-pressed="${focus === 'project'}">${t('usage.orderProject')}</button>
76
+ </div>
77
+ </div>`),
78
+ usageSection('03', 'u-price', t('usage.priceTitle'), t('usage.priceDesc'), slot('full', renderPriceCard())),
79
+ ],
80
+ )
72
81
  }
73
82
 
74
83
  // 群聊「用量」tab:本群消耗汇总 + 本群分模型 + 本群各 bot,内容严格限本群。
@@ -89,34 +98,33 @@ function renderUsageDomain() {
89
98
  : []
90
99
  const unpriced = Number(totals.unpricedCalls ?? 0)
91
100
  const overviewNotes = [
92
- unpriced > 0 ? `<div class="note warn-note">${unpriced} 次调用未配置价格,成本为部分值。</div>` : '',
93
- tier ? '' : '<div class="usage-note">下方分组明细暂不可用,上方汇总仍按本群统计。</div>',
101
+ unpriced > 0 ? `<div class="note warn-note">${t('usage.unpricedNote', { count: unpriced })}</div>` : '',
102
+ tier ? '' : `<div class="usage-note">${t('下方分组明细暂不可用,上方汇总仍按本群统计。')}</div>`,
94
103
  ].join('')
95
- return `
96
- ${usagePageHead(usage, '仅当前群聊内的用量,不含其他群聊', '本群')}
97
- ${usageSection(
98
- '本群用量总览',
99
- `四项指标只统计当前群聊的调用,按汇总窗口 ${windowText} 归集。`,
100
- `${overviewNotes}${usageMetricCards(totals, '本群', usage)}`,
101
- )}
102
- ${usageSection(
103
- '本群分布明细',
104
- `按日面板只画 ${dayTitle},其余面板与上方汇总同为 ${windowText} 窗口;条形长度 = tokens 占比,琥珀色 = 含未计价调用,空条 = 零用量。`,
105
- `<div class="usage-grid">
106
- ${usageDayPanel(days)}
107
- ${usageModelPanel(byModel, '本群分模型', '', currency)}
108
- ${usageListPanel('本群各 Bot', byBot.map(item => usageBotRow(item, maxBot, true, currency)), 'Bot')}
109
- </div>`,
110
- )}
111
- ${drillBot ? usageSection(
112
- `${drillBot.name} 在本群的运行记录`,
113
- '在「本群各 Bot」列表点选可切换查看对象。',
114
- `<div class="card usage-panel">
115
- ${drillRuns.length === 0 ? '<div class="faint">该 Bot 在本群还没有运行记录。</div>' : `<div class="run-list">${drillRuns.map(usageRunRow).join('')}</div>`}
116
- </div>`,
117
- `<button class="btn small" data-action="usage-clear-drill">${icon('close')}清除选择</button>`,
118
- ) : ''}
119
- `
104
+ const panels = [
105
+ usageDayPanel(days),
106
+ usageModelPanel(byModel, t('本群分模型'), '', currency),
107
+ usageListPanel(t('本群各 Bot'), byBot.map(item => usageBotRow(item, maxBot, true, currency)), 'Bot'),
108
+ ]
109
+ const nav = [
110
+ { id: 'u-overview', label: t('usage.overview') },
111
+ { id: 'u-distribution', label: t('usage.distTitle') },
112
+ ]
113
+ const sections = [
114
+ usageSection('01', 'u-overview', t('usage.overview'), t('usage.overviewDomainDesc', { window: windowText }),
115
+ slot('full', `${overviewNotes}${usageMetricCards(totals, t('usage.scopeDomain'), usage)}`)),
116
+ usageSection('02', 'u-distribution', t('usage.distTitleDomain'), t('usage.distDomainDesc', { dayTitle, window: windowText }),
117
+ usagePanelSlots(panels, panels.map((_, index) => index))),
118
+ ]
119
+ if (drillBot) {
120
+ nav.push({ id: 'u-runs', label: t('usage.drillRunsShort') })
121
+ sections.push(usageSection('03', 'u-runs', t('usage.drillRunsTitle', { name: drillBot.name }), t('usage.drillRunsDesc'),
122
+ slot('full', `<div class="card usage-panel">
123
+ ${drillRuns.length === 0 ? `<div class="faint">${t('usage.drillEmpty')}</div>` : `<div class="run-list">${drillRuns.map(usageRunRow).join('')}</div>`}
124
+ </div>`),
125
+ `<button class="btn small" data-action="usage-clear-drill">${icon('close')}${t('usage.clearDrill')}</button>`))
126
+ }
127
+ return pageShell(usagePageHead(usage, t('usage.headDomainHint'), t('usage.scopeDomain')), usageNav(nav), sections)
120
128
  }
121
129
 
122
130
  // 单聊「用量」tab:本 bot 汇总 + 本 bot 分模型,内容严格限本 bot。
@@ -133,33 +141,28 @@ function renderUsageSolo() {
133
141
  .filter(run => run.bot_id === state.soloBotId && (run.project_id ?? null) === null)
134
142
  const unpriced = Number(totals.unpricedCalls ?? 0)
135
143
  const overviewNotes = [
136
- unpriced > 0 ? `<div class="note warn-note">${unpriced} 次调用未配置价格,成本为部分值。</div>` : '',
137
- usage.solo && tier ? '' : '<div class="usage-note">该 Bot 的单聊明细暂不可用。</div>',
144
+ unpriced > 0 ? `<div class="note warn-note">${t('usage.unpricedNote', { count: unpriced })}</div>` : '',
145
+ usage.solo && tier ? '' : `<div class="usage-note">${t('该 Bot 的单聊明细暂不可用。')}</div>`,
138
146
  ].join('')
139
- return `
140
- ${usagePageHead(usage, '仅该 Bot 在项目外(单聊)的用量,不含项目内调用', '该 Bot')}
141
- ${usageSection(
142
- '该 Bot 用量总览',
143
- `四项指标只统计该 Bot 的单聊调用,按汇总窗口 ${windowText} 归集。`,
144
- `${overviewNotes}${usageMetricCards(totals, '该 Bot', usage)}`,
145
- )}
146
- ${usageSection(
147
- '该 Bot 分布明细',
148
- `按日面板只画 ${dayTitle},其余面板与上方汇总同为 ${windowText} 窗口。`,
149
- `<div class="usage-grid">
150
- ${usageDayPanel(days)}
151
- ${usageModelPanel(byModel, '该 Bot 分模型', '', currency)}
152
- </div>`,
153
- )}
154
- ${usageSection(
155
- '该 Bot 的运行记录',
156
- '与上方用量同口径:只含项目外(单聊)的运行。',
157
- `<div class="card usage-panel">
158
- <div class="card-head"><h3>运行明细</h3><span class="meta">${runs.length} 条</span></div>
159
- ${runs.length === 0 ? '<div class="faint">该 Bot 在项目外还没有运行记录。</div>' : `<div class="run-list">${runs.map(usageRunRow).join('')}</div>`}
160
- </div>`,
161
- )}
162
- `
147
+ return pageShell(
148
+ usagePageHead(usage, t('usage.headSoloHint'), t('usage.scopeSolo')),
149
+ usageNav([
150
+ { id: 'u-overview', label: t('usage.overview') },
151
+ { id: 'u-distribution', label: t('usage.distTitle') },
152
+ { id: 'u-runs', label: t('usage.runDetailTitle') },
153
+ ]),
154
+ [
155
+ usageSection('01', 'u-overview', t('usage.overview'), t('usage.overviewSoloDesc', { window: windowText }),
156
+ slot('full', `${overviewNotes}${usageMetricCards(totals, t('usage.scopeSolo'), usage)}`)),
157
+ usageSection('02', 'u-distribution', t('usage.distTitleSolo'), t('usage.distSoloDesc', { dayTitle, window: windowText }),
158
+ usagePanelSlots({ days: usageDayPanel(days), model: usageModelPanel(byModel, t('该 Bot 分模型'), '', currency) }, ['days', 'model'])),
159
+ usageSection('03', 'u-runs', t('usage.soloRunsTitle'), t('usage.soloRunsDesc'),
160
+ slot('full', `<div class="card usage-panel">
161
+ <div class="card-head"><h3>${t('usage.runDetailTitle')}</h3><span class="meta">${t('usage.runCount', { count: runs.length })}</span></div>
162
+ ${runs.length === 0 ? `<div class="faint">${t('usage.soloRunsEmpty')}</div>` : `<div class="run-list">${runs.map(usageRunRow).join('')}</div>`}
163
+ </div>`)),
164
+ ],
165
+ )
163
166
  }
164
167
 
165
168
  // 全局配置页「运行时效」卡:超时中止与无进展看门狗(分钟),保存走 update_settings。
@@ -169,26 +172,43 @@ function renderRunLimitsCard() {
169
172
  const limits = state.data.runLimits ?? {}
170
173
  const savedRun = settings.run_timeout_minutes ?? ''
171
174
  const savedStall = settings.stall_watchdog_minutes ?? ''
175
+ const savedReviewIdle = settings.review_idle_minutes ?? ''
176
+ const savedAutoClose = settings.review_auto_close ?? ''
172
177
  const runValue = savedRun !== '' ? savedRun : String(limits.runTimeoutMinutes ?? 120)
173
178
  // 看门狗保存值 '0'(关闭)合法,不能用 || 短路吞掉。
174
179
  const stallValue = savedStall !== '' ? savedStall : String(limits.stallTimeoutMinutes ?? 30)
180
+ // 验收滞留阈值(DSHBOTS-235):未保存回填生效值;'0'(关闭守门)同样合法不短路。
181
+ const reviewIdleValue = savedReviewIdle !== '' ? savedReviewIdle : String(limits.reviewIdleMinutes ?? 30)
182
+ const autoCloseOn = savedAutoClose !== '0'
175
183
  const envNames = [
176
184
  limits.runTimeoutEnv ? 'DSH_TEAM_RUN_TIMEOUT_MS' : '',
177
185
  limits.stallTimeoutEnv ? 'DSH_TEAM_STALL_TIMEOUT_MS' : '',
178
186
  ].filter(Boolean).join(' / ')
179
- const stallText = limits.stallTimeoutMinutes === 0 ? '看门狗关闭' : `${limits.stallTimeoutMinutes ?? 30} 分钟看门狗`
187
+ const stallText = limits.stallTimeoutMinutes === 0
188
+ ? t('global.stallOff')
189
+ : t('global.stallMinutes', { minutes: limits.stallTimeoutMinutes ?? 30 })
180
190
  return `
181
191
  <div class="card form-card g-card">
182
- <div class="card-head"><h3>运行时效</h3><span class="meta">当前生效 ${limits.runTimeoutMinutes ?? 120} 分钟超时 / ${stallText}</span></div>
192
+ <div class="card-head"><h3>${t('global.cardRunLimits')}</h3><span class="meta">${t('global.runLimitsCurrent', { timeout: limits.runTimeoutMinutes ?? 120, stall: stallText })}</span></div>
193
+ <div class="field-row">
194
+ <div class="field"><label id="settings-run-timeout-label" for="settings-run-timeout">${t('global.runTimeoutLabel')}</label><input class="input mono" style="text-align:right" type="number" min="1" max="360" id="settings-run-timeout" name="run_timeout_minutes" value="${attr(runValue)}"></div>
195
+ <div class="field"><label id="settings-stall-watchdog-label" for="settings-stall-watchdog">${t('global.stallWatchdogLabel')}</label><input class="input mono" style="text-align:right" type="number" min="0" max="360" id="settings-stall-watchdog" name="stall_watchdog_minutes" value="${attr(stallValue)}"></div>
196
+ </div>
183
197
  <div class="field-row">
184
- <div class="field"><label id="settings-run-timeout-label" for="settings-run-timeout">超时中止(分钟)</label><input class="input mono" style="text-align:right" type="number" min="1" max="360" id="settings-run-timeout" name="run_timeout_minutes" value="${attr(runValue)}"></div>
185
- <div class="field"><label id="settings-stall-watchdog-label" for="settings-stall-watchdog">无进展看门狗(分钟)</label><input class="input mono" style="text-align:right" type="number" min="0" max="360" id="settings-stall-watchdog" name="stall_watchdog_minutes" value="${attr(stallValue)}"></div>
198
+ <div class="field"><label id="settings-review-idle-label" for="settings-review-idle">${t('global.reviewIdleLabel')}</label><input class="input mono" style="text-align:right" type="number" min="0" max="1440" id="settings-review-idle" name="review_idle_minutes" value="${attr(reviewIdleValue)}"></div>
199
+ <div class="field"><label id="settings-review-auto-close-label" for="settings-review-auto-close">${t('global.reviewAutoCloseLabel')}</label>
200
+ <select class="select" id="settings-review-auto-close" name="review_auto_close">
201
+ <option value="1" ${autoCloseOn ? 'selected' : ''}>${t('global.on')}</option>
202
+ <option value="0" ${!autoCloseOn ? 'selected' : ''}>${t('global.off')}</option>
203
+ </select>
204
+ </div>
186
205
  </div>
187
- <div class="hint">超时中止 = 单次运行的最长时长(1–360 分钟);无进展看门狗 = 运行多久没有任何输出即判定卡住(0–360 分钟,0 为关闭)。</div>
188
- <div class="hint">新值只对之后启动的运行生效,进行中的运行不追溯。</div>
189
- ${envNames ? `<div class="hint">环境变量 ${envNames} 已显式设置,对应项以环境变量为准,页面保存值不生效。</div>` : ''}
206
+ <div class="hint">${t('global.runLimitsHint1')}</div>
207
+ <div class="hint">${t('global.reviewIdleHint')}</div>
208
+ <div class="hint">${t('新值只对之后启动的运行生效,进行中的运行不追溯。')}</div>
209
+ ${envNames ? `<div class="hint">${t('global.runLimitsEnv', { names: envNames })}</div>` : ''}
190
210
  <div class="btn-row" style="margin-top:12px">
191
- <button class="btn small" type="button" data-action="save-run-limits">保存运行时效</button>
211
+ <button class="btn small" type="button" data-action="save-run-limits">${t('global.saveRunLimits')}</button>
192
212
  </div>
193
213
  </div>`
194
214
  }
@@ -199,34 +219,34 @@ function renderOpsCard() {
199
219
  const num = value => (value === '' || value === undefined || value === null ? '' : String(value))
200
220
  return `
201
221
  <div class="card form-card g-card">
202
- <div class="card-head"><h3>系统与运维</h3></div>
222
+ <div class="card-head"><h3>${t('global.cardOps')}</h3></div>
203
223
  <div class="field-row">
204
224
  <div class="field">
205
- <label id="settings-currency-label" for="settings-currency">预算币种</label>
225
+ <label id="settings-currency-label" for="settings-currency">${t('global.budgetCurrency')}</label>
206
226
  <select class="select" id="settings-currency" name="budget_currency">
207
227
  ${['CNY', 'USD'].map(code => `<option value="${code}" ${code === currency ? 'selected' : ''}>${code}</option>`).join('')}
208
228
  </select>
209
229
  </div>
210
230
  <div class="field">
211
- <label id="settings-memory-review-label" for="settings-memory-review">记忆自动审查</label>
231
+ <label id="settings-memory-review-label" for="settings-memory-review">${t('global.memoryReview')}</label>
212
232
  <select class="select" id="settings-memory-review" name="memory_review">
213
- <option value="1" ${settings.memory_review !== '0' ? 'selected' : ''}>开启</option>
214
- <option value="0" ${settings.memory_review === '0' ? 'selected' : ''}>关闭</option>
233
+ <option value="1" ${settings.memory_review !== '0' ? 'selected' : ''}>${t('global.on')}</option>
234
+ <option value="0" ${settings.memory_review === '0' ? 'selected' : ''}>${t('global.off')}</option>
215
235
  </select>
216
236
  </div>
217
237
  </div>
218
238
  <div class="field-row">
219
- <div class="field"><label id="settings-global-token-budget-label" for="settings-global-token-budget">全局 Token 预算</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-global-token-budget" name="global_token_budget" value="${attr(num(settings.global_token_budget))}" placeholder="不限制"></div>
220
- <div class="field"><label id="settings-global-cost-budget-label" for="settings-global-cost-budget">全局成本预算</label><input class="input mono" style="text-align:right" type="number" min="0" step="0.01" id="settings-global-cost-budget" name="global_cost_budget" value="${attr(num(settings.global_cost_budget))}" placeholder="不限制"></div>
239
+ <div class="field"><label id="settings-global-token-budget-label" for="settings-global-token-budget">${t('global.tokenBudget')}</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-global-token-budget" name="global_token_budget" value="${attr(num(settings.global_token_budget))}" placeholder="${t('global.unlimited')}"></div>
240
+ <div class="field"><label id="settings-global-cost-budget-label" for="settings-global-cost-budget">${t('global.costBudget')}</label><input class="input mono" style="text-align:right" type="number" min="0" step="0.01" id="settings-global-cost-budget" name="global_cost_budget" value="${attr(num(settings.global_cost_budget))}" placeholder="${t('global.unlimited')}"></div>
221
241
  </div>
222
242
  <div class="field-row">
223
- <div class="field"><label id="settings-retention-usage-label" for="settings-retention-usage">用量保留天数</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-retention-usage" name="retention_usage_days" value="${attr(num(settings.retention_usage_days))}" placeholder="永久"></div>
224
- <div class="field"><label id="settings-retention-run-label" for="settings-retention-run">运行事件保留天数</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-retention-run" name="retention_run_event_days" value="${attr(num(settings.retention_run_event_days))}" placeholder="永久"></div>
243
+ <div class="field"><label id="settings-retention-usage-label" for="settings-retention-usage">${t('global.retentionUsage')}</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-retention-usage" name="retention_usage_days" value="${attr(num(settings.retention_usage_days))}" placeholder="${t('global.forever')}"></div>
244
+ <div class="field"><label id="settings-retention-run-label" for="settings-retention-run">${t('global.retentionRun')}</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-retention-run" name="retention_run_event_days" value="${attr(num(settings.retention_run_event_days))}" placeholder="${t('global.forever')}"></div>
225
245
  </div>
226
- <div class="field"><label id="settings-retention-message-label" for="settings-retention-message">消息保留天数</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-retention-message" name="retention_message_days" value="${attr(num(settings.retention_message_days))}" placeholder="永久"></div>
227
- <div class="hint">全局预算对所有项目生效;保留天数按天清理过期用量、运行事件与消息,0 表示永久保留。</div>
246
+ <div class="field"><label id="settings-retention-message-label" for="settings-retention-message">${t('global.retentionMessage')}</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-retention-message" name="retention_message_days" value="${attr(num(settings.retention_message_days))}" placeholder="${t('global.forever')}"></div>
247
+ <div class="hint">${t('global.opsHint')}</div>
228
248
  <div class="btn-row" style="margin-top:12px">
229
- <button class="btn small" type="button" data-action="save-settings">保存系统设置</button>
249
+ <button class="btn small" type="button" data-action="save-settings">${t('global.saveSettings')}</button>
230
250
  </div>
231
251
  </div>`
232
252
  }
@@ -234,46 +254,55 @@ function renderOpsCard() {
234
254
  // DSH 路径卡:只读展示本机 DSH 目录、工作区、共享技能根与数据目录。
235
255
  function dshPathsCard() {
236
256
  const paths = state.data.paths ?? {}
237
- const copyPath = value => `<button class="btn icon small" type="button" data-action="copy" data-copy="${attr(value)}" title="复制路径" aria-label="复制路径">${icon('copy')}</button>`
257
+ const copyPath = value => `<button class="btn icon small" type="button" data-action="copy" data-copy="${attr(value)}" title="${t('common.copyPath')}" aria-label="${t('common.copyPath')}">${icon('copy')}</button>`
238
258
  return `
239
259
  <div class="card form-card g-card">
240
- <div class="card-head"><h3>DSH 路径</h3><span class="meta">只读</span></div>
241
- <div class="path-row"><span>DSH 目录</span>${pathCode(paths.dshHome ?? '~/.dsh')}${copyPath(paths.dshHome ?? '')}</div>
242
- <div class="path-row"><span>工作区</span>${pathCode(tildePath(paths.workspace))}${copyPath(paths.workspace)}</div>
243
- <div class="path-row"><span>共享</span>${pathCode(paths.skillRoot)}${copyPath(paths.skillRoot)}</div>
244
- <div class="path-row"><span>数据</span>${pathCode(paths.dataDir)}${copyPath(paths.dataDir)}</div>
245
- <div class="hint">技能重扫入口在「技能」页;本卡只读本机路径。</div>
260
+ <div class="card-head"><h3>${t('global.cardDshPaths')}</h3><span class="meta">${t('global.readonly')}</span></div>
261
+ <div class="path-row"><span>${t('global.pathDshHome')}</span>${pathCode(paths.dshHome ?? '~/.dsh')}${copyPath(paths.dshHome ?? '')}</div>
262
+ <div class="path-row"><span>${t('global.pathWorkspace')}</span>${pathCode(tildePath(paths.workspace))}${copyPath(paths.workspace)}</div>
263
+ <div class="path-row"><span>${t('global.pathSkills')}</span>${pathCode(paths.skillRoot)}${copyPath(paths.skillRoot)}</div>
264
+ <div class="path-row"><span>${t('global.pathData')}</span>${pathCode(paths.dataDir)}${copyPath(paths.dataDir)}</div>
265
+ <div class="hint">${t('global.dshPathsHint')}</div>
246
266
  </div>`
247
267
  }
248
268
 
269
+ // 版本行(DSHBOTS-253):取不到真值(缺失/null/'unknown'/空串/纯空白)时整行不渲染,
270
+ // 不显示 unknown 或空占位;两个「最新版本」行行为不变。
271
+ function versionRow(labelKey, value) {
272
+ const version = typeof value === 'string' ? value.trim() : ''
273
+ return version && version !== 'unknown'
274
+ ? `<div class="kv"><span>${t(labelKey)}</span><strong>${esc(version)}</strong></div>`
275
+ : ''
276
+ }
277
+
249
278
  // DSH 服务卡:版本检查 + 投递失败提示(投递失败 kv 落在本卡尾部)。
250
279
  function dshServiceCard() {
251
280
  const data = state.data
252
- // 「DSH 服务」卡检查结果:loadState 只换 state.data,dshUpdate 存这里不被轮询盖掉。
281
+ // @ts-ignore 「DSH 服务」卡检查结果:loadState 只换 state.data,dshUpdate 存这里不被轮询盖掉。
253
282
  const update = state.dshUpdate
254
283
  const latestCell = (latest, available) => latest == null
255
284
  ? '<strong>—</strong>'
256
285
  : available
257
- ? `<strong>${esc(latest)} <span class="pill amber">可升级</span></strong>`
258
- : `<strong>${esc(latest)} <span class="pill green">最新</span></strong>`
286
+ ? `<strong>${esc(latest)} <span class="pill amber">${t('可升级')}</span></strong>`
287
+ : `<strong>${esc(latest)} <span class="pill green">${t('global.latest')}</span></strong>`
259
288
  const outbox = data.outbox ?? { pending: 0, failed: 0, delivered: 0 }
260
289
  return `
261
290
  <div class="card form-card g-card">
262
291
  <div class="card-head">
263
- <h3>DSH 服务</h3>
264
- <button class="btn small" data-action="check-dsh-update">${icon('refresh')}检查更新</button>
292
+ <h3>${t('global.cardDshService')}</h3>
293
+ <button class="btn small" data-action="check-dsh-update">${icon('refresh')}${t('global.checkUpdate')}</button>
265
294
  </div>
266
- <div class="kv"><span>dsh 当前版本</span><strong>${esc(data.dsh?.version ?? 'unknown')}</strong></div>
267
- <div class="kv"><span>dsh 最新版本</span>${latestCell(update?.latest, update?.updateAvailable)}</div>
268
- <div class="kv"><span>dsh-team-bots 当前版本</span><strong>${esc(data.pluginVersion ?? 'unknown')}</strong></div>
269
- <div class="kv"><span>dsh-team-bots 最新版本</span>${latestCell(update?.pluginLatest, update?.pluginUpdateAvailable)}</div>
270
- ${Number(outbox.failed ?? 0) > 0 ? `<div class="kv" style="margin-top:12px"><span>投递队列</span><strong>${outbox.failed} 条消息投递失败</strong></div>` : ''}
295
+ ${versionRow('global.dshCurrentVersion', data.dsh?.version)}
296
+ <div class="kv"><span>${t('global.dshLatestVersion')}</span>${latestCell(update?.latest, update?.updateAvailable)}</div>
297
+ ${versionRow('global.pluginCurrentVersion', data.pluginVersion)}
298
+ <div class="kv"><span>${t('global.pluginLatestVersion')}</span>${latestCell(update?.pluginLatest, update?.pluginUpdateAvailable)}</div>
299
+ ${Number(outbox.failed ?? 0) > 0 ? `<div class="kv" style="margin-top:12px"><span>${t('global.outboxQueue')}</span><strong>${t('global.outboxFailed', { count: outbox.failed })}</strong></div>` : ''}
271
300
  </div>`
272
301
  }
273
302
 
274
303
  function renderSettings() {
275
304
  const project = activeProject()
276
- const copyPath = value => `<button class="btn icon small" type="button" data-action="copy" data-copy="${attr(value)}" title="复制路径" aria-label="复制路径">${icon('copy')}</button>`
305
+ const copyPath = value => `<button class="btn icon small" type="button" data-action="copy" data-copy="${attr(value)}" title="${t("复制路径")}" aria-label="${t("复制路径")}">${icon('copy')}</button>`
277
306
  if (!project) return noProject()
278
307
  const members = activeBots()
279
308
  const owner = botById(project.owner_bot_id)
@@ -282,22 +311,22 @@ function renderSettings() {
282
311
  <div class="settings-grid">
283
312
  <div>
284
313
  <div class="card form-card">
285
- <div class="card-head"><h3>项目资料</h3><span class="meta">${esc(project.key ?? project.id)}</span></div>
314
+ <div class="card-head"><h3>${t("项目资料")}</h3><span class="meta">${esc(project.key ?? project.id)}</span></div>
286
315
  <input type="hidden" name="projectId" value="${attr(project.id)}">
287
- <div class="field"><label id="settings-name-label" for="settings-name">项目名称</label><input class="input" id="settings-name" name="name" value="${attr(project.name)}" maxlength="80"></div>
288
- <div class="field"><label id="settings-description-label" for="settings-description">项目描述</label><textarea class="textarea" id="settings-description" name="description">${esc(project.description || '')}</textarea></div>
316
+ <div class="field"><label id="settings-name-label" for="settings-name">${t("项目名称")}</label><input class="input" id="settings-name" name="name" value="${attr(project.name)}" maxlength="80"></div>
317
+ <div class="field"><label id="settings-description-label" for="settings-description">${t("项目描述")}</label><textarea class="textarea" id="settings-description" name="description">${esc(project.description || '')}</textarea></div>
289
318
  <div class="field-row">
290
- <div class="field"><label id="settings-owner-label" for="settings-owner">总监 Bot</label><select class="select" id="settings-owner" name="ownerBotId">${members.map(bot => `<option value="${attr(bot.id)}" ${bot.id === project.owner_bot_id ? 'selected' : ''}>${esc(bot.name)}</option>`).join('')}</select></div>
291
- <div class="field"><label id="settings-reply-mode-label" for="settings-reply-mode">群聊回复模式</label><select class="select" id="settings-reply-mode" name="replyMode"><option value="owner_first" ${project.group?.reply_mode !== 'everyone' ? 'selected' : ''}>总监优先</option><option value="everyone" ${project.group?.reply_mode === 'everyone' ? 'selected' : ''}>全员响应</option></select></div>
319
+ <div class="field"><label id="settings-owner-label" for="settings-owner">${t("总监")} Bot</label><select class="select" id="settings-owner" name="ownerBotId">${members.map(bot => `<option value="${attr(bot.id)}" ${bot.id === project.owner_bot_id ? 'selected' : ''}>${esc(bot.name)}</option>`).join('')}</select></div>
320
+ <div class="field"><label id="settings-reply-mode-label" for="settings-reply-mode">${t("群聊回复模式")}</label><select class="select" id="settings-reply-mode" name="replyMode"><option value="owner_first" ${project.group?.reply_mode !== 'everyone' ? 'selected' : ''}>${t("总监优先")}</option><option value="everyone" ${project.group?.reply_mode === 'everyone' ? 'selected' : ''}>${t("全员响应")}</option></select></div>
292
321
  </div>
293
322
  </div>
294
323
  <div class="card form-card" style="margin-top:12px">
295
- <div class="card-head"><h3>月度预算</h3></div>
324
+ <div class="card-head"><h3>${t("月度预算")}</h3></div>
296
325
  <div class="field-row">
297
- <div class="field"><label id="settings-token-budget-label" for="settings-token-budget">Token 预算</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-token-budget" name="tokenBudget" value="${project.token_budget ?? ''}" placeholder="不限制"></div>
298
- <div class="field"><label id="settings-cost-budget-label" for="settings-cost-budget">成本预算</label><input class="input mono" style="text-align:right" type="number" min="0" step="0.01" id="settings-cost-budget" name="costBudget" value="${project.cost_budget ?? ''}" placeholder="不限制"></div>
326
+ <div class="field"><label id="settings-token-budget-label" for="settings-token-budget">Token ${t("预算")}</label><input class="input mono" style="text-align:right" type="number" min="0" id="settings-token-budget" name="tokenBudget" value="${project.token_budget ?? ''}" placeholder="${t("不限制")}"></div>
327
+ <div class="field"><label id="settings-cost-budget-label" for="settings-cost-budget">${t("成本预算")}</label><input class="input mono" style="text-align:right" type="number" min="0" step="0.01" id="settings-cost-budget" name="costBudget" value="${project.cost_budget ?? ''}" placeholder="${t("不限制")}"></div>
299
328
  </div>
300
- <div class="hint">超出预算时项目会提示预算已用尽。成本预算与模型价格使用同一币种计价。</div>
329
+ <div class="hint">${t("超出预算时项目会提示预算已用尽。成本预算与模型价格使用同一币种计价。")}</div>
301
330
  </div>
302
331
  <div class="card form-card" style="margin-top:12px">
303
332
  <div class="card-head"><h3>${t('settings.codeHygieneTitle')}</h3></div>
@@ -310,25 +339,25 @@ function renderSettings() {
310
339
  </div>
311
340
  <div>
312
341
  <div class="card form-card">
313
- <div class="card-head"><h3>工作区路径</h3></div>
342
+ <div class="card-head"><h3>${t("工作区路径")}</h3></div>
314
343
  <div class="field">
315
- <label id="settings-production-label" for="settings-production">生产目录</label>
316
- <div style="display:flex;gap:8px"><input class="input mono" style="flex:1" id="settings-production" name="productionDir" value="${attr(project.production_dir ?? '')}" placeholder="/Users/you/repos/my-game(可选)"><button class="btn" type="button" data-action="pick-dir-open" data-picker-for="settings-production">${icon('folder')}选择</button></div>
317
- <div class="hint">Bots 的工作目录,可指向既有代码库;留空则用默认管理目录,切换后已有密钥会自动迁移并清理旧目录。</div>
344
+ <label id="settings-production-label" for="settings-production">${t("生产目录")}</label>
345
+ <div style="display:flex;gap:8px"><input class="input mono" style="flex:1" id="settings-production" name="productionDir" value="${attr(project.production_dir ?? '')}" placeholder="/Users/you/repos/my-game${t("(可选)")}"><button class="btn" type="button" data-action="pick-dir-open" data-picker-for="settings-production">${icon('folder')}${t("选择")}</button></div>
346
+ <div class="hint">Bots ${t("的工作目录,可指向既有代码库;留空则用默认管理目录,切换后已有密钥会自动迁移并清理旧目录。")}</div>
318
347
  <div class="dir-picker" id="dir-picker-settings-production" hidden></div>
319
348
  </div>
320
- <div class="path-row"><span>当前生效</span>${pathCode(tildePath(project.workspace_path))}${copyPath(project.workspace_path)}</div>
321
- <div class="path-row"><span>管理数据</span>${pathCode(project.data_path ?? '')}${copyPath(project.data_path ?? '')}</div>
349
+ <div class="path-row"><span>${t("当前生效")}</span>${pathCode(tildePath(project.workspace_path))}${copyPath(project.workspace_path)}</div>
350
+ <div class="path-row"><span>${t("管理数据")}</span>${pathCode(project.data_path ?? '')}${copyPath(project.data_path ?? '')}</div>
322
351
  </div>
323
352
  <div class="card form-card" style="margin-top:12px">
324
- <div class="card-head"><h3>项目状态</h3>${project.status === 'active' ? '<span class="pill green">运行中</span>' : '<span class="pill amber">已归档</span>'}</div>
325
- <div class="kv"><span>总监</span><strong>${esc(owner?.name ?? '未设置')}</strong></div>
326
- <div class="kv"><span>任务总数</span><strong>${project.stats.tasks}</strong></div>
327
- <div class="kv"><span>运行总数</span><strong>${project.stats.runs}</strong></div>
353
+ <div class="card-head"><h3>${t("项目状态")}</h3>${project.status === 'active' ? `<span class="pill green">${t("运行中")}</span>` : `<span class="pill amber">${t("已归档")}</span>`}</div>
354
+ <div class="kv"><span>${t("总监")}</span><strong>${esc(owner?.name ?? t("未设置"))}</strong></div>
355
+ <div class="kv"><span>${t("任务总数")}</span><strong>${project.stats.tasks}</strong></div>
356
+ <div class="kv"><span>${t("运行总数")}</span><strong>${project.stats.runs}</strong></div>
328
357
  ${project.status === 'active'
329
- ? `<div class="btn-row settings-danger-row" style="margin-top:12px;justify-content:flex-end"><button class="btn small danger" type="button" data-action="archive-project" data-project-id="${attr(project.id)}">归档项目</button></div>`
330
- : `<div class="hint" style="margin-top:10px">已归档项目停止新运行,工作区文件保留。项目再开会恢复为进行中;移除追踪会清理本项目的管理数据。</div>
331
- <div class="btn-row" style="margin-top:12px;justify-content:flex-end"><button class="btn small" type="button" data-action="remove-tracking-open" data-project-id="${attr(project.id)}" data-project-name="${attr(project.name)}">移除追踪</button><button class="btn small primary" type="button" data-action="reopen-project" data-project-id="${attr(project.id)}">项目再开</button></div>`}
358
+ ? `<div class="btn-row settings-danger-row" style="margin-top:12px;justify-content:flex-end"><button class="btn small danger" type="button" data-action="archive-project" data-project-id="${attr(project.id)}">${t("归档项目")}</button></div>`
359
+ : `<div class="hint" style="margin-top:10px">${t("已归档项目停止新运行,工作区文件保留。项目再开会恢复为进行中;移除追踪会清理本项目的管理数据。")}</div>
360
+ <div class="btn-row" style="margin-top:12px;justify-content:flex-end"><button class="btn small" type="button" data-action="remove-tracking-open" data-project-id="${attr(project.id)}" data-project-name="${attr(project.name)}">${t("移除追踪")}</button><button class="btn small primary" type="button" data-action="reopen-project" data-project-id="${attr(project.id)}">${t("项目再开")}</button></div>`}
332
361
  </div>
333
362
  </div>
334
363
  </div>
@@ -341,22 +370,6 @@ function currentScale() {
341
370
  return Number.isFinite(value) && value > 0 ? value : 1
342
371
  }
343
372
 
344
- // 分组信息架构(DSHBOTS-184):一节 = 一组 = 一个锚点;组内是 12 列槽位,
345
- // 槽位负责跨列排布,modal-forms 的价格卡因此不必改自己的结构。
346
- function gsec(index, id, title, desc, body) {
347
- return `
348
- <section class="gsec" id="${id}" aria-labelledby="${id}-title">
349
- <div class="gsec-head">
350
- <span class="gsec-index mono">${index}</span>
351
- <div class="gsec-copy">
352
- <h3 class="gsec-title" id="${id}-title">${title}</h3>
353
- <p class="gsec-desc">${desc}</p>
354
- </div>
355
- </div>
356
- <div class="gsec-body">${body}</div>
357
- </section>`
358
- }
359
-
360
373
  function renderGlobal() {
361
374
  const data = state.data
362
375
  const scale = currentScale()
@@ -364,47 +377,41 @@ function renderGlobal() {
364
377
  // 用 || 而非 ??:settingsView() 对未保存键返回 ''(见 core.js),空串必须回落 auto,否则三选项都不选中。
365
378
  const uiLanguage = data.settings?.ui_language || 'auto'
366
379
  const notify = notifyToggleView()
367
- return `
368
- <div class="global-page">
369
- <header class="global-head">
370
- <div class="global-head-copy">
371
- <p class="global-eyebrow">GLOBAL CONFIGURATION</p>
372
- <h2 class="global-title">全局配置</h2>
373
- <p class="global-desc">跨项目生效的团队设置,按「偏好 → 运行 → 关于」分组,改动在卡片内就地保存。</p>
374
- </div>
375
- </header>
376
- <nav class="global-nav" aria-label="配置分组导航">
377
- <a class="global-nav-item" href="#g-pref">偏好</a>
378
- <a class="global-nav-item" href="#g-runtime">运行与预算</a>
379
- <a class="global-nav-item" href="#g-about">关于与系统状态</a>
380
- </nav>
381
- ${gsec('01', 'g-pref', '偏好', '只影响这台机器上的显示方式,保存后立即生效。', `
382
- <div class="g-slot g-slot--full">
383
- <div class="card form-card g-card">
380
+ return pageShell(
381
+ pageHead('GLOBAL CONFIGURATION', t('global.title'), t('global.desc'), refreshAction()),
382
+ pageNav([
383
+ { id: 'g-pref', label: t('global.groupPref') },
384
+ { id: 'g-runtime', label: t('global.groupRuntime') },
385
+ { id: 'g-about', label: t('global.groupAbout') },
386
+ ], t('global.navLabel')),
387
+ [
388
+ pageSection({
389
+ index: '01', id: 'g-pref', title: t('global.groupPref'), desc: t('global.groupPrefDesc'),
390
+ body: slot('full', `<div class="card form-card g-card">
384
391
  <div class="card-head">
385
- <h3>界面</h3>
386
- <div class="btn-row"><button class="btn small" type="button" data-action="reset-scale">${icon('refresh')}重置</button></div>
392
+ <h3>${t('global.cardUi')}</h3>
393
+ <div class="btn-row"><button class="btn small" type="button" data-action="reset-scale">${icon('refresh')}${t('global.reset')}</button></div>
387
394
  </div>
388
395
  <div class="g-fields">
389
396
  <div class="field">
390
- <label id="ui-scale-label" for="ui-scale">界面字号 <span class="mono" id="ui-scale-value">${Math.round(scale * 100)}%</span></label>
397
+ <label id="ui-scale-label" for="ui-scale">${t('global.uiScale')} <span class="mono" id="ui-scale-value">${Math.round(scale * 100)}%</span></label>
391
398
  <input type="range" id="ui-scale" class="range" min="1" max="1.4" step="0.05" value="${scale}">
392
399
  <div class="scale-row">
393
- <span class="faint">小</span>
394
- <span class="faint" style="margin-left:auto">大</span>
400
+ <span class="faint">${t('global.uiScaleSmall')}</span>
401
+ <span class="faint" style="margin-left:auto">${t('global.uiScaleLarge')}</span>
395
402
  </div>
396
403
  </div>
397
404
  <div class="field">
398
- <span class="field-label" id="ui-theme-label">配色</span>
405
+ <span class="field-label" id="ui-theme-label">${t('global.theme')}</span>
399
406
  <div class="seg" role="group" aria-labelledby="ui-theme-label">
400
407
  <button data-action="set-theme" data-theme="dsh" aria-pressed="${state.theme === 'dsh'}">DSH</button>
401
408
  <button data-action="set-theme" data-theme="catppuccin" aria-pressed="${state.theme === 'catppuccin'}">Catppuccin</button>
402
409
  </div>
403
410
  </div>
404
411
  <div class="field">
405
- <span class="field-label" id="desktop-notify-label">桌面通知</span>
406
- <div><button class="btn small" type="button" data-action="toggle-notify" aria-labelledby="desktop-notify-label" aria-pressed="${notify.on ? 'true' : 'false'}"${notify.disabled ? ' disabled' : ''}>${esc(notify.label)}</button></div>
407
- <div class="hint">${esc(notify.hint)}</div>
412
+ <span class="field-label" id="desktop-notify-label">${t('桌面通知')}</span>
413
+ <div><button class="btn small" type="button" data-action="toggle-notify" aria-labelledby="desktop-notify-label" aria-pressed="${notify.on ? 'true' : 'false'}"${notify.disabled ? ' disabled' : ''}>${esc(t(notify.label))}</button></div>
414
+ <div class="hint">${esc(t(notify.hint))}</div>
408
415
  </div>
409
416
  <div class="field">
410
417
  <label id="settings-ui-language-label" for="settings-ui-language">${t('settings.uiLanguage')}</label>
@@ -418,17 +425,23 @@ function renderGlobal() {
418
425
  </div>
419
426
  <div class="g-foot">
420
427
  <div class="g-kvs">
421
- <div class="kv"><span>缩放范围</span><strong>100% – 140%</strong></div>
422
- <div class="kv"><span>偏好存储</span><strong>本地浏览器(语言除外)</strong></div>
428
+ <div class="kv"><span>${t('global.scaleRange')}</span><strong>100% – 140%</strong></div>
429
+ <div class="kv"><span>${t('global.prefStorage')}</span><strong>${t('global.prefStorageValue')}</strong></div>
423
430
  </div>
424
431
  <div class="btn-row"><button class="btn small primary" type="button" data-action="save-ui-language">${esc(t('settings.uiLanguageSave'))}</button></div>
425
432
  </div>
426
- </div>
427
- </div>`)}
428
- ${gsec('02', 'g-runtime', '运行与预算', '影响所有项目运行的行为与开销上限:超时中止、无进展看门狗、预算与数据保留。', `<div class="g-slot g-slot--half">${renderRunLimitsCard()}</div><div class="g-slot g-slot--half">${renderOpsCard()}</div>`)}
429
- ${gsec('03', 'g-about', '关于与系统状态', '本机 DSH 路径、DSH 与插件版本、更新检查与消息投递队列。', `<div class="g-slot g-slot--half">${dshPathsCard()}</div><div class="g-slot g-slot--half">${dshServiceCard()}</div>`)}
430
- </div>
431
- `
433
+ </div>`),
434
+ }),
435
+ pageSection({
436
+ index: '02', id: 'g-runtime', title: t('global.groupRuntime'), desc: t('global.groupRuntimeDesc'),
437
+ body: `${slot('half', renderRunLimitsCard())}${slot('half', renderOpsCard())}`,
438
+ }),
439
+ pageSection({
440
+ index: '03', id: 'g-about', title: t('global.groupAbout'), desc: t('global.groupAboutDesc'),
441
+ body: `${slot('half', dshPathsCard())}${slot('half', dshServiceCard())}`,
442
+ }),
443
+ ],
444
+ )
432
445
  }
433
446
 
434
- export { renderUsageGlobal, renderUsageDomain, renderUsageSolo, renderRunLimitsCard, renderOpsCard, gsec, renderSettings, currentScale, renderGlobal }
447
+ export { renderUsageGlobal, renderUsageDomain, renderUsageSolo, renderRunLimitsCard, renderOpsCard, renderSettings, currentScale, renderGlobal }