dsh-aupdate 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +33 -1
  2. package/client.js +414 -187
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -139,6 +139,12 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
139
139
  同一份界面还挂在**设置 → 插件更新**里,是独立的一页,不用先去插件页翻这张卡。
140
140
  读写走 `/api/dsh-aupdate/{state,run,rollback,logs}`。
141
141
 
142
+ 版面按 `dsh-cost-meter` 的设置页组织:一栏一栏的分区卡片、小号分区标题、浅一档的说明
143
+ 文字,主/次两级小按钮;「上一次」不再是一串用 `·` 拼起来的句子,而是三张统计卡
144
+ (上次检查 / 检查包数 / 可更新)加一个状态徽标。颜色与边框全部取自宿主主题变量
145
+ (`--dsw-alias-*`),亮色暗色都对得上;样式表只注入一次,选择器全带 `dsh-au-` 前缀,
146
+ 不碰宿主和其它插件的样式。
147
+
142
148
  ### 勾选插件,而不是手写包名
143
149
 
144
150
  `exclude` 原来要一行一个包名地敲。现在整页里是一张勾选清单,直接列出这个 profile
@@ -149,6 +155,12 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
149
155
  - 「全选 / 清空」只作用于当前筛选出来的行——搜完再点全选,意思是把搜到的都勾上
150
156
  - 这个 profile 里装着的插件都会列出来,列表本身就是「能勾什么」的全部答案
151
157
 
158
+ ### 提示不重复
159
+
160
+ 「上一次」卡片里,本轮结果的原因只出现一次:点「立刻检查」后的反馈只是一句
161
+ 「检查完成」,6 秒后自动收掉——不再把 reason 和状态词(还是英文 done)拼一遍贴在下面。
162
+ 状态词只在没有已渲染原因时作为兜底,且按当前语言显示。
163
+
152
164
  ### 关于 aupdate
153
165
 
