dsh-aupdate 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -70,6 +70,7 @@ window.__ModuleLoader__.load({
70
70
  secSchedule: '调度与范围',
71
71
  lastChecked: '上次检查',
72
72
  lastUpdates: '可更新',
73
+ lastUpdated: '已更新',
73
74
  unavailable: '读不到设置:后端路由没起来(插件仍会按默认设置自动更新)',
74
75
  retry: '重试',
75
76
  save: '保存',
@@ -90,6 +91,8 @@ window.__ModuleLoader__.load({
90
91
  checked: '检查了',
91
92
  packages: '个包',
92
93
  updates: '个可更新',
94
+ updatedUnit: '个已更新',
95
+ updatedHint: '个插件',
93
96
  upToDate: '全部都是最新的',
94
97
  enabled: '启用定时检查',
95
98
  enabledHint: '关掉之后不再自动跑,设置页仍然可用',
@@ -125,6 +128,41 @@ window.__ModuleLoader__.load({
125
128
  allowHint: '每行一个包名;留空表示全部包都参与',
126
129
  allowMajor: '允许跨大版本',
127
130
  allowMajorHint: '关闭后只在同一主版本内升级(0.x 插件多半会因此长期不动)',
131
+ registry: '安装源',
132
+ registryHint: '查版本和装包都走这个源。默认跟随 pnpm 自己的配置,一个字节都不改。',
133
+ regPnpm: '跟随 pnpm',
134
+ regNpmjs: '官方源',
135
+ regMirror: '大陆镜像',
136
+ regCustom: '自定义',
137
+ regUrl: '自定义源地址',
138
+ regUrlHint: 'http(s)://…;填的不是 http(s) 就退回「跟随 pnpm」',
139
+ compatCheck: '装前检查 DSH 兼容性',
140
+ compatCheckHint: '宿主是等插件卸下之后才拒绝装不上的版本的;提前拦下,快照不会白拍、也不会留下半装的样子',
141
+ dshVersion: 'DSH 版本',
142
+ lagTitle: '镜像落后',
143
+ lagNote: '{n} 个插件的镜像还没同步,官方源已经有新版本',
144
+ blockedNote: '{n} 个版本在这台 DSH 上装不了',
145
+ versionsTab: '版本管理',
146
+ versionsTitle: '版本管理',
147
+ versionsSubtitle: '每个已装插件的全部已发布版本,点一下就切过去',
148
+ versionsSearch: '搜索插件名',
149
+ versionsCount: '{n} 个插件',
150
+ versionsShow: '版本',
151
+ versionsHide: '收起',
152
+ versionsSwitch: '切到这一版',
153
+ versionsCurrent: '当前',
154
+ versionsLatest: '最新',
155
+ versionsInstalled: '已装',
156
+ versionsBlocked: '这台 DSH 装不了',
157
+ versionsDeprecated: '已废弃',
158
+ versionsNeed: '要求 DSH {r}',
159
+ versionsLoading: '读取版本…',
160
+ versionsFailed: '读不到版本列表',
161
+ versionsEmpty: '没有匹配的插件',
162
+ versionsDone: '已切到 {v}',
163
+ versionsNoop: '已经是这一版',
164
+ versionsFail: '切换失败',
165
+ versionsTotal: '共 {n} 个版本',
128
166
  maxPerCycle: '一轮最多装几个',
129
167
  maxPerCycleHint: '0 表示不限。装包会一直占着 pnpm 锁,限一个数就把单次占用封顶,剩下的下一轮接着装',
130
168
  sessionIdle: '会话静默(分钟)',
@@ -162,7 +200,12 @@ window.__ModuleLoader__.load({
162
200
  langAuto: '跟随系统',
163
201
  langZh: '中文',
164
202
  langEn: 'English',
165
- toastTitle: '{n} 个插件可以更新',
203
+ toastTitle: '{n} 个插件已更新',
204
+ toastTitleFound: '{n} 个插件可更新',
205
+ toastBadge: '已更新',
206
+ toastBadgeFound: '可更新',
207
+ toastBody: '装好就地生效,不用重启;下面是这一轮换掉的版本。',
208
+ toastBodyFound: '下面是能升级到的新版本;自动安装关掉时只会检查,不会动手。',
166
209
  toastMore: '还有 {n} 个',
167
210
  toastDismiss: '知道了',
168
211
  keepTitle: '保留期限',
@@ -185,6 +228,7 @@ window.__ModuleLoader__.load({
185
228
  rolledBack: '已回滚',
186
229
  policy: '更新策略',
187
230
  minutes: '分钟',
231
+ min: '分钟',
188
232
  scope: '这些设置只影响本机这个 profile',
189
233
  about: '关于 aupdate',
190
234
  aboutVersion: '版本',
@@ -208,6 +252,7 @@ window.__ModuleLoader__.load({
208
252
  secSchedule: 'Schedule and scope',
209
253
  lastChecked: 'Last check',
210
254
  lastUpdates: 'Updates',
255
+ lastUpdated: 'Updated',
211
256
  unavailable: 'Cannot read settings: the backend route is not up (defaults still apply)',
212
257
  retry: 'Retry',
213
258
  save: 'Save',
@@ -228,6 +273,8 @@ window.__ModuleLoader__.load({
228
273
  checked: 'checked',
229
274
  packages: 'packages',
230
275
  updates: 'updates',
276
+ updatedUnit: 'updated',
277
+ updatedHint: 'plugins',
231
278
  upToDate: 'everything is current',
232
279
  enabled: 'Scheduled checks',
233
280
  enabledHint: 'Turn off to stop automatic runs; this page keeps working',
@@ -263,6 +310,41 @@ window.__ModuleLoader__.load({
263
310
  allowHint: 'one package name per line; empty means every package',
264
311
  allowMajor: 'Allow major upgrades',
265
312
  allowMajorHint: 'Off keeps upgrades inside one major; 0.x plugins would rarely move',
313
+ registry: 'Registry',
314
+ registryHint: 'Version lookups and installs both use this source. The default follows pnpm own config and changes nothing.',
315
+ regPnpm: 'Follow pnpm',
316
+ regNpmjs: 'Official',
317
+ regMirror: 'China mirror',
318
+ regCustom: 'Custom',
319
+ regUrl: 'Custom registry URL',
320
+ regUrlHint: 'http(s)://…; anything else falls back to Follow pnpm',
321
+ compatCheck: 'Check DSH compatibility first',
322
+ compatCheckHint: 'The host refuses unusable versions only after the bundle is gone; stopping earlier keeps the snapshot and the profile clean',
323
+ dshVersion: 'DSH version',
324
+ lagTitle: 'Mirror behind',
325
+ lagNote: '{n} plugin(s) not synced to the mirror yet; upstream already has newer',
326
+ blockedNote: '{n} version(s) cannot be installed on this DSH',
327
+ versionsTab: 'Versions',
328
+ versionsTitle: 'Version manager',
329
+ versionsSubtitle: 'Every published version of every installed plugin; click one to switch',
330
+ versionsSearch: 'Search plugin names',
331
+ versionsCount: '{n} plugins',
332
+ versionsShow: 'Versions',
333
+ versionsHide: 'Hide',
334
+ versionsSwitch: 'Switch to this',
335
+ versionsCurrent: 'current',
336
+ versionsLatest: 'latest',
337
+ versionsInstalled: 'installed',
338
+ versionsBlocked: 'not installable on this DSH',
339
+ versionsDeprecated: 'deprecated',
340
+ versionsNeed: 'needs DSH {r}',
341
+ versionsLoading: 'Loading versions…',
342
+ versionsFailed: 'Could not read the version list',
343
+ versionsEmpty: 'Nothing matches',
344
+ versionsDone: 'Switched to {v}',
345
+ versionsNoop: 'Already on this version',
346
+ versionsFail: 'Switch failed',
347
+ versionsTotal: '{n} versions',
266
348
  maxPerCycle: 'Installs per cycle',
267
349
  maxPerCycleHint: '0 means no limit. pnpm holds a lock for the whole install, so a cap bounds how long the profile stays busy; the rest wait for the next cycle',
268
350
  sessionIdle: 'Session quiet window (minutes)',
@@ -300,7 +382,12 @@ window.__ModuleLoader__.load({
300
382
  langAuto: 'Follow the system',
301
383
  langZh: '中文',
302
384
  langEn: 'English',
303
- toastTitle: '{n} plugin(s) can update',
385
+ toastTitle: '{n} plugin(s) updated',
386
+ toastTitleFound: '{n} plugin(s) can update',
387
+ toastBadge: 'Updated',
388
+ toastBadgeFound: 'Update available',
389
+ toastBody: 'Applied in place, no restart needed. Here is what changed this round.',
390
+ toastBodyFound: 'Newer versions are available. With auto-install off this only checks; nothing is installed.',
304
391
  toastMore: 'and {n} more',
305
392
  toastDismiss: 'Got it',
306
393
  keepTitle: 'Retention',
@@ -322,6 +409,7 @@ window.__ModuleLoader__.load({
322
409
  rollbackFailed: 'Rollback failed',
323
410
  rolledBack: 'rolled back',
324
411
  policy: 'Update policy',
412
+ minutes: 'minutes',
325
413
  min: 'min',
326
414
  scope: 'These settings apply to this profile only',
327
415
  about: 'About aupdate',
@@ -408,17 +496,12 @@ window.__ModuleLoader__.load({
408
496
  if (typeof iso !== 'string' || iso === '') return ''
409
497
  const when = new Date(iso)
410
498
  if (Number.isNaN(when.getTime())) return iso
411
- try {
412
- return new Intl.DateTimeFormat(LOCALE, {
413
- year: 'numeric', month: '2-digit', day: '2-digit',
414
- hour: '2-digit', minute: '2-digit', second: '2-digit',
415
- hour12: false,
416
- }).format(when)
417
- } catch {
418
- const pad = (n) => String(n).padStart(2, '0')
419
- return when.getFullYear() + '-' + pad(when.getMonth() + 1) + '-' + pad(when.getDate()) +
420
- ' ' + pad(when.getHours()) + ':' + pad(when.getMinutes()) + ':' + pad(when.getSeconds())
421
- }
499
+ // 26/11/26 12:38:两位年/月/日 + 时:分,秒不显示。
500
+ // 「上一次检查」这类时间看到分就够,秒只会把统计卡挤窄;
501
+ // 走本地时区取值,不用 Intl 的日期顺序(中文环境会排成 2026/11/26)。
502
+ const pad = (n) => String(n).padStart(2, '0')
503
+ return pad(when.getFullYear() % 100) + '/' + pad(when.getMonth() + 1) + '/' + pad(when.getDate()) +
504
+ ' ' + pad(when.getHours()) + ':' + pad(when.getMinutes())
422
505
  }
423
506
 
424
507
  /**
@@ -572,11 +655,11 @@ window.__ModuleLoader__.load({
572
655
  .dsh-au-badge.run{color:var(--dsw-alias-state-business-primary,#4d6bfe);border-color:color-mix(in oklch,var(--dsw-alias-state-business-primary,#4d6bfe),transparent 55%);background:color-mix(in oklch,var(--dsw-alias-state-business-primary,#4d6bfe),transparent 90%)}
573
656
 
574
657
  .dsh-au-input{width:96px;padding:4px 8px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.32));background:var(--dsw-alias-bg-layer-2,transparent);color:inherit;font:inherit;font-size:13px;text-align:right;transition:border-color .15s}
575
- .dsh-au-area{width:100%;min-height:58px;padding:6px 8px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.32));background:var(--dsw-alias-bg-layer-2,transparent);color:inherit;font:inherit;font-size:12.5px;resize:vertical;transition:border-color .15s}
576
658
  .dsh-au-select{padding:4px 8px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.32));background:var(--dsw-alias-bg-layer-2,transparent);color:inherit;font:inherit;font-size:13px;min-width:132px;transition:border-color .15s}
659
+ .dsh-au-url{width:240px;max-width:100%;padding:4px 8px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.32));background:var(--dsw-alias-bg-layer-2,transparent);color:inherit;font:inherit;font-size:12.5px;transition:border-color .15s}
577
660
  .dsh-au-search{padding:4px 8px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.32));background:var(--dsw-alias-bg-layer-2,transparent);color:inherit;font:inherit;font-size:12.5px;transition:border-color .15s}
578
- .dsh-au-input:focus,.dsh-au-area:focus,.dsh-au-select:focus,.dsh-au-search:focus{outline:none;border-color:var(--dsw-alias-state-business-primary,#4d6bfe)}
579
- .dsh-au-input:disabled,.dsh-au-select:disabled,.dsh-au-area:disabled{opacity:.55}
661
+ .dsh-au-input:focus,.dsh-au-select:focus,.dsh-au-search:focus,.dsh-au-url:focus{outline:none;border-color:var(--dsw-alias-state-business-primary,#4d6bfe)}
662
+ .dsh-au-input:disabled,.dsh-au-select:disabled{opacity:.55}
580
663
 
581
664
  .dsh-au-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
582
665
  .dsh-au-btn{display:inline-flex;align-items:center;gap:4px;padding:4px 11px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.32));background:transparent;color:inherit;font:inherit;font-size:12.5px;cursor:pointer;transition:background .15s,border-color .15s,opacity .15s}
@@ -601,22 +684,38 @@ window.__ModuleLoader__.load({
601
684
  .dsh-au-logtime{color:var(--dsw-alias-label-caption,rgba(128,128,128,.8));font-variant-numeric:tabular-nums}
602
685
  .dsh-au-logtext{color:inherit}
603
686
 
687
+ /* 版本管理:一行版本 = 版本号 + 标记 + 右侧动作。 */
688
+ .dsh-au-vhead{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
689
+ .dsh-au-vlist{display:flex;flex-direction:column;gap:2px;max-height:300px;overflow:auto;border:1px solid var(--dsw-alias-border-l1,rgba(128,128,128,.22));border-radius:10px;padding:4px;margin-top:2px}
690
+ .dsh-au-vrow{display:flex;align-items:center;gap:8px;padding:3px 6px;border-radius:6px;min-width:0}
691
+ .dsh-au-vrow:hover{background:var(--dsw-alias-bg-mask-1,rgba(128,128,128,.08))}
692
+ .dsh-au-vnum{flex:0 0 auto;min-width:92px;font-variant-numeric:tabular-nums;font-size:12.5px}
693
+ .dsh-au-vact{flex:0 0 auto;margin-left:auto}
694
+ .dsh-au-dim{color:var(--dsw-alias-label-caption,rgba(128,128,128,.85));font-size:11.5px}
695
+ .dsh-au-bad{color:var(--dsw-alias-state-error-primary,#d9534f);font-size:11.5px}
696
+ .dsh-au-pivot{flex:0 0 auto;font-size:11px;line-height:1.6;padding:0 7px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));color:var(--dsw-alias-label-secondary,inherit)}
604
697
  .dsh-au-link{color:inherit;text-decoration:none;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.4));padding-bottom:1px;transition:color .15s,border-color .15s}
605
698
  .dsh-au-link:hover{color:var(--dsw-alias-state-business-primary,#4d6bfe);border-color:currentColor}
606
699
  .dsh-au-linkext{margin-left:3px;opacity:.5}
607
700
 
608
- .dsh-au-toast{position:fixed;right:16px;bottom:16px;z-index:2147483000;display:flex;flex-direction:column;gap:10px;box-sizing:border-box;width:340px;max-width:calc(100vw - 32px);padding:14px 15px;border-radius:12px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));background:var(--dsw-alias-toast-bg,#f7f7f8);color:var(--dsw-alias-label-primary,#1f2328);box-shadow:0 12px 32px rgba(0,0,0,.24);font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;animation:dsh-au-in .18s ease-out}
609
- .dsh-au-toast-head{display:flex;align-items:center;gap:8px}
610
- .dsh-au-toast-title{flex:1 1 auto;min-width:0;font-weight:600}
611
- .dsh-au-toast-x{flex:0 0 auto;width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0;border:0;border-radius:6px;background:transparent;color:inherit;font:inherit;font-size:16px;line-height:1;opacity:.6;cursor:pointer;transition:background .15s,opacity .15s}
701
+ /* 通知卡:照 dsh-cost-meter 的「峰/谷切换提醒」做。
702
+ * 那张卡是「圆点徽标 + 标题 + 正文 + 右对齐按钮」,并按事件换主色;
703
+ * 这里同一结构用于「发现可更新」,主色取 business 蓝,边框和投影都走主题。 */
704
+ .dsh-au-toast{--au-toast-accent:var(--dsw-alias-state-business-primary,#4d6bfe);position:fixed;right:16px;bottom:16px;z-index:2147483000;display:flex;flex-direction:column;gap:9px;box-sizing:border-box;width:340px;max-width:calc(100vw - 32px);padding:14px 16px;border-radius:14px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-toast-bg,#f7f7f8));color:var(--dsw-alias-label-primary,#1f2328);box-shadow:0 14px 36px #00000038;font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;animation:dsh-au-in .22s cubic-bezier(.2,.8,.2,1)}
705
+ .dsh-au-toast-badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-weight:600;letter-spacing:.4px;text-transform:uppercase;color:var(--au-toast-accent)}
706
+ .dsh-au-toast-badge:before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor;box-shadow:0 0 0 4px color-mix(in srgb,currentColor 16%,transparent);flex:0 0 auto}
707
+ .dsh-au-toast-head{display:flex;align-items:flex-start;gap:8px}
708
+ .dsh-au-toast-title{flex:1 1 auto;min-width:0;font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary,#1f2328);line-height:1.4}
709
+ .dsh-au-toast-x{flex:0 0 auto;width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0;margin:-2px -4px 0 0;border:0;border-radius:6px;background:transparent;color:inherit;font:inherit;font-size:16px;line-height:1;opacity:.6;cursor:pointer;transition:background .15s,opacity .15s}
612
710
  .dsh-au-toast-x:hover{opacity:1;background:var(--dsw-alias-bg-mask-2,rgba(128,128,128,.14))}
711
+ .dsh-au-toast-body{color:var(--dsw-alias-label-secondary,rgba(128,128,128,1));line-height:1.55;font-size:12.5px}
613
712
  .dsh-au-toast-list{display:flex;flex-direction:column;gap:2px;max-height:190px;overflow:auto;margin:0 -4px}
614
713
  .dsh-au-toast-item{display:flex;align-items:baseline;gap:8px;padding:3px 6px;border-radius:6px;background:var(--dsw-alias-bg-mask-1,rgba(128,128,128,.08))}
615
- .dsh-au-toast-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
714
+ .dsh-au-toast-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-primary,inherit)}
616
715
  .dsh-au-toast-ver{flex:0 0 auto;font-size:11.5px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95));font-variant-numeric:tabular-nums}
617
716
  .dsh-au-toast-more{font-size:11.5px;color:var(--dsw-alias-label-caption,rgba(128,128,128,.85))}
618
- .dsh-au-toast-foot{display:flex;align-items:center;justify-content:flex-end;gap:8px}
619
- @keyframes dsh-au-in{from{opacity:0;transform:translateY(8px) scale(.99)}to{opacity:1;transform:none}}
717
+ .dsh-au-toast-foot{display:flex;align-items:center;justify-content:flex-end;gap:8px;padding-top:2px}
718
+ @keyframes dsh-au-in{from{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}
620
719
  @media (prefers-reduced-motion:reduce){.dsh-au-toast{animation:none}}
621
720
  `
622
721
 
@@ -648,9 +747,17 @@ window.__ModuleLoader__.load({
648
747
  label: 'dsh-au-label',
649
748
  hint: 'dsh-au-hint',
650
749
  input: 'dsh-au-input',
651
- area: 'dsh-au-area',
652
750
  select: 'dsh-au-select',
653
751
  search: 'dsh-au-search',
752
+ url: 'dsh-au-url',
753
+ vhead: 'dsh-au-vhead',
754
+ vlist: 'dsh-au-vlist',
755
+ vrow: 'dsh-au-vrow',
756
+ vnum: 'dsh-au-vnum',
757
+ vact: 'dsh-au-vact',
758
+ dim: 'dsh-au-dim',
759
+ bad: 'dsh-au-bad',
760
+ pivot: 'dsh-au-pivot',
654
761
  actions: 'dsh-au-actions',
655
762
  btn: 'dsh-au-btn',
656
763
  btnPrimary: 'dsh-au-btn dsh-au-primary',
@@ -661,7 +768,6 @@ window.__ModuleLoader__.load({
661
768
  stat: 'dsh-au-stat',
662
769
  statK: 'dsh-au-stat-k',
663
770
  statV: 'dsh-au-stat-v',
664
- badge: 'dsh-au-badge',
665
771
  check: 'dsh-au-check',
666
772
  logBox: 'dsh-au-log',
667
773
  logTime: 'dsh-au-logtime',
@@ -1146,6 +1252,7 @@ window.__ModuleLoader__.load({
1146
1252
  }
1147
1253
 
1148
1254
  const last = state?.lastRun
1255
+ const applied = appliedCount(last)
1149
1256
 
1150
1257
  return h('div', { className: S.wrap },
1151
1258
  h('div', { className: S.head },
@@ -1227,6 +1334,43 @@ window.__ModuleLoader__.load({
1227
1334
  h(SwitchRow, { label: T.allowMajor, hint: T.allowMajorHint, value: draft.allowMajor, onChange: (v) => patch('allowMajor', v) }),
1228
1335
  h(SwitchRow, { label: T.allowPrerelease, hint: T.allowPrereleaseHint, value: draft.allowPrerelease, onChange: (v) => patch('allowPrerelease', v) }),
1229
1336
  ),
1337
+ // 安装源 + 兼容性预检(0.8.0 借自 dsh-plugin-upgrader,见 docs/BORROWED-FROM-UPGRADER.md)。
1338
+ h('div', { className: S.card },
1339
+ h('h3', { className: S.h }, T.registry),
1340
+ h(SelectRow, {
1341
+ label: T.registry,
1342
+ hint: T.registryHint,
1343
+ value: draft.registryMode ?? 'pnpm',
1344
+ onChange: (v) => patch('registryMode', v),
1345
+ options: [
1346
+ { value: 'pnpm', label: T.regPnpm },
1347
+ { value: 'npmjs', label: T.regNpmjs },
1348
+ { value: 'mirror', label: T.regMirror },
1349
+ { value: 'custom', label: T.regCustom },
1350
+ ],
1351
+ }),
1352
+ (draft.registryMode ?? 'pnpm') === 'custom'
1353
+ ? h('div', { className: S.row },
1354
+ h('div', { className: S.labelBox },
1355
+ h('span', { className: S.label }, T.regUrl),
1356
+ h('span', { className: S.hint }, T.regUrlHint),
1357
+ ),
1358
+ h('input', {
1359
+ type: 'url',
1360
+ value: draft.registryUrl ?? '',
1361
+ placeholder: 'https://registry.example.com',
1362
+ onChange: (event) => patch('registryUrl', event.target.value),
1363
+ className: S.url,
1364
+ }),
1365
+ )
1366
+ : null,
1367
+ h(SwitchRow, { label: T.compatCheck, hint: T.compatCheckHint, value: draft.compatCheck !== false, onChange: (v) => patch('compatCheck', v) }),
1368
+ // 这两项是只读的现场信息:出问题时第一句话就是「你的 DSH 是哪个版本、走的哪个源」。
1369
+ h('div', { className: S.meta },
1370
+ h('span', null, T.dshVersion + ': ' + (state?.dshVersion ?? '—')),
1371
+ h('span', null, T.registry + ': ' + (state?.registry === '' || !state?.registry ? T.regPnpm : state.registry)),
1372
+ ),
1373
+ ),
1230
1374
  h('div', { className: S.card },
1231
1375
  h('h3', { className: S.h }, T.keepTitle),
1232
1376
  h('p', { className: S.note }, T.keepHint),
@@ -1286,9 +1430,12 @@ window.__ModuleLoader__.load({
1286
1430
  h('span', { className: S.hint }, T.packages),
1287
1431
  ),
1288
1432
  h('div', { className: S.stat },
1289
- h('span', { className: S.statK }, T.lastUpdates),
1290
- h('span', { className: S.statV }, String(last.updates?.length ?? 0)),
1291
- h('span', { className: S.hint }, (last.updates?.length ?? 0) > 0 ? T.updates : T.upToDate),
1433
+ h('span', { className: S.statK }, applied > 0 ? T.lastUpdated : T.lastUpdates),
1434
+ h('span', { className: S.statV }, String(applied > 0 ? applied : (last.updates?.length ?? 0))),
1435
+ // 卡片里标题已经是「已更新」,副标题只补量词,不再重复一遍「已更新」。
1436
+ h('span', { className: S.hint }, applied > 0
1437
+ ? T.updatedHint
1438
+ : (last.updates?.length ?? 0) > 0 ? T.updates : T.upToDate),
1292
1439
  ),
1293
1440
  ),
1294
1441
  // 原因只说一遍:徽标承接状态词,正文承接句子,两者不重复同一句话。
@@ -1319,6 +1466,16 @@ window.__ModuleLoader__.load({
1319
1466
  )),
1320
1467
  )
1321
1468
  })(),
1469
+ // 镜像落后和「装不了」都要按名字说出来:只报「已是最新」或「一个没装上」,
1470
+ // 用户没法知道该换源还是该升 DSH。
1471
+ (last?.lagged?.length ?? 0) > 0
1472
+ ? h('p', { className: S.note }, T.lagNote.replace('{n}', String(last.lagged.length)) + ' · ' +
1473
+ last.lagged.slice(0, 3).map((row) => row.name + ' ' + (row.mirror ?? '?') + ' → ' + (row.upstream ?? '?')).join(','))
1474
+ : null,
1475
+ (last?.blocked?.length ?? 0) > 0
1476
+ ? h('p', { className: S.note }, T.blockedNote.replace('{n}', String(last.blocked.length)) + ' · ' +
1477
+ last.blocked.slice(0, 3).map((row) => row.name + '@' + (row.target ?? '?')).join(','))
1478
+ : null,
1322
1479
  runHint ? h('span', { className: S.status }, runHint) : null,
1323
1480
  ),
1324
1481
  // 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
@@ -1457,9 +1614,11 @@ window.__ModuleLoader__.load({
1457
1614
  ? (T.enabled + ':' + T.off)
1458
1615
  : last === null || last === undefined
1459
1616
  ? T.never
1460
- : (last.updates?.length ?? 0) > 0
1461
- ? (last.updates?.length ?? 0) + ' ' + T.updates
1462
- : T.upToDate
1617
+ : appliedCount(last) > 0
1618
+ ? appliedCount(last) + ' ' + T.updatedUnit
1619
+ : (last.updates?.length ?? 0) > 0
1620
+ ? (last.updates?.length ?? 0) + ' ' + T.updates
1621
+ : T.upToDate
1463
1622
  return h('span', { className: S.status }, text)
1464
1623
  }
1465
1624
 
@@ -1507,6 +1666,19 @@ window.__ModuleLoader__.load({
1507
1666
  return { name, versions: from + ' → ' + to }
1508
1667
  }
1509
1668
 
1669
+ /**
1670
+ * 这一轮「真的换掉了几个版本」。
1671
+ *
1672
+ * lastRun.updates 是「发现了哪些新版本」,安装被关掉、被让开、装失败时它照样有值。
1673
+ * 界面上说「已更新 N 个」就必须是装成了的,否则把「查到 4 个」写成「更新了 4 个」
1674
+ * 是在撒谎。installed 里失败的条目带 ' !failed',要减掉。
1675
+ */
1676
+ function appliedCount(last) {
1677
+ if (last === null || last === undefined) return 0
1678
+ const rows = Array.isArray(last.installed) ? last.installed : []
1679
+ return rows.filter((row) => typeof row === 'string' && !row.endsWith('!failed')).length
1680
+ }
1681
+
1510
1682
  function updateSignature(updates) {
1511
1683
  return (Array.isArray(updates) ? updates : [])
1512
1684
  .map((item) => describeUpdate(item))
@@ -1516,7 +1688,7 @@ window.__ModuleLoader__.load({
1516
1688
  .join('|')
1517
1689
  }
1518
1690
 
1519
- function showUpdateToast(updates) {
1691
+ function showUpdateToast(updates, applied) {
1520
1692
  if (toastOpen) return
1521
1693
  const doc = typeof document === 'undefined' ? null : document
1522
1694
  if (doc === null || doc.body === null) return
@@ -1531,12 +1703,19 @@ window.__ModuleLoader__.load({
1531
1703
  box.setAttribute('role', 'status')
1532
1704
  box.setAttribute('aria-live', 'polite')
1533
1705
 
1534
- // 头部:标题 + × —— 和 cost-meter 的引导卡同一套「标题行 + 关闭」结构。
1706
+ // 结构与 cost-meter 的「峰/谷切换提醒」一致:圆点徽标 → 标题行(含 ×)
1707
+ // → 一句正文 → 清单 → 右对齐按钮。徽标是那张卡最好认的一处,这里复用它。
1708
+ const badge = doc.createElement('div')
1709
+ badge.className = 'dsh-au-toast-badge'
1710
+ badge.textContent = applied > 0 ? T.toastBadge : T.toastBadgeFound
1711
+ box.appendChild(badge)
1712
+
1535
1713
  const head = doc.createElement('div')
1536
1714
  head.className = 'dsh-au-toast-head'
1537
1715
  const title = doc.createElement('div')
1538
1716
  title.className = 'dsh-au-toast-title'
1539
- title.textContent = T.toastTitle.replace('{n}', String(rows.length))
1717
+ // 真的装完了才说「已更新」;只查到、没动手时说「可更新」,别把「发现」说成「装了」。
1718
+ title.textContent = (applied > 0 ? T.toastTitle : T.toastTitleFound).replace('{n}', String(rows.length))
1540
1719
  const xBtn = doc.createElement('button')
1541
1720
  xBtn.type = 'button'
1542
1721
  xBtn.className = 'dsh-au-toast-x'
@@ -1546,6 +1725,11 @@ window.__ModuleLoader__.load({
1546
1725
  head.appendChild(xBtn)
1547
1726
  box.appendChild(head)
1548
1727
 
1728
+ const body = doc.createElement('div')
1729
+ body.className = 'dsh-au-toast-body'
1730
+ body.textContent = applied > 0 ? T.toastBody : T.toastBodyFound
1731
+ box.appendChild(body)
1732
+
1549
1733
  const list = doc.createElement('div')
1550
1734
  list.className = 'dsh-au-toast-list'
1551
1735
  // 超过 12 条就在框内滚动:提醒不该占掉半屏。
@@ -1620,7 +1804,7 @@ window.__ModuleLoader__.load({
1620
1804
  const sig = updateSignature(updates)
1621
1805
  if (sig !== notifiedMark()) {
1622
1806
  markNotified(sig)
1623
- showUpdateToast(updates)
1807
+ showUpdateToast(updates, appliedCount(state?.lastRun))
1624
1808
  }
1625
1809
  }
1626
1810
  }
@@ -1636,6 +1820,196 @@ window.__ModuleLoader__.load({
1636
1820
  }
1637
1821
  }
1638
1822
 
1823
+ /**
1824
+ * 「版本管理」标签页。
1825
+ *
1826
+ * 和设置页的分工:设置页管「什么时候自动升」,这一页管「现在就要某一版」。
1827
+ * 版本列表按包按需拉(一次一个包),不进首屏:整页一次拉一堆包的 packument
1828
+ * 在镜像上会慢到没法用。
1829
+ */
1830
+ function VersionsTab() {
1831
+ useLang()
1832
+ const [state, setState] = useState(null)
1833
+ const [query, setQuery] = useState('')
1834
+ const [openName, setOpenName] = useState('')
1835
+ const [lists, setLists] = useState({})
1836
+ const [loadError, setLoadError] = useState('')
1837
+ const [busy, setBusy] = useState('')
1838
+ const [hint, setHint] = useState('')
1839
+
1840
+ const reload = useCallback(async () => {
1841
+ try {
1842
+ setState(await getState(LANG))
1843
+ } catch {}
1844
+ }, [])
1845
+
1846
+ useEffect(() => { void reload() }, [reload])
1847
+
1848
+ // 切版本可能要好几分钟(pnpm 要校验锁文件),期间才轮询;闲着时一个请求都不发。
1849
+ useEffect(() => {
1850
+ if (busy === '') return undefined
1851
+ const timer = setInterval(async () => {
1852
+ try {
1853
+ setState(await getState(LANG))
1854
+ } catch {}
1855
+ }, 3000)
1856
+ return () => clearInterval(timer)
1857
+ }, [busy])
1858
+
1859
+ const openVersions = useCallback(async (name) => {
1860
+ if (openName === name) {
1861
+ setOpenName('')
1862
+ return
1863
+ }
1864
+ setOpenName(name)
1865
+ setLoadError('')
1866
+ if (lists[name] !== undefined) return
1867
+ try {
1868
+ const response = await fetch(endpoint('versions') + '?name=' + encodeURIComponent(name) + '&lang=' + (LANG === 'en' ? 'en' : 'zh'), {
1869
+ headers: { accept: 'application/json' },
1870
+ cache: 'no-store',
1871
+ })
1872
+ if (!response.ok) throw new Error('versions ' + response.status)
1873
+ const payload = await response.json()
1874
+ setLists((prev) => ({ ...prev, [name]: payload }))
1875
+ } catch {
1876
+ setLoadError(T.versionsFailed)
1877
+ }
1878
+ }, [openName, lists])
1879
+
1880
+ const doSwitch = useCallback(async (name, version) => {
1881
+ if (busy !== '') return
1882
+ setBusy(name + '@' + version)
1883
+ setHint('')
1884
+ try {
1885
+ const response = await fetch(endpoint('switch') + langQuery(), {
1886
+ method: 'POST',
1887
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
1888
+ body: JSON.stringify({ name, version }),
1889
+ })
1890
+ const payload = await response.json().catch(() => null)
1891
+ if (response.ok) {
1892
+ setHint(payload?.unchanged === true ? T.versionsNoop : T.versionsDone.replace('{v}', version))
1893
+ // 版本变了,这个包的缓存列表要作废,否则「当前」标记还停在旧版本上。
1894
+ setLists((prev) => {
1895
+ const next = { ...prev }
1896
+ delete next[name]
1897
+ return next
1898
+ })
1899
+ await reload()
1900
+ } else {
1901
+ setHint(T.versionsFail + ' · ' + (payload?.reason || payload?.detail || ('HTTP ' + response.status)))
1902
+ }
1903
+ } catch {
1904
+ setHint(T.versionsFail)
1905
+ } finally {
1906
+ setBusy('')
1907
+ }
1908
+ }, [busy, reload])
1909
+
1910
+ const packages = useMemo(() => {
1911
+ const all = Array.isArray(state?.packages) ? state.packages : []
1912
+ const text = query.trim().toLowerCase()
1913
+ return text === '' ? all : all.filter((item) => String(item.name).toLowerCase().includes(text))
1914
+ }, [state, query])
1915
+
1916
+ const progress = state?.progress
1917
+ const runningText = (() => {
1918
+ if (!progress) return ''
1919
+ if (progress.phase === 'installing' && progress.total > 0) {
1920
+ return T.progressInstall
1921
+ .replace('{n}', String(progress.index))
1922
+ .replace('{m}', String(progress.total))
1923
+ .replace('{name}', String(progress.name || ''))
1924
+ }
1925
+ if (progress.phase === 'applying') return T.progressApply
1926
+ return T.running
1927
+ })()
1928
+
1929
+ return h('div', { className: S.wrap },
1930
+ h('div', { className: S.head },
1931
+ h('h3', { className: S.title }, T.versionsTitle),
1932
+ h('p', { className: S.sub }, T.versionsSubtitle),
1933
+ ),
1934
+ h('div', { className: S.card },
1935
+ h('div', { className: S.vhead },
1936
+ h('input', {
1937
+ type: 'search',
1938
+ value: query,
1939
+ placeholder: T.versionsSearch,
1940
+ onChange: (event) => setQuery(event.target.value),
1941
+ className: S.search,
1942
+ style: { flex: '1 1 200px' },
1943
+ }),
1944
+ h('span', { className: S.hint }, T.versionsCount.replace('{n}', String(packages.length))),
1945
+ ),
1946
+ h('div', { className: S.meta },
1947
+ h('span', null, T.dshVersion + ': ' + (state?.dshVersion ?? '—')),
1948
+ h('span', null, T.registry + ': ' + (state?.registry === '' || !state?.registry ? T.regPnpm : state.registry)),
1949
+ ),
1950
+ progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
1951
+ hint ? h('span', { className: S.status }, hint) : null,
1952
+ loadError ? h('p', { className: S.err }, loadError) : null,
1953
+ packages.length === 0
1954
+ ? h('span', { className: S.status }, T.versionsEmpty)
1955
+ : h('div', { className: S.scrollList },
1956
+ packages.map((item) => {
1957
+ const listed = lists[item.name]
1958
+ const expanded = openName === item.name
1959
+ return h('div', { key: item.name, style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
1960
+ h('div', { className: S.row },
1961
+ h('div', { className: S.labelBox },
1962
+ h('span', { title: item.name }, item.name),
1963
+ h('span', { className: S.hint },
1964
+ T.versionsInstalled + ' ' + (item.version === '' ? '—' : item.version) +
1965
+ (listed && listed.tagVersion !== '' ? ' · ' + T.versionsLatest + ' ' + listed.tagVersion : '')),
1966
+ ),
1967
+ h('button', {
1968
+ type: 'button',
1969
+ className: expanded ? S.btn : S.btn,
1970
+ onClick: () => void openVersions(item.name),
1971
+ }, expanded ? T.versionsHide : T.versionsShow),
1972
+ ),
1973
+ expanded
1974
+ ? listed === undefined
1975
+ ? h('span', { className: S.hint }, T.versionsLoading)
1976
+ : h('div', { className: S.vlist },
1977
+ h('span', { className: S.dim }, T.versionsTotal.replace('{n}', String(listed.total ?? 0)) +
1978
+ (listed.latest !== '' ? ' · ' + T.versionsLatest + ' ' + listed.latest : '')),
1979
+ (listed.versions ?? []).map((row) => {
1980
+ const isCurrent = row.version === item.version
1981
+ const blocked = row.ok === false
1982
+ return h('div', { key: row.version, className: S.vrow },
1983
+ h('span', { className: S.vnum }, row.version),
1984
+ isCurrent ? h('span', { className: S.pivot }, T.versionsCurrent) : null,
1985
+ row.version === listed.latest && !isCurrent ? h('span', { className: S.pivot }, T.versionsLatest) : null,
1986
+ row.deprecated === true ? h('span', { className: S.dim }, T.versionsDeprecated) : null,
1987
+ blocked
1988
+ ? h('span', { className: S.bad, title: T.versionsNeed.replace('{r}', row.need || '?') }, T.versionsBlocked)
1989
+ : null,
1990
+ h('div', { className: S.vact },
1991
+ isCurrent
1992
+ ? null
1993
+ : h('button', {
1994
+ type: 'button',
1995
+ className: blocked ? S.btn : S.btnPrimary,
1996
+ disabled: blocked || busy !== '',
1997
+ title: blocked ? T.versionsNeed.replace('{r}', row.need || '?') : '',
1998
+ onClick: () => void doSwitch(item.name, row.version),
1999
+ }, busy === item.name + '@' + row.version ? T.running : T.versionsSwitch),
2000
+ ),
2001
+ )
2002
+ }),
2003
+ )
2004
+ : null,
2005
+ )
2006
+ }),
2007
+ ),
2008
+ ),
2009
+ h('span', { className: S.hint }, T.scope),
2010
+ )
2011
+ }
2012
+
1639
2013
  return {
1640
2014
  inject: ['slots'],
1641
2015
  apply(ctx) {
@@ -1664,6 +2038,15 @@ window.__ModuleLoader__.load({
1664
2038
  order: 36,
1665
2039
  label: () => T.pageLabel,
1666
2040
  }, () => h(AutoUpdateCard)))
2041
+
2042
+ // 插件页标签栏多一个「版本管理」:和设置页分工——设置页管「什么时候自动升」,
2043
+ // 这一页管「现在就要某一版」。order 2 排在「已安装/发现」(0) 和市场(1) 之后。
2044
+ ctx.slots.inject('plugins.tab', () => ctx.slots.register({
2045
+ name: 'plugins.tab',
2046
+ id: NS,
2047
+ order: 2,
2048
+ label: () => T.versionsTab,
2049
+ }, () => h(VersionsTab)))
1667
2050
  },
1668
2051
  }
1669
2052
  },