154
166
  设置页底部有「关于 aupdate」信息组(照 Bloom 的「关于 Bloom」做):版本号(从 package.json
@@ -207,6 +219,9 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
207
219
  关掉「发现更新时提醒我」就完全不弹,日志和设置页照常记录——提醒只是别让它装完你
208
220
  还不知道,不是唯一的告知渠道。
209
221
 
222
+ 提醒卡沿用同一套版式:标题行 + `×`、可滚动的插件清单、「知道了」主按钮,按 Esc 也能关;
223
+ `prefers-reduced-motion` 下不播进场动画。
224
+
210
225
  提醒用的是原生 DOM 浮层,不是新的槽位:槽位只在宿主页挂载时才渲染,而提醒要能在
211
226
  会话、插件页、设置页都出现。
212
227
 
@@ -402,11 +417,25 @@ immediately without a restart. A number field fires per keystroke; that does not
402
417
  one request per character. The same UI is also its own page under
403
418
  **Settings → Plugin updates**, so it is not buried in the plugins page.
404
419
 
420
+ The layout follows the `dsh-cost-meter` settings page: stacked section cards, small section
421
+ headings, one-step-muted secondary text and two button tiers. "Last run" is no longer a run
422
+ of sentences glued with `·` but three stat cards (last check / packages checked / updates)
423
+ plus a status badge. Colours and borders come from the host theme variables
424
+ (`--dsw-alias-*`), so light and dark both hold; the stylesheet is injected once and every
425
+ selector is `dsh-au-` prefixed, so no host or other plugin rule is touched.
426
+
405
427
  `exclude` is a checkbox list of the plugins actually installed in this profile, with
406
428
  their installed versions, instead of a textarea you had to type package names into.
407
429
  Search narrows the list; Select all / Clear only touch the rows currently shown, so
408
430
  "search, then select all" means what you expect.
409
431
 
432
+ ### No duplicated hints
433
+
434
+ The Last run card states the outcome once. Clicking Check now only adds a short
435
+ "Check finished" acknowledgment that clears itself after six seconds — it no longer echoes
436
+ the same reason plus a raw status word underneath. Status words are a localized fallback
437
+ used only when no rendered reason exists.
438
+
410
439
  An **About aupdate** group sits at the bottom of the page (modeled on Bloom's About section):
411
440
  the version (read from package.json, so releases need no front-end edit), a changelog link,
412
441
  source repository, issue tracker, plus Star and Share (copies the project URL; the URL is
@@ -431,7 +460,10 @@ When a check finds updates, a notice appears in the bottom-right corner listing
431
460
  plugin and its current → new version; past eight it adds "and N more", and it closes
432
461
  itself after 15 seconds. Long package names are truncated on the name side so the
433
462
  versions stay visible, and past six entries the list scrolls. The Last run card on the
434
- settings page lists the same plugins and version pairs. Each batch is announced once — the signature is kept in
463
+ settings page lists the same plugins and version pairs. The notice uses the same card
464
+ language: a title row with `×`, a scrollable plugin list and a primary "Got it" button;
465
+ `Esc` closes it too, and the entrance animation is skipped under `prefers-reduced-motion`.
466
+ Each batch is announced once — the signature is kept in
435
467
  `localStorage` — and turning "Tell me when updates are found" off silences it entirely
436
468
  while the log and settings page keep recording.
437
469
 
package/client.js CHANGED
@@ -14,6 +14,49 @@ window.__ModuleLoader__.load({
14
14
  * 外链一律 target=_blank + rel=noopener noreferrer:设置页可能跑在受限
15
15
  * webview 里,noopener 防止新页反向控制本页。
16
16
  */
17
+ /**
18
+ * 状态词本地化。
19
+ *
20
+ * 后端存的是数据(done / failed / blocked…),不该直接显示在界面上。
21
+ * 只有拿不到已渲染的 reason 时的兜底路径会用到它,所以表不用很大。
22
+ */
23
+ const STATUS_LABELS = {
24
+ zh: {
25
+ done: '完成', failed: '失败', blocked: '已让开', partial: '部分完成', busy: '正在跑',
26
+ skipped: '已跳过', none: '无', ok: '成功', cancelled: '已取消', restart: '需重启',
27
+ applying: '生效中', unavailable: '不可用',
28
+ },
29
+ en: {
30
+ done: 'done', failed: 'failed', blocked: 'held off', partial: 'partly done', busy: 'busy',
31
+ skipped: 'skipped', none: 'none', ok: 'ok', cancelled: 'cancelled', restart: 'restart needed',
32
+ applying: 'applying', unavailable: 'unavailable',
33
+ },
34
+ }
35
+
36
+ function statusLabel(value) {
37
+ const table = STATUS_LABELS[LANG] ?? STATUS_LABELS.zh
38
+ return table[String(value ?? '')] ?? String(value ?? '')
39
+ }
40
+
41
+ /**
42
+ * 状态徽标配色。
43
+ *
44
+ * 后端存的是机器词(done/failed/blocked…),直接铺成一行文字看不出轻重;
45
+ * 这点颜色区分让「装完了」「失败了」「让开了」一眼能分开,文字本身仍走
46
+ * statusLabel 本地化。
47
+ */
48
+ const BADGE_TONE = {
49
+ ok: 'ok', done: 'ok',
50
+ partial: 'warn', skipped: 'warn', blocked: 'warn', restart: 'warn',
51
+ failed: 'err', error: 'err',
52
+ busy: 'run', applying: 'run',
53
+ }
54
+
55
+ function badgeClass(status) {
56
+ const tone = BADGE_TONE[String(status ?? '')]
57
+ return tone ? S.badge + ' ' + tone : S.badge
58
+ }
59
+
17
60
  const REPO_URL = 'https://github.com/CalmSun/dsh-aupdate'
18
61
  const CHANGELOG_URL = REPO_URL + '/releases'
19
62
  const ISSUES_URL = REPO_URL + '/issues/new'
@@ -23,6 +66,10 @@ window.__ModuleLoader__.load({
23
66
  zh: {
24
67
  title: '插件自动更新',
25
68
  subtitle: '定时检查 registry,发现新版本就装好并就地生效',
69
+ secGeneral: '基本设置',
70
+ secSchedule: '调度与范围',
71
+ lastChecked: '上次检查',
72
+ lastUpdates: '可更新',
26
73
  unavailable: '读不到设置:后端路由没起来(插件仍会按默认设置自动更新)',
27
74
  retry: '重试',
28
75
  save: '保存',
@@ -37,6 +84,7 @@ window.__ModuleLoader__.load({
37
84
  progressApply: '正在就地生效…',
38
85
  runDone: '检查完成',
39
86
  runFailed: '检查没能完成',
87
+ off: '已关闭',
40
88
  lastRun: '上一次',
41
89
  never: '还没跑过',
42
90
  checked: '检查了',
@@ -156,6 +204,10 @@ window.__ModuleLoader__.load({
156
204
  en: {
157
205
  title: 'Plugin auto-update',
158
206
  subtitle: 'Checks the registry on a timer and applies new versions in place',
207
+ secGeneral: 'Basics',
208
+ secSchedule: 'Schedule and scope',
209
+ lastChecked: 'Last check',
210
+ lastUpdates: 'Updates',
159
211
  unavailable: 'Cannot read settings: the backend route is not up (defaults still apply)',
160
212
  retry: 'Retry',
161
213
  save: 'Save',
@@ -170,6 +222,7 @@ window.__ModuleLoader__.load({
170
222
  progressApply: 'Applying in place…',
171
223
  runDone: 'Check finished',
172
224
  runFailed: 'Check could not finish',
225
+ off: 'off',
173
226
  lastRun: 'Last run',
174
227
  never: 'never',
175
228
  checked: 'checked',
@@ -470,45 +523,158 @@ window.__ModuleLoader__.load({
470
523
  return response.json()
471
524
  }
472
525
 
473
- /* ── styles: kept inline so the page needs no build step ───────────── */
474
- const S = {
475
- wrap: { display: 'flex', flexDirection: 'column', gap: '14px', padding: '4px 2px', fontSize: '13px', lineHeight: 1.5 },
476
- head: { display: 'flex', flexDirection: 'column', gap: '2px' },
477
- title: { fontSize: '14px', fontWeight: 600, margin: 0 },
478
- sub: { opacity: 0.62, fontSize: '12px', margin: 0 },
479
- card: { border: '1px solid rgba(128,128,128,0.22)', borderRadius: '8px', padding: '12px', display: 'flex', flexDirection: 'column', gap: '10px' },
480
- row: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: '12px' },
481
- labelBox: { display: 'flex', flexDirection: 'column', gap: '1px', minWidth: 0 },
482
- label: { fontWeight: 500 },
483
- hint: { opacity: 0.55, fontSize: '11.5px' },
484
- input: { width: '96px', padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '13px', textAlign: 'right' },
485
- area: { width: '100%', minHeight: '58px', padding: '6px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '12.5px', fontFamily: 'inherit', resize: 'vertical' },
486
- // select 的宽度比数字框宽:四种模式的中文标签最长「每天固定时刻」。
487
- select: { padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '13px', minWidth: '132px' },
488
- actions: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' },
489
- btn: { padding: '5px 12px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', cursor: 'pointer', fontSize: '13px' },
490
- btnPrimary: { padding: '5px 12px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'rgba(128,128,128,0.16)', color: 'inherit', cursor: 'pointer', fontSize: '13px', fontWeight: 500 },
491
- status: { fontSize: '12px', opacity: 0.7 },
492
- err: { fontSize: '12px', color: '#d9534f' },
493
- meta: { display: 'flex', gap: '14px', flexWrap: 'wrap', fontSize: '12px', opacity: 0.7 },
494
- // 等宽 + 可滚动:日志要能对齐看时间戳,也不能把整页顶长。
495
- logBox: { margin: 0, padding: '8px 10px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.22)', background: 'rgba(128,128,128,0.06)', fontSize: '11.5px', lineHeight: 1.55, fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace', maxHeight: '260px', overflow: 'auto', whiteSpace: 'pre-wrap', wordBreak: 'break-word' },
496
- logTime: { opacity: 0.5, flexShrink: 0, fontVariantNumeric: 'tabular-nums' },
497
- logText: {},
498
- // 勾选清单:包名可能很长(@scope/name),要能截断,版本靠右对齐。
499
- // 更新记录可能上百条,不封高度会把整页顶到几屏之外,滚动条交还给这一栏。
500
- scrollList: { display: 'flex', flexDirection: 'column', gap: '8px', maxHeight: '260px', overflowY: 'auto', paddingRight: '4px' },
501
- pkgList: { display: 'flex', flexDirection: 'column', gap: '1px', maxHeight: '240px', overflow: 'auto', border: '1px solid rgba(128,128,128,0.22)', borderRadius: '6px', padding: '4px' },
502
- pkgRow: { display: 'flex', alignItems: 'center', gap: '8px', padding: '2px 4px', borderRadius: '4px', cursor: 'pointer' },
503
- pkgName: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
504
- pkgVer: { opacity: 0.5, fontSize: '11px', marginLeft: 'auto', flexShrink: 0 },
505
- search: { padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '12.5px' },
506
- // 「关于」组:外链靠右等宽、↗ 与文字同色但更淡,避免整行像按钮。
507
- link: { color: 'inherit', textDecoration: 'none', borderBottom: '1px solid rgba(128,128,128,0.4)', paddingBottom: '1px' },
508
- linkExt: { opacity: 0.5, marginLeft: '3px' },
509
- ver: { fontVariantNumeric: 'tabular-nums', opacity: 0.8 },
526
+ /* ── styles ─────────────────────────────────────────────────────────
527
+ *
528
+ * 视觉风格对齐 dsh-cost-meter 的设置页:分区卡片、小号分区标题、次级说明
529
+ * 文字、主/次两级小按钮、右下角通知卡;颜色一律走 --dsw-alias-* 主题变量
530
+ * 并带字面量回退,取不到变量也不会变成看不见的字。
531
+ *
532
+ * 原来每个节点都挂一坨内联 style,代价有三:
533
+ * - hover / focus-visible / 动画做不了(内联样式没有伪类);
534
+ * - 每次渲染重建几十个样式对象,输入框每敲一个字符就重建一次;
535
+ * - 颜色写死 rgba,亮色/暗色主题只能靠碰运气。
536
+ *
537
+ * 所以改成「一张只注入一次的样式表 + 类名」。选择器全部带 dsh-au- 前缀,
538
+ * 只作用于本插件自己的节点,不碰宿主和其它插件的样式。
539
+ */
540
+ const CSS_ID = 'dsh-aupdate-styles'
541
+
542
+ const CSS_TEXT = `
543
+ .dsh-au-wrap{display:flex;flex-direction:column;gap:16px;padding:2px 0;font-size:13px;line-height:1.5;color:var(--dsw-alias-label-primary,#1f2328)}
544
+ .dsh-au-head{display:flex;flex-direction:column;gap:3px}
545
+ .dsh-au-title{margin:0;font-size:15px;font-weight:600}
546
+ .dsh-au-sub{margin:0;font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
547
+
548
+ .dsh-au-section{display:flex;flex-direction:column;gap:10px;padding:14px 15px;border-radius:12px;border:1px solid var(--dsw-alias-border-l1,rgba(128,128,128,.22));background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.03))}
549
+ .dsh-au-h{margin:0;font-size:12px;font-weight:600;letter-spacing:.01em;color:var(--dsw-alias-label-secondary,rgba(128,128,128,1))}
550
+ .dsh-au-note{margin:0;font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
551
+ .dsh-au-err{margin:0;font-size:12px;color:var(--dsw-alias-state-error-primary,#d9534f)}
552
+
553
+ .dsh-au-row{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
554
+ .dsh-au-col{display:flex;flex-direction:column;gap:6px}
555
+ .dsh-au-line{display:flex;align-items:baseline;gap:8px}
556
+ .dsh-au-labelbox{display:flex;flex-direction:column;gap:1px;min-width:0}
557
+ .dsh-au-label{font-weight:500}
558
+ .dsh-au-hint{font-size:11.5px;color:var(--dsw-alias-label-caption,rgba(128,128,128,.85))}
559
+ .dsh-au-status{font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
560
+ .dsh-au-meta{display:flex;gap:12px;flex-wrap:wrap;font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
561
+ .dsh-au-num{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary,inherit)}
562
+
563
+ .dsh-au-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(152px,1fr));gap:10px}
564
+ .dsh-au-stat{display:flex;flex-direction:column;gap:1px;padding:10px 12px;border-radius:10px;border:1px solid var(--dsw-alias-border-l1,rgba(128,128,128,.22));background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.05))}
565
+ .dsh-au-stat-k{font-size:11.5px;color:var(--dsw-alias-label-caption,rgba(128,128,128,.85))}
566
+ .dsh-au-stat-v{font-size:17px;font-weight:600;font-variant-numeric:tabular-nums;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
567
+
568
+ .dsh-au-badge{display:inline-flex;align-items:center;align-self:flex-start;gap:4px;padding:1px 8px;border-radius:999px;font-size:11px;line-height:1.6;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));color:var(--dsw-alias-label-secondary,inherit)}
569
+ .dsh-au-badge.ok{color:var(--dsw-alias-state-success-primary,#2f9e44);border-color:var(--dsw-alias-state-success-tertiary,rgba(47,158,68,.4));background:color-mix(in oklch,var(--dsw-alias-state-success-primary,#2f9e44),transparent 90%)}
570
+ .dsh-au-badge.warn{color:var(--dsw-alias-state-warn-primary,#b8860b);border-color:var(--dsw-alias-state-warn-tertiary,rgba(184,134,11,.4));background:color-mix(in oklch,var(--dsw-alias-state-warn-primary,#b8860b),transparent 90%)}
571
+ .dsh-au-badge.err{color:var(--dsw-alias-state-error-primary,#d9534f);border-color:color-mix(in oklch,var(--dsw-alias-state-error-primary,#d9534f),transparent 55%);background:color-mix(in oklch,var(--dsw-alias-state-error-primary,#d9534f),transparent 90%)}
572
+ .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
+
574
+ .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
+ .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}
577
+ .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}
580
+
581
+ .dsh-au-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
582
+ .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}
583
+ .dsh-au-btn:hover:not(:disabled){background:var(--dsw-alias-bg-mask-2,rgba(128,128,128,.12))}
584
+ .dsh-au-btn:active:not(:disabled){background:var(--dsw-alias-bg-mask-3,rgba(128,128,128,.18))}
585
+ .dsh-au-btn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4d6bfe);outline-offset:1px}
586
+ .dsh-au-btn:disabled{opacity:.5;cursor:default}
587
+ .dsh-au-primary{background:var(--dsw-alias-button-primary-fill,#4d6bfe);border-color:transparent;color:var(--dsw-alias-label-primary-foreground,#fff);font-weight:500}
588
+ .dsh-au-primary:hover:not(:disabled){background:color-mix(in oklch,var(--dsw-alias-button-primary-fill,#4d6bfe),black 8%)}
589
+ .dsh-au-primary:active:not(:disabled){background:color-mix(in oklch,var(--dsw-alias-button-primary-fill,#4d6bfe),black 14%)}
590
+
591
+ .dsh-au-check{flex:0 0 auto;width:16px;height:16px;margin:2px 0 0;cursor:pointer;accent-color:var(--dsw-alias-state-business-primary,#4d6bfe)}
592
+ .dsh-au-check:disabled{cursor:default;opacity:.5}
593
+
594
+ .dsh-au-scroll{display:flex;flex-direction:column;gap:6px;max-height:264px;overflow-y:auto;padding-right:4px}
595
+ .dsh-au-pkglist{display:flex;flex-direction:column;gap:1px;max-height:240px;overflow:auto;border:1px solid var(--dsw-alias-border-l1,rgba(128,128,128,.22));border-radius:10px;padding:4px}
596
+ .dsh-au-pkgrow{display:flex;align-items:center;gap:8px;padding:3px 6px;border-radius:6px;cursor:pointer}
597
+ .dsh-au-pkgrow:hover{background:var(--dsw-alias-bg-mask-1,rgba(128,128,128,.08))}
598
+ .dsh-au-pkgname{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
599
+ .dsh-au-pkgver{flex:0 0 auto;margin-left:auto;font-size:11px;color:var(--dsw-alias-label-caption,rgba(128,128,128,.85));font-variant-numeric:tabular-nums}
600
+ .dsh-au-log{margin:0;padding:8px 10px;border-radius:10px;border:1px solid var(--dsw-alias-border-l1,rgba(128,128,128,.22));background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.06));font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;line-height:1.6;max-height:288px;overflow:auto;white-space:pre-wrap;word-break:break-word}
601
+ .dsh-au-logtime{color:var(--dsw-alias-label-caption,rgba(128,128,128,.8));font-variant-numeric:tabular-nums}
602
+ .dsh-au-logtext{color:inherit}
603
+
604
+ .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
+ .dsh-au-link:hover{color:var(--dsw-alias-state-business-primary,#4d6bfe);border-color:currentColor}
606
+ .dsh-au-linkext{margin-left:3px;opacity:.5}
607
+
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}
612
+ .dsh-au-toast-x:hover{opacity:1;background:var(--dsw-alias-bg-mask-2,rgba(128,128,128,.14))}
613
+ .dsh-au-toast-list{display:flex;flex-direction:column;gap:2px;max-height:190px;overflow:auto;margin:0 -4px}
614
+ .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}
616
+ .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
+ .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}}
620
+ @media (prefers-reduced-motion:reduce){.dsh-au-toast{animation:none}}
621
+ `
622
+
623
+ /** 只注入一次:id 存在就跳过,重复挂载/热更新都不会叠出第二份样式表。 */
624
+ function installStyles() {
625
+ try {
626
+ const doc = typeof document === 'undefined' ? null : document
627
+ if (doc === null || doc.head === null) return
628
+ if (doc.getElementById(CSS_ID) !== null) return
629
+ const tag = doc.createElement('style')
630
+ tag.id = CSS_ID
631
+ tag.setAttribute('data-dsh-aupdate', 'styles')
632
+ tag.textContent = CSS_TEXT
633
+ doc.head.appendChild(tag)
634
+ } catch {}
510
635
  }
511
636
 
637
+ /* 类名映射:组件里写 S.card 就等于挂上 dsh-au-section。 */
638
+ const S = {
639
+ wrap: 'dsh-au-wrap',
640
+ head: 'dsh-au-head',
641
+ title: 'dsh-au-title',
642
+ sub: 'dsh-au-sub',
643
+ card: 'dsh-au-section',
644
+ h: 'dsh-au-h',
645
+ note: 'dsh-au-note',
646
+ row: 'dsh-au-row',
647
+ labelBox: 'dsh-au-labelbox',
648
+ label: 'dsh-au-label',
649
+ hint: 'dsh-au-hint',
650
+ input: 'dsh-au-input',
651
+ area: 'dsh-au-area',
652
+ select: 'dsh-au-select',
653
+ search: 'dsh-au-search',
654
+ actions: 'dsh-au-actions',
655
+ btn: 'dsh-au-btn',
656
+ btnPrimary: 'dsh-au-btn dsh-au-primary',
657
+ status: 'dsh-au-status',
658
+ err: 'dsh-au-err',
659
+ meta: 'dsh-au-meta',
660
+ cards: 'dsh-au-cards',
661
+ stat: 'dsh-au-stat',
662
+ statK: 'dsh-au-stat-k',
663
+ statV: 'dsh-au-stat-v',
664
+ badge: 'dsh-au-badge',
665
+ check: 'dsh-au-check',
666
+ logBox: 'dsh-au-log',
667
+ logTime: 'dsh-au-logtime',
668
+ logText: 'dsh-au-logtext',
669
+ scrollList: 'dsh-au-scroll',
670
+ pkgList: 'dsh-au-pkglist',
671
+ pkgRow: 'dsh-au-pkgrow',
672
+ pkgName: 'dsh-au-pkgname',
673
+ pkgVer: 'dsh-au-pkgver',
674
+ link: 'dsh-au-link',
675
+ linkExt: 'dsh-au-linkext',
676
+ ver: 'dsh-au-num',
677
+ }
512
678
  function Toggle(props) {
513
679
  const { checked, onChange, disabled } = props
514
680
  return h('input', {
@@ -516,16 +682,16 @@ window.__ModuleLoader__.load({
516
682
  checked: checked === true,
517
683
  disabled: disabled === true,
518
684
  onChange: (event) => onChange(event.target.checked),
519
- style: { width: '16px', height: '16px', cursor: disabled === true ? 'default' : 'pointer', accentColor: 'currentColor', marginTop: '2px' },
685
+ className: S.check,
520
686
  })
521
687
  }
522
688
 
523
689
  function SwitchRow(props) {
524
690
  const { label, hint, value, onChange, disabled } = props
525
- return h('div', { style: S.row },
526
- h('div', { style: S.labelBox },
527
- h('span', { style: S.label }, label),
528
- hint ? h('span', { style: S.hint }, hint) : null,
691
+ return h('div', { className: S.row },
692
+ h('div', { className: S.labelBox },
693
+ h('span', { className: S.label }, label),
694
+ hint ? h('span', { className: S.hint }, hint) : null,
529
695
  ),
530
696
  h(Toggle, { checked: value, onChange, disabled }),
531
697
  )
@@ -533,10 +699,10 @@ window.__ModuleLoader__.load({
533
699
 
534
700
  function NumberRow(props) {
535
701
  const { label, hint, value, onChange, min, max, disabled } = props
536
- return h('div', { style: S.row },
537
- h('div', { style: S.labelBox },
538
- h('span', { style: S.label }, label),
539
- hint ? h('span', { style: S.hint }, hint) : null,
702
+ return h('div', { className: S.row },
703
+ h('div', { className: S.labelBox },
704
+ h('span', { className: S.label }, label),
705
+ hint ? h('span', { className: S.hint }, hint) : null,
540
706
  ),
541
707
  h('input', {
542
708
  type: 'number',
@@ -548,7 +714,7 @@ window.__ModuleLoader__.load({
548
714
  const next = Number(event.target.value)
549
715
  if (Number.isFinite(next)) onChange(next)
550
716
  },
551
- style: S.input,
717
+ className: S.input,
552
718
  }),
553
719
  )
554
720
  }
@@ -559,17 +725,17 @@ window.__ModuleLoader__.load({
559
725
  */
560
726
  function ClockRow(props) {
561
727
  const { label, hint, value, onChange, disabled } = props
562
- return h('div', { style: S.row },
563
- h('div', { style: S.labelBox },
564
- h('span', { style: S.label }, label),
565
- hint ? h('span', { style: S.hint }, hint) : null,
728
+ return h('div', { className: S.row },
729
+ h('div', { className: S.labelBox },
730
+ h('span', { className: S.label }, label),
731
+ hint ? h('span', { className: S.hint }, hint) : null,
566
732
  ),
567
733
  h('input', {
568
734
  type: 'time',
569
735
  value: typeof value === 'string' ? value : '03:00',
570
736
  disabled: disabled === true,
571
737
  onChange: (event) => onChange(event.target.value),
572
- style: S.input,
738
+ className: S.input,
573
739
  }),
574
740
  )
575
741
  }
@@ -582,16 +748,16 @@ window.__ModuleLoader__.load({
582
748
  */
583
749
  function SelectRow(props) {
584
750
  const { label, hint, value, options, onChange, disabled } = props
585
- return h('div', { style: S.row },
586
- h('div', { style: S.labelBox },
587
- h('span', { style: S.label }, label),
588
- hint ? h('span', { style: S.hint }, hint) : null,
751
+ return h('div', { className: S.row },
752
+ h('div', { className: S.labelBox },
753
+ h('span', { className: S.label }, label),
754
+ hint ? h('span', { className: S.hint }, hint) : null,
589
755
  ),
590
756
  h('select', {
591
757
  value,
592
758
  disabled: disabled === true,
593
759
  onChange: (event) => onChange(event.target.value),
594
- style: S.select,
760
+ className: S.select,
595
761
  }, options.map((option) => h('option', { key: option.value, value: option.value }, option.label))),
596
762
  )
597
763
  }
@@ -615,8 +781,8 @@ window.__ModuleLoader__.load({
615
781
  if (typeof gate.lock === 'string' && gate.lock !== '') {
616
782
  parts.push(T.gateLocked.replace('{who}', gate.lock))
617
783
  }
618
- return h('div', { style: S.labelBox },
619
- h('span', { style: S.hint }, parts.join(' · ')),
784
+ return h('div', { className: S.labelBox },
785
+ h('span', { className: S.hint }, parts.join(' · ')),
620
786
  )
621
787
  }
622
788
 
@@ -659,30 +825,31 @@ window.__ModuleLoader__.load({
659
825
  commit(next)
660
826
  }
661
827
 
662
- if (all.length === 0) return h('span', { style: S.status }, T.pkgsEmpty)
828
+ if (all.length === 0) return h('span', { className: S.status }, T.pkgsEmpty)
663
829
 
664
- return h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
665
- h('div', { style: S.actions },
830
+ return h('div', { className: 'dsh-au-col' },
831
+ h('div', { className: S.actions },
666
832
  h('input', {
667
833
  type: 'search',
668
834
  value: query,
669
835
  placeholder: T.pkgsSearch,
670
836
  onChange: (event) => setQuery(event.target.value),
671
- style: { ...S.search, flex: '1 1 160px' },
837
+ className: S.search,
838
+ style: { flex: '1 1 160px' },
672
839
  }),
673
- h('button', { type: 'button', style: S.btn, onClick: () => setVisible(true) }, T.pkgsAll),
674
- h('button', { type: 'button', style: S.btn, onClick: () => setVisible(false) }, T.pkgsNone),
675
- h('span', { style: S.hint }, T.pkgsCount.replace('{n}', String(chosen.size))),
840
+ h('button', { type: 'button', className: S.btn, onClick: () => setVisible(true) }, T.pkgsAll),
841
+ h('button', { type: 'button', className: S.btn, onClick: () => setVisible(false) }, T.pkgsNone),
842
+ h('span', { className: S.hint }, T.pkgsCount.replace('{n}', String(chosen.size))),
676
843
  ),
677
- h('div', { style: S.pkgList },
844
+ h('div', { className: S.pkgList },
678
845
  rows.length === 0
679
- ? h('span', { style: { ...S.status, padding: '4px' } }, T.pkgsNoMatch)
680
- : rows.map((item) => h('label', { key: item.name, style: S.pkgRow, title: item.name },
846
+ ? h('span', { className: S.status, style: { padding: '4px' } }, T.pkgsNoMatch)
847
+ : rows.map((item) => h('label', { key: item.name, className: S.pkgRow, title: item.name },
681
848
  h(Toggle, { checked: chosen.has(item.name), onChange: () => toggle(item.name) }),
682
- h('span', { style: S.pkgName }, item.name),
849
+ h('span', { className: S.pkgName }, item.name),
683
850
  item.version === ''
684
- ? h('span', { style: S.pkgVer }, T.pkgsNotInstalled)
685
- : h('span', { style: S.pkgVer }, item.version),
851
+ ? h('span', { className: S.pkgVer }, T.pkgsNotInstalled)
852
+ : h('span', { className: S.pkgVer }, item.version),
686
853
  )),
687
854
  ),
688
855
  )
@@ -706,8 +873,8 @@ window.__ModuleLoader__.load({
706
873
  href,
707
874
  target: '_blank',
708
875
  rel: 'noopener noreferrer',
709
- style: S.link,
710
- }, label, h('span', { style: S.linkExt, 'aria-hidden': 'true' }, '↗'))
876
+ className: S.link,
877
+ }, label, h('span', { className: S.linkExt, 'aria-hidden': 'true' }, '↗'))
711
878
 
712
879
  const share = async () => {
713
880
  try {
@@ -722,44 +889,44 @@ window.__ModuleLoader__.load({
722
889
  }
723
890
  }
724
891
 
725
- return h('div', { style: S.card },
726
- h('span', { style: S.label }, T.about),
727
- h('div', { style: S.row },
728
- h('span', { style: S.label }, T.aboutVersion),
729
- h('span', { style: S.ver }, version === '' ? '…' : 'v' + version),
892
+ return h('div', { className: S.card },
893
+ h('h3', { className: S.h }, T.about),
894
+ h('div', { className: S.row },
895
+ h('span', { className: S.label }, T.aboutVersion),
896
+ h('span', { className: S.ver }, version === '' ? '…' : 'v' + version),
730
897
  ),
731
- h('div', { style: S.row },
732
- h('span', { style: S.label }, T.aboutChangelog),
898
+ h('div', { className: S.row },
899
+ h('span', { className: S.label }, T.aboutChangelog),
733
900
  extLink(CHANGELOG_URL, T.aboutChangelogLink),
734
901
  ),
735
- h('div', { style: S.row },
736
- h('span', { style: S.label }, T.aboutRepo),
902
+ h('div', { className: S.row },
903
+ h('span', { className: S.label }, T.aboutRepo),
737
904
  extLink(REPO_URL, 'GitHub'),
738
905
  ),
739
- h('div', { style: S.row },
740
- h('span', { style: S.label }, T.aboutFeedback),
906
+ h('div', { className: S.row },
907
+ h('span', { className: S.label }, T.aboutFeedback),
741
908
  extLink(ISSUES_URL, T.aboutFeedbackLink),
742
909
  ),
743
- h('div', { style: S.row },
744
- h('span', { style: S.labelBox },
745
- h('span', { style: S.label }, T.aboutStar),
746
- h('span', { style: S.hint }, T.aboutStarHint),
910
+ h('div', { className: S.row },
911
+ h('span', { className: S.labelBox },
912
+ h('span', { className: S.label }, T.aboutStar),
913
+ h('span', { className: S.hint }, T.aboutStarHint),
747
914
  ),
748
915
  extLink(STARS_URL, 'GitHub'),
749
916
  ),
750
- h('div', { style: S.row },
751
- h('span', { style: S.labelBox },
752
- h('span', { style: S.label }, T.aboutShare),
753
- h('span', { style: S.hint }, T.aboutShareHint),
917
+ h('div', { className: S.row },
918
+ h('span', { className: S.labelBox },
919
+ h('span', { className: S.label }, T.aboutShare),
920
+ h('span', { className: S.hint }, T.aboutShareHint),
754
921
  ),
755
- h('button', { type: 'button', style: S.btn, onClick: () => void share() }, T.aboutShare),
922
+ h('button', { type: 'button', className: S.btn, onClick: () => void share() }, T.aboutShare),
756
923
  ),
757
924
  // 项目地址可点开、可选中复制,失败时用户还有这一条路。
758
- h('div', { style: S.row },
759
- h('span', { style: S.label }, T.aboutProject),
925
+ h('div', { className: S.row },
926
+ h('span', { className: S.label }, T.aboutProject),
760
927
  extLink(REPO_URL, REPO_URL.replace('https://', '')),
761
928
  ),
762
- shareHint ? h('span', { style: S.status }, shareHint) : null,
929
+ shareHint ? h('span', { className: S.status }, shareHint) : null,
763
930
  )
764
931
  }
765
932
 
@@ -893,9 +1060,12 @@ window.__ModuleLoader__.load({
893
1060
  // 进度由上面的常驻轮询统一负责,这里只发请求。
894
1061
  const result = await runNow('update')
895
1062
  if (result?.started === false) {
1063
+ // 「已经有一轮在跑」这类信息在「上一次」里没有,必须显示。
896
1064
  setRunHint(result.reason || T.runFailed)
897
1065
  } else {
898
- setRunHint((result?.reason || T.runDone) + ' · ' + (result?.status ?? ''))
1066
+ // 只给一句「检查完成」。原因和状态已经写进「上一次」那张卡,
1067
+ // 这里再拼一遍 reason + status 会和它逐字重复(还有英文 done)。
1068
+ setRunHint(T.runDone)
899
1069
  }
900
1070
  // 跑完把状态刷一遍,页面上看到的就是最新结果。
901
1071
  try {
@@ -911,6 +1081,14 @@ window.__ModuleLoader__.load({
911
1081
  }
912
1082
  }, [running])
913
1083
 
1084
+ // 结束提示只是一次性反馈:6 秒后自己收掉,免得它一直挂在卡片里,
1085
+ // 和下面「上一次」的原因并列成两段一样的文字。
1086
+ useEffect(() => {
1087
+ if (running || runHint === '') return undefined
1088
+ const timer = setTimeout(() => setRunHint(''), 6000)
1089
+ return () => clearTimeout(timer)
1090
+ }, [running, runHint])
1091
+
914
1092
  const doCleanup = useCallback(async () => {
915
1093
  if (cleaning) return
916
1094
  setCleaning(true)
@@ -957,24 +1135,25 @@ window.__ModuleLoader__.load({
957
1135
  }, [rolling, running, confirming])
958
1136
 
959
1137
  if (phase === 'error') {
960
- return h('div', { style: S.card },
961
- h('span', { style: S.err }, T.unavailable),
962
- h('div', { style: S.actions }, h('button', { type: 'button', style: S.btn, onClick: () => void load() }, T.retry)),
1138
+ return h('div', { className: S.card },
1139
+ h('span', { className: S.err }, T.unavailable),
1140
+ h('div', { className: S.actions }, h('button', { type: 'button', className: S.btn, onClick: () => void load() }, T.retry)),
963
1141
  )
964
1142
  }
965
1143
 
966
1144
  if (phase === 'loading' || draft === null) {
967
- return h('div', { style: S.card }, h('span', { style: S.status }, '…'))
1145
+ return h('div', { className: S.card }, h('span', { className: S.status }, '…'))
968
1146
  }
969
1147
 
970
1148
  const last = state?.lastRun
971
1149
 
972
- return h('div', { style: S.wrap },
973
- h('div', { style: S.head },
974
- h('h3', { style: S.title }, T.title),
975
- h('p', { style: S.sub }, T.subtitle),
1150
+ return h('div', { className: S.wrap },
1151
+ h('div', { className: S.head },
1152
+ h('h3', { className: S.title }, T.title),
1153
+ h('p', { className: S.sub }, T.subtitle),
976
1154
  ),
977
- h('div', { style: S.card },
1155
+ h('div', { className: S.card },
1156
+ h('h3', { className: S.h }, T.secGeneral),
978
1157
  h(SelectRow, {
979
1158
  label: T.language,
980
1159
  hint: T.languageHint,
@@ -999,7 +1178,8 @@ window.__ModuleLoader__.load({
999
1178
  h(SwitchRow, { label: T.idleOnly, hint: T.idleOnlyHint, value: draft.idleOnly, onChange: (v) => patch('idleOnly', v), disabled: !draft.enabled }),
1000
1179
  h(SwitchRow, { label: T.notify, hint: T.notifyHint, value: draft.notify, onChange: (v) => patch('notify', v) }),
1001
1180
  ),
1002
- h('div', { style: S.card },
1181
+ h('div', { className: S.card },
1182
+ h('h3', { className: S.h }, T.secSchedule),
1003
1183
  h(SelectRow, {
1004
1184
  label: T.schedule,
1005
1185
  hint: T.scheduleHint,
@@ -1031,9 +1211,9 @@ window.__ModuleLoader__.load({
1031
1211
  h(NumberRow, { label: T.maxPerCycle, hint: T.maxPerCycleHint, value: draft.maxPerCycle, min: 0, max: 50, onChange: (v) => patch('maxPerCycle', v), disabled: !draft.enabled }),
1032
1212
  h(NumberRow, { label: T.sessionIdle, hint: T.sessionIdleHint, value: draft.sessionIdleMinutes, min: 0, max: 120, onChange: (v) => patch('sessionIdleMinutes', v), disabled: !draft.enabled || !draft.idleOnly }),
1033
1213
  gateLine(state),
1034
- h('div', { style: S.labelBox },
1035
- h('span', { style: S.label }, T.pkgsExclude),
1036
- h('span', { style: S.hint }, T.pkgsExcludeHint),
1214
+ h('div', { className: S.labelBox },
1215
+ h('span', { className: S.label }, T.pkgsExclude),
1216
+ h('span', { className: S.hint }, T.pkgsExcludeHint),
1037
1217
  ),
1038
1218
  h(PackagePicker, {
1039
1219
  packages: state?.packages,
@@ -1042,14 +1222,14 @@ window.__ModuleLoader__.load({
1042
1222
  }),
1043
1223
  ),
1044
1224
  // 策略:预发布 / 跨大版本,决定「什么算可以装」。
1045
- h('div', { style: S.card },
1046
- h('span', { style: S.label }, T.policy),
1225
+ h('div', { className: S.card },
1226
+ h('h3', { className: S.h }, T.policy),
1047
1227
  h(SwitchRow, { label: T.allowMajor, hint: T.allowMajorHint, value: draft.allowMajor, onChange: (v) => patch('allowMajor', v) }),
1048
1228
  h(SwitchRow, { label: T.allowPrerelease, hint: T.allowPrereleaseHint, value: draft.allowPrerelease, onChange: (v) => patch('allowPrerelease', v) }),
1049
1229
  ),
1050
- h('div', { style: S.card },
1051
- h('span', { style: S.label }, T.keepTitle),
1052
- h('span', { style: S.hint }, T.keepHint),
1230
+ h('div', { className: S.card },
1231
+ h('h3', { className: S.h }, T.keepTitle),
1232
+ h('p', { className: S.note }, T.keepHint),
1053
1233
  h(SelectRow, {
1054
1234
  label: T.keepHistory,
1055
1235
  value: String(draft.historyRetentionDays ?? 3),
@@ -1076,31 +1256,52 @@ window.__ModuleLoader__.load({
1076
1256
  { value: '0', label: T.keepForever },
1077
1257
  ],
1078
1258
  }),
1079
- h('div', { style: S.actions },
1080
- h('button', { type: 'button', style: S.btn, disabled: cleaning, onClick: () => void doCleanup() }, cleaning ? T.cleaning : T.cleanNow),
1081
- cleanHint ? h('span', { style: S.status }, cleanHint) : null,
1259
+ h('div', { className: S.actions },
1260
+ h('button', { type: 'button', className: S.btn, disabled: cleaning, onClick: () => void doCleanup() }, cleaning ? T.cleaning : T.cleanNow),
1261
+ cleanHint ? h('span', { className: S.status }, cleanHint) : null,
1082
1262
  ),
1083
1263
  ),
1084
- h('div', { style: S.card },
1264
+ h('div', { className: S.card },
1085
1265
  // 按钮和它动作的对象放在一起:读「上一次」的人最想做的事就是再跑一次。
1086
- h('div', { style: S.row },
1087
- h('span', { style: S.label }, T.lastRun),
1088
- h('button', { type: 'button', style: S.btn, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
1266
+ h('div', { className: S.row },
1267
+ h('div', { className: S.labelBox },
1268
+ h('h3', { className: S.h }, T.lastRun),
1269
+ last === null || last === undefined ? h('span', { className: S.hint }, T.never) : null,
1270
+ ),
1271
+ h('button', { type: 'button', className: S.btnPrimary, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
1089
1272
  ),
1090
1273
  // 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
1091
- progress
1092
- ? h('span', { style: { ...S.status, color: '#4c9aff', fontWeight: 500 } }, runningText)
1093
- : null,
1094
- last === null || last === undefined
1095
- ? h('span', { style: S.status }, T.never)
1096
- : h('div', { style: S.meta },
1097
- h('span', { title: last.at || '' }, formatWhen(last.at) + (relativeWhen(last.at) ? '(' + relativeWhen(last.at) + ')' : '')),
1098
- h('span', null, T.checked + ' ' + (last.checked ?? 0) + ' ' + T.packages),
1099
- h('span', null, (last.updates?.length ?? 0) > 0
1100
- ? (last.updates?.length ?? 0) + ' ' + T.updates
1101
- : T.upToDate),
1102
- h('span', null, last.reason || last.status || ''),
1103
- ),
1274
+ progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
1275
+ // 三张统计卡,照 cost-meter 概览页的写法:一眼看到「什么时候查的、
1276
+ // 查了多少、几个能更」,而不是一串用 · 拼起来的句子。
1277
+ last === null || last === undefined ? null : h('div', { className: S.cards },
1278
+ h('div', { className: S.stat },
1279
+ h('span', { className: S.statK }, T.lastChecked),
1280
+ h('span', { className: S.statV, title: last.at || '' }, formatWhen(last.at) || '—'),
1281
+ relativeWhen(last.at) ? h('span', { className: S.hint }, relativeWhen(last.at)) : null,
1282
+ ),
1283
+ h('div', { className: S.stat },
1284
+ h('span', { className: S.statK }, T.checked),
1285
+ h('span', { className: S.statV }, String(last.checked ?? 0)),
1286
+ h('span', { className: S.hint }, T.packages),
1287
+ ),
1288
+ 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),
1292
+ ),
1293
+ ),
1294
+ // 原因只说一遍:徽标承接状态词,正文承接句子,两者不重复同一句话。
1295
+ (() => {
1296
+ if (last === null || last === undefined) return null
1297
+ const reason = typeof last.reason === 'string' ? last.reason : ''
1298
+ const status = statusLabel(last.status)
1299
+ if (reason === '' && status === '') return null
1300
+ return h('div', { className: S.row },
1301
+ reason === '' ? null : h('span', { className: S.note }, reason),
1302
+ status === '' ? null : h('span', { className: badgeClass(last.status) }, status),
1303
+ )
1304
+ })(),
1104
1305
  // 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
1105
1306
  // 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
1106
1307
  (() => {
@@ -1108,31 +1309,31 @@ window.__ModuleLoader__.load({
1108
1309
  .map((item) => describeUpdate(item))
1109
1310
  .filter((row) => row !== null)
1110
1311
  if (rows.length === 0) return null
1111
- return h('div', { style: S.scrollList },
1312
+ return h('div', { className: S.scrollList },
1112
1313
  rows.map((row, index) => h('div', {
1113
1314
  key: row.name + ':' + index,
1114
- style: { display: 'flex', alignItems: 'baseline', gap: '8px' },
1315
+ className: 'dsh-au-line',
1115
1316
  },
1116
- h('span', { style: S.pkgName, title: row.name }, row.name),
1117
- row.versions === '' ? null : h('span', { style: S.pkgVer }, row.versions),
1317
+ h('span', { className: S.pkgName, title: row.name }, row.name),
1318
+ row.versions === '' ? null : h('span', { className: S.pkgVer }, row.versions),
1118
1319
  )),
1119
1320
  )
1120
1321
  })(),
1121
- runHint ? h('span', { style: S.status }, runHint) : null,
1322
+ runHint ? h('span', { className: S.status }, runHint) : null,
1122
1323
  ),
1123
1324
  // 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
1124
- h('div', { style: S.card },
1125
- h('span', { style: S.label }, T.history),
1325
+ h('div', { className: S.card },
1326
+ h('h3', { className: S.h }, T.history),
1126
1327
  (state?.history?.length ?? 0) === 0
1127
- ? h('span', { style: S.status }, T.historyEmpty)
1128
- : h('div', { style: S.scrollList },
1328
+ ? h('span', { className: S.status }, T.historyEmpty)
1329
+ : h('div', { className: S.scrollList },
1129
1330
  state.history.map((row, index) => h('div', {
1130
1331
  key: row.name + '@' + row.at + ':' + index,
1131
- style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: '10px' },
1332
+ className: S.row,
1132
1333
  },
1133
- h('div', { style: S.labelBox },
1334
+ h('div', { className: S.labelBox },
1134
1335
  h('span', null, row.name + ' ' + (row.from ?? '?') + ' → ' + (row.to ?? '?')),
1135
- h('span', { style: S.hint, title: row.at || '' },
1336
+ h('span', { className: S.hint, title: row.at || '' },
1136
1337
  formatWhen(row.at) + (relativeWhen(row.at) ? '(' + relativeWhen(row.at) + ')' : '') +
1137
1338
  (row.rolledBack === true ? ' · ' + T.rolledBack : '')),
1138
1339
  ),
@@ -1140,18 +1341,18 @@ window.__ModuleLoader__.load({
1140
1341
  ? null
1141
1342
  : h('button', {
1142
1343
  type: 'button',
1143
- style: confirming === row.name ? S.btnPrimary : S.btn,
1344
+ className: confirming === row.name ? S.btnPrimary : S.btn,
1144
1345
  disabled: rolling !== '' || running,
1145
1346
  onClick: () => void doRollback(row.name),
1146
1347
  }, rolling === row.name ? T.rollingBack : confirming === row.name ? T.rollback + '?' : T.rollback),
1147
1348
  )),
1148
1349
  ),
1149
- rollHint ? h('span', { style: S.status }, rollHint) : null,
1350
+ rollHint ? h('span', { className: S.status }, rollHint) : null,
1150
1351
  ),
1151
1352
  h(LogCard, null),
1152
1353
  // 没有保存按钮:改动自己在 350ms 后落盘,这里只报它落没落成。
1153
- saveHint ? h('span', { style: S.status }, saveHint) : null,
1154
- h('span', { style: S.hint }, T.scope),
1354
+ saveHint ? h('span', { className: S.status }, saveHint) : null,
1355
+ h('span', { className: S.hint }, T.scope),
1155
1356
  h(AboutCard, { version: state?.version }),
1156
1357
  )
1157
1358
  }
@@ -1195,36 +1396,36 @@ window.__ModuleLoader__.load({
1195
1396
  const rows = (data?.rows ?? []).slice().reverse()
1196
1397
  const total = data?.total ?? 0
1197
1398
 
1198
- return h('div', { style: S.card },
1199
- h('div', { style: S.row },
1200
- h('div', { style: S.labelBox },
1201
- h('span', { style: S.label }, T.logs),
1202
- h('span', { style: S.hint }, T.logsHint + ' · ' + T.logsNewest),
1399
+ return h('div', { className: S.card },
1400
+ h('div', { className: S.row },
1401
+ h('div', { className: S.labelBox },
1402
+ h('h3', { className: S.h }, T.logs),
1403
+ h('span', { className: S.hint }, T.logsHint + ' · ' + T.logsNewest),
1203
1404
  ),
1204
- h('div', { style: S.actions },
1405
+ h('div', { className: S.actions },
1205
1406
  h('select', {
1206
1407
  value: String(lines),
1207
1408
  onChange: (event) => setLines(Number(event.target.value)),
1208
- style: S.select,
1409
+ className: S.select,
1209
1410
  }, [100, 200, 500, 1000].map((n) => h('option', { key: n, value: String(n) }, n + ' ' + T.logsLines))),
1210
- h('button', { type: 'button', style: S.btn, onClick: () => setTick((n) => n + 1) }, T.logsRefresh),
1411
+ h('button', { type: 'button', className: S.btn, onClick: () => setTick((n) => n + 1) }, T.logsRefresh),
1211
1412
  ),
1212
1413
  ),
1213
1414
  h(SwitchRow, { label: T.logsAuto, hint: T.logsAutoHint, value: auto, onChange: setAuto }),
1214
1415
  phase === 'loading' && data === null
1215
- ? h('span', { style: S.status }, '…')
1416
+ ? h('span', { className: S.status }, '…')
1216
1417
  : phase === 'missing' || (data !== null && data.exists === false)
1217
- ? h('span', { style: S.status }, T.logsMissing)
1418
+ ? h('span', { className: S.status }, T.logsMissing)
1218
1419
  : rows.length === 0
1219
- ? h('span', { style: S.status }, T.logsEmpty)
1220
- : h('pre', { style: S.logBox, title: data?.path || '' },
1420
+ ? h('span', { className: S.status }, T.logsEmpty)
1421
+ : h('pre', { className: S.logBox, title: data?.path || '' },
1221
1422
  rows.map((row, index) => h('div', { key: index },
1222
- row.at ? h('span', { style: S.logTime }, formatLogWhen(row.at) + ' ') : null,
1223
- h('span', { style: S.logText }, row.text),
1423
+ row.at ? h('span', { className: S.logTime }, formatLogWhen(row.at) + ' ') : null,
1424
+ h('span', { className: S.logText }, row.text),
1224
1425
  )),
1225
1426
  ),
1226
1427
  data !== null && data.exists !== false
1227
- ? h('div', { style: S.meta },
1428
+ ? h('div', { className: S.meta },
1228
1429
  h('span', { title: data.path || '' }, T.logsTotal.replace('{n}', String(total))),
1229
1430
  data.rotated === true ? h('span', null, T.logsRotated) : null,
1230
1431
  )
@@ -1253,13 +1454,13 @@ window.__ModuleLoader__.load({
1253
1454
  const text = state === null
1254
1455
  ? '…'
1255
1456
  : state.settings?.enabled === false
1256
- ? (T.enabled + ':' + 'off')
1457
+ ? (T.enabled + ':' + T.off)
1257
1458
  : last === null || last === undefined
1258
1459
  ? T.never
1259
1460
  : (last.updates?.length ?? 0) > 0
1260
1461
  ? (last.updates?.length ?? 0) + ' ' + T.updates
1261
1462
  : T.upToDate
1262
- return h('span', { style: { fontSize: '12px', opacity: 0.68 } }, text)
1463
+ return h('span', { className: S.status }, text)
1263
1464
  }
1264
1465
 
1265
1466
  /* ── 更新提醒 ────────────────────────────────────────────────────────
@@ -1322,37 +1523,44 @@ window.__ModuleLoader__.load({
1322
1523
  const rows = (Array.isArray(updates) ? updates : []).map((item) => describeUpdate(item)).filter((row) => row !== null)
1323
1524
  if (rows.length === 0) return
1324
1525
  toastOpen = true
1526
+ // 提醒可能在设置页之外弹出来,样式表没装就先补上(幂等)。
1527
+ installStyles()
1325
1528
  const box = doc.createElement('div')
1326
1529
  box.setAttribute('data-dsh-aupdate', 'toast')
1327
- box.style.cssText = [
1328
- 'position:fixed', 'right:16px', 'bottom:16px', 'z-index:2147483000',
1329
- 'width:320px', 'max-width:calc(100vw - 32px)', 'padding:12px 14px', 'border-radius:10px',
1330
- 'background:rgba(28,28,30,0.97)', 'color:#f4f4f5',
1331
- 'box-shadow:0 8px 28px rgba(0,0,0,0.38)', 'border:1px solid rgba(255,255,255,0.14)',
1332
- 'font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif',
1333
- 'display:flex', 'flex-direction:column', 'gap:9px',
1334
- ].join(';')
1530
+ box.className = 'dsh-au-toast'
1531
+ box.setAttribute('role', 'status')
1532
+ box.setAttribute('aria-live', 'polite')
1335
1533
 
1534
+ // 头部:标题 + × —— 和 cost-meter 的引导卡同一套「标题行 + 关闭」结构。
1535
+ const head = doc.createElement('div')
1536
+ head.className = 'dsh-au-toast-head'
1336
1537
  const title = doc.createElement('div')
1538
+ title.className = 'dsh-au-toast-title'
1337
1539
  title.textContent = T.toastTitle.replace('{n}', String(rows.length))
1338
- title.style.cssText = 'font-weight:600;display:flex;align-items:center;gap:6px'
1339
- box.appendChild(title)
1540
+ const xBtn = doc.createElement('button')
1541
+ xBtn.type = 'button'
1542
+ xBtn.className = 'dsh-au-toast-x'
1543
+ xBtn.textContent = '×'
1544
+ xBtn.setAttribute('aria-label', T.toastDismiss)
1545
+ head.appendChild(title)
1546
+ head.appendChild(xBtn)
1547
+ box.appendChild(head)
1340
1548
 
1341
1549
  const list = doc.createElement('div')
1342
- // 超过 6 条就在框内滚动:提醒不该占掉半屏。
1343
- list.style.cssText = 'display:flex;flex-direction:column;gap:2px;max-height:190px;overflow:auto;margin:0 -4px'
1550
+ list.className = 'dsh-au-toast-list'
1551
+ // 超过 12 条就在框内滚动:提醒不该占掉半屏。
1344
1552
  for (const row of rows.slice(0, 12)) {
1345
1553
  const line = doc.createElement('div')
1346
- line.style.cssText = 'display:flex;align-items:baseline;gap:8px;padding:2px 4px;border-radius:4px;background:rgba(255,255,255,0.05)'
1554
+ line.className = 'dsh-au-toast-item'
1347
1555
  const nameEl = doc.createElement('span')
1556
+ nameEl.className = 'dsh-au-toast-name'
1348
1557
  nameEl.textContent = row.name
1349
1558
  // 包名可能很长(@scope/name),压缩它而不是压缩版本。
1350
- nameEl.style.cssText = 'flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap'
1351
1559
  line.appendChild(nameEl)
1352
1560
  if (row.versions !== '') {
1353
1561
  const verEl = doc.createElement('span')
1562
+ verEl.className = 'dsh-au-toast-ver'
1354
1563
  verEl.textContent = row.versions
1355
- verEl.style.cssText = 'flex:0 0 auto;font-size:11.5px;opacity:0.72;font-variant-numeric:tabular-nums'
1356
1564
  line.appendChild(verEl)
1357
1565
  }
1358
1566
  list.appendChild(line)
@@ -1361,21 +1569,38 @@ window.__ModuleLoader__.load({
1361
1569
 
1362
1570
  if (rows.length > 12) {
1363
1571
  const more = doc.createElement('div')
1572
+ more.className = 'dsh-au-toast-more'
1364
1573
  more.textContent = T.toastMore.replace('{n}', String(rows.length - 12))
1365
- more.style.cssText = 'font-size:11.5px;opacity:0.6'
1366
1574
  box.appendChild(more)
1367
1575
  }
1368
1576
 
1577
+ const foot = doc.createElement('div')
1578
+ foot.className = 'dsh-au-toast-foot'
1369
1579
  const close = doc.createElement('button')
1370
1580
  close.type = 'button'
1581
+ close.className = 'dsh-au-btn dsh-au-primary'
1371
1582
  close.textContent = T.toastDismiss
1372
- close.style.cssText = 'align-self:flex-end;padding:3px 10px;border-radius:6px;border:1px solid rgba(255,255,255,0.25);background:transparent;color:inherit;cursor:pointer;font-size:12px'
1583
+ foot.appendChild(close)
1584
+ box.appendChild(foot)
1585
+
1586
+ let closed = false
1373
1587
  const dismiss = () => {
1588
+ if (closed) return
1589
+ closed = true
1374
1590
  toastOpen = false
1591
+ try { doc.removeEventListener('keydown', onKey, true) } catch {}
1375
1592
  try { box.remove() } catch {}
1376
1593
  }
1594
+ // Esc 也能关:浮层挡住右下角时,键盘用户不该只能等它自己消失。
1595
+ const onKey = (event) => {
1596
+ if (event.key === 'Escape') {
1597
+ event.stopPropagation()
1598
+ dismiss()
1599
+ }
1600
+ }
1377
1601
  close.addEventListener('click', dismiss)
1378
- box.appendChild(close)
1602
+ xBtn.addEventListener('click', dismiss)
1603
+ try { doc.addEventListener('keydown', onKey, true) } catch {}
1379
1604
  doc.body.appendChild(box)
1380
1605
  // 不点也不会一直挂着:15 秒后自己消失,省得挡住下面的界面。
1381
1606
  setTimeout(dismiss, 15000)
@@ -1414,6 +1639,8 @@ window.__ModuleLoader__.load({
1414
1639
  return {
1415
1640
  inject: ['slots'],
1416
1641
  apply(ctx) {
1642
+ // 样式表只注入一次;先把类挂上去,第一帧就是最终样子,不会闪一下。
1643
+ installStyles()
1417
1644
  // 提醒跟着插件一起上、一起卸:ctx.effect 收的是清理函数。
1418
1645
  if (typeof ctx.effect === 'function') ctx.effect(startUpdateNotifier, 'dsh-aupdate: update notices')
1419
1646
  // key 的格式是「包名#条目id」:本插件在 cordis.patch.yml 里的条目 id 就是包名本身,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aupdate",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "description": "定时检查 DSH 插件更新,串行安装后就地生效,不重启;支持多种调度节奏、失败抑制、按包回滚,并在动手前留快照、忙时自动让开;不更新/只更新哪些插件改成勾选,发现更新在右下角提醒,日志最新在最上面,并在「设置 → 插件更新」里有独立一页。",
6
6
  "license": "MIT",