dsh-aupdate 0.7.2 → 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 +20 -1
  2. package/client.js +375 -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
@@ -213,6 +219,9 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
213
219
  关掉「发现更新时提醒我」就完全不弹,日志和设置页照常记录——提醒只是别让它装完你
214
220
  还不知道,不是唯一的告知渠道。
215
221
 
222
+ 提醒卡沿用同一套版式:标题行 + `×`、可滚动的插件清单、「知道了」主按钮,按 Esc 也能关;
223
+ `prefers-reduced-motion` 下不播进场动画。
224
+
216
225
  提醒用的是原生 DOM 浮层,不是新的槽位:槽位只在宿主页挂载时才渲染,而提醒要能在
217
226
  会话、插件页、设置页都出现。
218
227
 
@@ -408,6 +417,13 @@ immediately without a restart. A number field fires per keystroke; that does not
408
417
  one request per character. The same UI is also its own page under
409
418
  **Settings → Plugin updates**, so it is not buried in the plugins page.
410
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
+
411
427
  `exclude` is a checkbox list of the plugins actually installed in this profile, with
412
428
  their installed versions, instead of a textarea you had to type package names into.
413
429
  Search narrows the list; Select all / Clear only touch the rows currently shown, so
@@ -444,7 +460,10 @@ When a check finds updates, a notice appears in the bottom-right corner listing
444
460
  plugin and its current → new version; past eight it adds "and N more", and it closes
445
461
  itself after 15 seconds. Long package names are truncated on the name side so the
446
462
  versions stay visible, and past six entries the list scrolls. The Last run card on the
447
- 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
448
467
  `localStorage` — and turning "Tell me when updates are found" off silences it entirely
449
468
  while the log and settings page keep recording.
450
469
 
package/client.js CHANGED
@@ -38,6 +38,25 @@ window.__ModuleLoader__.load({
38
38
  return table[String(value ?? '')] ?? String(value ?? '')
39
39
  }
40
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
+
41
60
  const REPO_URL = 'https://github.com/CalmSun/dsh-aupdate'
42
61
  const CHANGELOG_URL = REPO_URL + '/releases'
43
62
  const ISSUES_URL = REPO_URL + '/issues/new'
@@ -47,6 +66,10 @@ window.__ModuleLoader__.load({
47
66
  zh: {
48
67
  title: '插件自动更新',
49
68
  subtitle: '定时检查 registry,发现新版本就装好并就地生效',
69
+ secGeneral: '基本设置',
70
+ secSchedule: '调度与范围',
71
+ lastChecked: '上次检查',
72
+ lastUpdates: '可更新',
50
73
  unavailable: '读不到设置:后端路由没起来(插件仍会按默认设置自动更新)',
51
74
  retry: '重试',
52
75
  save: '保存',
@@ -181,6 +204,10 @@ window.__ModuleLoader__.load({
181
204
  en: {
182
205
  title: 'Plugin auto-update',
183
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',
184
211
  unavailable: 'Cannot read settings: the backend route is not up (defaults still apply)',
185
212
  retry: 'Retry',
186
213
  save: 'Save',
@@ -496,45 +523,158 @@ window.__ModuleLoader__.load({
496
523
  return response.json()
497
524
  }
498
525
 
499
- /* ── styles: kept inline so the page needs no build step ───────────── */
500
- const S = {
501
- wrap: { display: 'flex', flexDirection: 'column', gap: '14px', padding: '4px 2px', fontSize: '13px', lineHeight: 1.5 },
502
- head: { display: 'flex', flexDirection: 'column', gap: '2px' },
503
- title: { fontSize: '14px', fontWeight: 600, margin: 0 },
504
- sub: { opacity: 0.62, fontSize: '12px', margin: 0 },
505
- card: { border: '1px solid rgba(128,128,128,0.22)', borderRadius: '8px', padding: '12px', display: 'flex', flexDirection: 'column', gap: '10px' },
506
- row: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: '12px' },
507
- labelBox: { display: 'flex', flexDirection: 'column', gap: '1px', minWidth: 0 },
508
- label: { fontWeight: 500 },
509
- hint: { opacity: 0.55, fontSize: '11.5px' },
510
- 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' },
511
- 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' },
512
- // select 的宽度比数字框宽:四种模式的中文标签最长「每天固定时刻」。
513
- select: { padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '13px', minWidth: '132px' },
514
- actions: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' },
515
- btn: { padding: '5px 12px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', cursor: 'pointer', fontSize: '13px' },
516
- 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 },
517
- status: { fontSize: '12px', opacity: 0.7 },
518
- err: { fontSize: '12px', color: '#d9534f' },
519
- meta: { display: 'flex', gap: '14px', flexWrap: 'wrap', fontSize: '12px', opacity: 0.7 },
520
- // 等宽 + 可滚动:日志要能对齐看时间戳,也不能把整页顶长。
521
- 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' },
522
- logTime: { opacity: 0.5, flexShrink: 0, fontVariantNumeric: 'tabular-nums' },
523
- logText: {},
524
- // 勾选清单:包名可能很长(@scope/name),要能截断,版本靠右对齐。
525
- // 更新记录可能上百条,不封高度会把整页顶到几屏之外,滚动条交还给这一栏。
526
- scrollList: { display: 'flex', flexDirection: 'column', gap: '8px', maxHeight: '260px', overflowY: 'auto', paddingRight: '4px' },
527
- pkgList: { display: 'flex', flexDirection: 'column', gap: '1px', maxHeight: '240px', overflow: 'auto', border: '1px solid rgba(128,128,128,0.22)', borderRadius: '6px', padding: '4px' },
528
- pkgRow: { display: 'flex', alignItems: 'center', gap: '8px', padding: '2px 4px', borderRadius: '4px', cursor: 'pointer' },
529
- pkgName: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
530
- pkgVer: { opacity: 0.5, fontSize: '11px', marginLeft: 'auto', flexShrink: 0 },
531
- search: { padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '12.5px' },
532
- // 「关于」组:外链靠右等宽、↗ 与文字同色但更淡,避免整行像按钮。
533
- link: { color: 'inherit', textDecoration: 'none', borderBottom: '1px solid rgba(128,128,128,0.4)', paddingBottom: '1px' },
534
- linkExt: { opacity: 0.5, marginLeft: '3px' },
535
- 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 {}
536
635
  }
537
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
+ }
538
678
  function Toggle(props) {
539
679
  const { checked, onChange, disabled } = props
540
680
  return h('input', {
@@ -542,16 +682,16 @@ window.__ModuleLoader__.load({
542
682
  checked: checked === true,
543
683
  disabled: disabled === true,
544
684
  onChange: (event) => onChange(event.target.checked),
545
- style: { width: '16px', height: '16px', cursor: disabled === true ? 'default' : 'pointer', accentColor: 'currentColor', marginTop: '2px' },
685
+ className: S.check,
546
686
  })
547
687
  }
548
688
 
549
689
  function SwitchRow(props) {
550
690
  const { label, hint, value, onChange, disabled } = props
551
- return h('div', { style: S.row },
552
- h('div', { style: S.labelBox },
553
- h('span', { style: S.label }, label),
554
- 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,
555
695
  ),
556
696
  h(Toggle, { checked: value, onChange, disabled }),
557
697
  )
@@ -559,10 +699,10 @@ window.__ModuleLoader__.load({
559
699
 
560
700
  function NumberRow(props) {
561
701
  const { label, hint, value, onChange, min, max, 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,
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,
566
706
  ),
567
707
  h('input', {
568
708
  type: 'number',
@@ -574,7 +714,7 @@ window.__ModuleLoader__.load({
574
714
  const next = Number(event.target.value)
575
715
  if (Number.isFinite(next)) onChange(next)
576
716
  },
577
- style: S.input,
717
+ className: S.input,
578
718
  }),
579
719
  )
580
720
  }
@@ -585,17 +725,17 @@ window.__ModuleLoader__.load({
585
725
  */
586
726
  function ClockRow(props) {
587
727
  const { label, hint, value, onChange, disabled } = props
588
- return h('div', { style: S.row },
589
- h('div', { style: S.labelBox },
590
- h('span', { style: S.label }, label),
591
- 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,
592
732
  ),
593
733
  h('input', {
594
734
  type: 'time',
595
735
  value: typeof value === 'string' ? value : '03:00',
596
736
  disabled: disabled === true,
597
737
  onChange: (event) => onChange(event.target.value),
598
- style: S.input,
738
+ className: S.input,
599
739
  }),
600
740
  )
601
741
  }
@@ -608,16 +748,16 @@ window.__ModuleLoader__.load({
608
748
  */
609
749
  function SelectRow(props) {
610
750
  const { label, hint, value, options, onChange, disabled } = props
611
- return h('div', { style: S.row },
612
- h('div', { style: S.labelBox },
613
- h('span', { style: S.label }, label),
614
- 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,
615
755
  ),
616
756
  h('select', {
617
757
  value,
618
758
  disabled: disabled === true,
619
759
  onChange: (event) => onChange(event.target.value),
620
- style: S.select,
760
+ className: S.select,
621
761
  }, options.map((option) => h('option', { key: option.value, value: option.value }, option.label))),
622
762
  )
623
763
  }
@@ -641,8 +781,8 @@ window.__ModuleLoader__.load({
641
781
  if (typeof gate.lock === 'string' && gate.lock !== '') {
642
782
  parts.push(T.gateLocked.replace('{who}', gate.lock))
643
783
  }
644
- return h('div', { style: S.labelBox },
645
- h('span', { style: S.hint }, parts.join(' · ')),
784
+ return h('div', { className: S.labelBox },
785
+ h('span', { className: S.hint }, parts.join(' · ')),
646
786
  )
647
787
  }
648
788
 
@@ -685,30 +825,31 @@ window.__ModuleLoader__.load({
685
825
  commit(next)
686
826
  }
687
827
 
688
- 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)
689
829
 
690
- return h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
691
- h('div', { style: S.actions },
830
+ return h('div', { className: 'dsh-au-col' },
831
+ h('div', { className: S.actions },
692
832
  h('input', {
693
833
  type: 'search',
694
834
  value: query,
695
835
  placeholder: T.pkgsSearch,
696
836
  onChange: (event) => setQuery(event.target.value),
697
- style: { ...S.search, flex: '1 1 160px' },
837
+ className: S.search,
838
+ style: { flex: '1 1 160px' },
698
839
  }),
699
- h('button', { type: 'button', style: S.btn, onClick: () => setVisible(true) }, T.pkgsAll),
700
- h('button', { type: 'button', style: S.btn, onClick: () => setVisible(false) }, T.pkgsNone),
701
- 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))),
702
843
  ),
703
- h('div', { style: S.pkgList },
844
+ h('div', { className: S.pkgList },
704
845
  rows.length === 0
705
- ? h('span', { style: { ...S.status, padding: '4px' } }, T.pkgsNoMatch)
706
- : 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 },
707
848
  h(Toggle, { checked: chosen.has(item.name), onChange: () => toggle(item.name) }),
708
- h('span', { style: S.pkgName }, item.name),
849
+ h('span', { className: S.pkgName }, item.name),
709
850
  item.version === ''
710
- ? h('span', { style: S.pkgVer }, T.pkgsNotInstalled)
711
- : h('span', { style: S.pkgVer }, item.version),
851
+ ? h('span', { className: S.pkgVer }, T.pkgsNotInstalled)
852
+ : h('span', { className: S.pkgVer }, item.version),
712
853
  )),
713
854
  ),
714
855
  )
@@ -732,8 +873,8 @@ window.__ModuleLoader__.load({
732
873
  href,
733
874
  target: '_blank',
734
875
  rel: 'noopener noreferrer',
735
- style: S.link,
736
- }, label, h('span', { style: S.linkExt, 'aria-hidden': 'true' }, '↗'))
876
+ className: S.link,
877
+ }, label, h('span', { className: S.linkExt, 'aria-hidden': 'true' }, '↗'))
737
878
 
738
879
  const share = async () => {
739
880
  try {
@@ -748,44 +889,44 @@ window.__ModuleLoader__.load({
748
889
  }
749
890
  }
750
891
 
751
- return h('div', { style: S.card },
752
- h('span', { style: S.label }, T.about),
753
- h('div', { style: S.row },
754
- h('span', { style: S.label }, T.aboutVersion),
755
- 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),
756
897
  ),
757
- h('div', { style: S.row },
758
- h('span', { style: S.label }, T.aboutChangelog),
898
+ h('div', { className: S.row },
899
+ h('span', { className: S.label }, T.aboutChangelog),
759
900
  extLink(CHANGELOG_URL, T.aboutChangelogLink),
760
901
  ),
761
- h('div', { style: S.row },
762
- h('span', { style: S.label }, T.aboutRepo),
902
+ h('div', { className: S.row },
903
+ h('span', { className: S.label }, T.aboutRepo),
763
904
  extLink(REPO_URL, 'GitHub'),
764
905
  ),
765
- h('div', { style: S.row },
766
- h('span', { style: S.label }, T.aboutFeedback),
906
+ h('div', { className: S.row },
907
+ h('span', { className: S.label }, T.aboutFeedback),
767
908
  extLink(ISSUES_URL, T.aboutFeedbackLink),
768
909
  ),
769
- h('div', { style: S.row },
770
- h('span', { style: S.labelBox },
771
- h('span', { style: S.label }, T.aboutStar),
772
- 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),
773
914
  ),
774
915
  extLink(STARS_URL, 'GitHub'),
775
916
  ),
776
- h('div', { style: S.row },
777
- h('span', { style: S.labelBox },
778
- h('span', { style: S.label }, T.aboutShare),
779
- 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),
780
921
  ),
781
- 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),
782
923
  ),
783
924
  // 项目地址可点开、可选中复制,失败时用户还有这一条路。
784
- h('div', { style: S.row },
785
- h('span', { style: S.label }, T.aboutProject),
925
+ h('div', { className: S.row },
926
+ h('span', { className: S.label }, T.aboutProject),
786
927
  extLink(REPO_URL, REPO_URL.replace('https://', '')),
787
928
  ),
788
- shareHint ? h('span', { style: S.status }, shareHint) : null,
929
+ shareHint ? h('span', { className: S.status }, shareHint) : null,
789
930
  )
790
931
  }
791
932
 
@@ -994,24 +1135,25 @@ window.__ModuleLoader__.load({
994
1135
  }, [rolling, running, confirming])
995
1136
 
996
1137
  if (phase === 'error') {
997
- return h('div', { style: S.card },
998
- h('span', { style: S.err }, T.unavailable),
999
- 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)),
1000
1141
  )
1001
1142
  }
1002
1143
 
1003
1144
  if (phase === 'loading' || draft === null) {
1004
- return h('div', { style: S.card }, h('span', { style: S.status }, '…'))
1145
+ return h('div', { className: S.card }, h('span', { className: S.status }, '…'))
1005
1146
  }
1006
1147
 
1007
1148
  const last = state?.lastRun
1008
1149
 
1009
- return h('div', { style: S.wrap },
1010
- h('div', { style: S.head },
1011
- h('h3', { style: S.title }, T.title),
1012
- 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),
1013
1154
  ),
1014
- h('div', { style: S.card },
1155
+ h('div', { className: S.card },
1156
+ h('h3', { className: S.h }, T.secGeneral),
1015
1157
  h(SelectRow, {
1016
1158
  label: T.language,
1017
1159
  hint: T.languageHint,
@@ -1036,7 +1178,8 @@ window.__ModuleLoader__.load({
1036
1178
  h(SwitchRow, { label: T.idleOnly, hint: T.idleOnlyHint, value: draft.idleOnly, onChange: (v) => patch('idleOnly', v), disabled: !draft.enabled }),
1037
1179
  h(SwitchRow, { label: T.notify, hint: T.notifyHint, value: draft.notify, onChange: (v) => patch('notify', v) }),
1038
1180
  ),
1039
- h('div', { style: S.card },
1181
+ h('div', { className: S.card },
1182
+ h('h3', { className: S.h }, T.secSchedule),
1040
1183
  h(SelectRow, {
1041
1184
  label: T.schedule,
1042
1185
  hint: T.scheduleHint,
@@ -1068,9 +1211,9 @@ window.__ModuleLoader__.load({
1068
1211
  h(NumberRow, { label: T.maxPerCycle, hint: T.maxPerCycleHint, value: draft.maxPerCycle, min: 0, max: 50, onChange: (v) => patch('maxPerCycle', v), disabled: !draft.enabled }),
1069
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 }),
1070
1213
  gateLine(state),
1071
- h('div', { style: S.labelBox },
1072
- h('span', { style: S.label }, T.pkgsExclude),
1073
- 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),
1074
1217
  ),
1075
1218
  h(PackagePicker, {
1076
1219
  packages: state?.packages,
@@ -1079,14 +1222,14 @@ window.__ModuleLoader__.load({
1079
1222
  }),
1080
1223
  ),
1081
1224
  // 策略:预发布 / 跨大版本,决定「什么算可以装」。
1082
- h('div', { style: S.card },
1083
- h('span', { style: S.label }, T.policy),
1225
+ h('div', { className: S.card },
1226
+ h('h3', { className: S.h }, T.policy),
1084
1227
  h(SwitchRow, { label: T.allowMajor, hint: T.allowMajorHint, value: draft.allowMajor, onChange: (v) => patch('allowMajor', v) }),
1085
1228
  h(SwitchRow, { label: T.allowPrerelease, hint: T.allowPrereleaseHint, value: draft.allowPrerelease, onChange: (v) => patch('allowPrerelease', v) }),
1086
1229
  ),
1087
- h('div', { style: S.card },
1088
- h('span', { style: S.label }, T.keepTitle),
1089
- 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),
1090
1233
  h(SelectRow, {
1091
1234
  label: T.keepHistory,
1092
1235
  value: String(draft.historyRetentionDays ?? 3),
@@ -1113,33 +1256,52 @@ window.__ModuleLoader__.load({
1113
1256
  { value: '0', label: T.keepForever },
1114
1257
  ],
1115
1258
  }),
1116
- h('div', { style: S.actions },
1117
- h('button', { type: 'button', style: S.btn, disabled: cleaning, onClick: () => void doCleanup() }, cleaning ? T.cleaning : T.cleanNow),
1118
- 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,
1119
1262
  ),
1120
1263
  ),
1121
- h('div', { style: S.card },
1264
+ h('div', { className: S.card },
1122
1265
  // 按钮和它动作的对象放在一起:读「上一次」的人最想做的事就是再跑一次。
1123
- h('div', { style: S.row },
1124
- h('span', { style: S.label }, T.lastRun),
1125
- 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),
1126
1272
  ),
1127
1273
  // 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
1128
- progress
1129
- ? h('span', { style: { ...S.status, color: '#4c9aff', fontWeight: 500 } }, runningText)
1130
- : null,
1131
- last === null || last === undefined
1132
- ? h('span', { style: S.status }, T.never)
1133
- : h('div', { style: S.meta },
1134
- h('span', { title: last.at || '' }, formatWhen(last.at) + (relativeWhen(last.at) ? '(' + relativeWhen(last.at) + ')' : '')),
1135
- h('span', null, T.checked + ' ' + (last.checked ?? 0) + ' ' + T.packages),
1136
- h('span', null, (last.updates?.length ?? 0) > 0
1137
- ? (last.updates?.length ?? 0) + ' ' + T.updates
1138
- : T.upToDate),
1139
- // reason 是后端按语言渲染好的句子;没有它才退回本地化的状态词,
1140
- // 绝不要把英文 done 直接摆到界面上。
1141
- h('span', null, last.reason || statusLabel(last.status) || ''),
1142
- ),
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
+ })(),
1143
1305
  // 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
1144
1306
  // 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
1145
1307
  (() => {
@@ -1147,31 +1309,31 @@ window.__ModuleLoader__.load({
1147
1309
  .map((item) => describeUpdate(item))
1148
1310
  .filter((row) => row !== null)
1149
1311
  if (rows.length === 0) return null
1150
- return h('div', { style: S.scrollList },
1312
+ return h('div', { className: S.scrollList },
1151
1313
  rows.map((row, index) => h('div', {
1152
1314
  key: row.name + ':' + index,
1153
- style: { display: 'flex', alignItems: 'baseline', gap: '8px' },
1315
+ className: 'dsh-au-line',
1154
1316
  },
1155
- h('span', { style: S.pkgName, title: row.name }, row.name),
1156
- 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),
1157
1319
  )),
1158
1320
  )
1159
1321
  })(),
1160
- runHint ? h('span', { style: S.status }, runHint) : null,
1322
+ runHint ? h('span', { className: S.status }, runHint) : null,
1161
1323
  ),
1162
1324
  // 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
1163
- h('div', { style: S.card },
1164
- h('span', { style: S.label }, T.history),
1325
+ h('div', { className: S.card },
1326
+ h('h3', { className: S.h }, T.history),
1165
1327
  (state?.history?.length ?? 0) === 0
1166
- ? h('span', { style: S.status }, T.historyEmpty)
1167
- : h('div', { style: S.scrollList },
1328
+ ? h('span', { className: S.status }, T.historyEmpty)
1329
+ : h('div', { className: S.scrollList },
1168
1330
  state.history.map((row, index) => h('div', {
1169
1331
  key: row.name + '@' + row.at + ':' + index,
1170
- style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: '10px' },
1332
+ className: S.row,
1171
1333
  },
1172
- h('div', { style: S.labelBox },
1334
+ h('div', { className: S.labelBox },
1173
1335
  h('span', null, row.name + ' ' + (row.from ?? '?') + ' → ' + (row.to ?? '?')),
1174
- h('span', { style: S.hint, title: row.at || '' },
1336
+ h('span', { className: S.hint, title: row.at || '' },
1175
1337
  formatWhen(row.at) + (relativeWhen(row.at) ? '(' + relativeWhen(row.at) + ')' : '') +
1176
1338
  (row.rolledBack === true ? ' · ' + T.rolledBack : '')),
1177
1339
  ),
@@ -1179,18 +1341,18 @@ window.__ModuleLoader__.load({
1179
1341
  ? null
1180
1342
  : h('button', {
1181
1343
  type: 'button',
1182
- style: confirming === row.name ? S.btnPrimary : S.btn,
1344
+ className: confirming === row.name ? S.btnPrimary : S.btn,
1183
1345
  disabled: rolling !== '' || running,
1184
1346
  onClick: () => void doRollback(row.name),
1185
1347
  }, rolling === row.name ? T.rollingBack : confirming === row.name ? T.rollback + '?' : T.rollback),
1186
1348
  )),
1187
1349
  ),
1188
- rollHint ? h('span', { style: S.status }, rollHint) : null,
1350
+ rollHint ? h('span', { className: S.status }, rollHint) : null,
1189
1351
  ),
1190
1352
  h(LogCard, null),
1191
1353
  // 没有保存按钮:改动自己在 350ms 后落盘,这里只报它落没落成。
1192
- saveHint ? h('span', { style: S.status }, saveHint) : null,
1193
- h('span', { style: S.hint }, T.scope),
1354
+ saveHint ? h('span', { className: S.status }, saveHint) : null,
1355
+ h('span', { className: S.hint }, T.scope),
1194
1356
  h(AboutCard, { version: state?.version }),
1195
1357
  )
1196
1358
  }
@@ -1234,36 +1396,36 @@ window.__ModuleLoader__.load({
1234
1396
  const rows = (data?.rows ?? []).slice().reverse()
1235
1397
  const total = data?.total ?? 0
1236
1398
 
1237
- return h('div', { style: S.card },
1238
- h('div', { style: S.row },
1239
- h('div', { style: S.labelBox },
1240
- h('span', { style: S.label }, T.logs),
1241
- 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),
1242
1404
  ),
1243
- h('div', { style: S.actions },
1405
+ h('div', { className: S.actions },
1244
1406
  h('select', {
1245
1407
  value: String(lines),
1246
1408
  onChange: (event) => setLines(Number(event.target.value)),
1247
- style: S.select,
1409
+ className: S.select,
1248
1410
  }, [100, 200, 500, 1000].map((n) => h('option', { key: n, value: String(n) }, n + ' ' + T.logsLines))),
1249
- 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),
1250
1412
  ),
1251
1413
  ),
1252
1414
  h(SwitchRow, { label: T.logsAuto, hint: T.logsAutoHint, value: auto, onChange: setAuto }),
1253
1415
  phase === 'loading' && data === null
1254
- ? h('span', { style: S.status }, '…')
1416
+ ? h('span', { className: S.status }, '…')
1255
1417
  : phase === 'missing' || (data !== null && data.exists === false)
1256
- ? h('span', { style: S.status }, T.logsMissing)
1418
+ ? h('span', { className: S.status }, T.logsMissing)
1257
1419
  : rows.length === 0
1258
- ? h('span', { style: S.status }, T.logsEmpty)
1259
- : 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 || '' },
1260
1422
  rows.map((row, index) => h('div', { key: index },
1261
- row.at ? h('span', { style: S.logTime }, formatLogWhen(row.at) + ' ') : null,
1262
- 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),
1263
1425
  )),
1264
1426
  ),
1265
1427
  data !== null && data.exists !== false
1266
- ? h('div', { style: S.meta },
1428
+ ? h('div', { className: S.meta },
1267
1429
  h('span', { title: data.path || '' }, T.logsTotal.replace('{n}', String(total))),
1268
1430
  data.rotated === true ? h('span', null, T.logsRotated) : null,
1269
1431
  )
@@ -1298,7 +1460,7 @@ window.__ModuleLoader__.load({
1298
1460
  : (last.updates?.length ?? 0) > 0
1299
1461
  ? (last.updates?.length ?? 0) + ' ' + T.updates
1300
1462
  : T.upToDate
1301
- return h('span', { style: { fontSize: '12px', opacity: 0.68 } }, text)
1463
+ return h('span', { className: S.status }, text)
1302
1464
  }
1303
1465
 
1304
1466
  /* ── 更新提醒 ────────────────────────────────────────────────────────
@@ -1361,37 +1523,44 @@ window.__ModuleLoader__.load({
1361
1523
  const rows = (Array.isArray(updates) ? updates : []).map((item) => describeUpdate(item)).filter((row) => row !== null)
1362
1524
  if (rows.length === 0) return
1363
1525
  toastOpen = true
1526
+ // 提醒可能在设置页之外弹出来,样式表没装就先补上(幂等)。
1527
+ installStyles()
1364
1528
  const box = doc.createElement('div')
1365
1529
  box.setAttribute('data-dsh-aupdate', 'toast')
1366
- box.style.cssText = [
1367
- 'position:fixed', 'right:16px', 'bottom:16px', 'z-index:2147483000',
1368
- 'width:320px', 'max-width:calc(100vw - 32px)', 'padding:12px 14px', 'border-radius:10px',
1369
- 'background:rgba(28,28,30,0.97)', 'color:#f4f4f5',
1370
- 'box-shadow:0 8px 28px rgba(0,0,0,0.38)', 'border:1px solid rgba(255,255,255,0.14)',
1371
- 'font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif',
1372
- 'display:flex', 'flex-direction:column', 'gap:9px',
1373
- ].join(';')
1530
+ box.className = 'dsh-au-toast'
1531
+ box.setAttribute('role', 'status')
1532
+ box.setAttribute('aria-live', 'polite')
1374
1533
 
1534
+ // 头部:标题 + × —— 和 cost-meter 的引导卡同一套「标题行 + 关闭」结构。
1535
+ const head = doc.createElement('div')
1536
+ head.className = 'dsh-au-toast-head'
1375
1537
  const title = doc.createElement('div')
1538
+ title.className = 'dsh-au-toast-title'
1376
1539
  title.textContent = T.toastTitle.replace('{n}', String(rows.length))
1377
- title.style.cssText = 'font-weight:600;display:flex;align-items:center;gap:6px'
1378
- 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)
1379
1548
 
1380
1549
  const list = doc.createElement('div')
1381
- // 超过 6 条就在框内滚动:提醒不该占掉半屏。
1382
- 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 条就在框内滚动:提醒不该占掉半屏。
1383
1552
  for (const row of rows.slice(0, 12)) {
1384
1553
  const line = doc.createElement('div')
1385
- 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'
1386
1555
  const nameEl = doc.createElement('span')
1556
+ nameEl.className = 'dsh-au-toast-name'
1387
1557
  nameEl.textContent = row.name
1388
1558
  // 包名可能很长(@scope/name),压缩它而不是压缩版本。
1389
- nameEl.style.cssText = 'flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap'
1390
1559
  line.appendChild(nameEl)
1391
1560
  if (row.versions !== '') {
1392
1561
  const verEl = doc.createElement('span')
1562
+ verEl.className = 'dsh-au-toast-ver'
1393
1563
  verEl.textContent = row.versions
1394
- verEl.style.cssText = 'flex:0 0 auto;font-size:11.5px;opacity:0.72;font-variant-numeric:tabular-nums'
1395
1564
  line.appendChild(verEl)
1396
1565
  }
1397
1566
  list.appendChild(line)
@@ -1400,21 +1569,38 @@ window.__ModuleLoader__.load({
1400
1569
 
1401
1570
  if (rows.length > 12) {
1402
1571
  const more = doc.createElement('div')
1572
+ more.className = 'dsh-au-toast-more'
1403
1573
  more.textContent = T.toastMore.replace('{n}', String(rows.length - 12))
1404
- more.style.cssText = 'font-size:11.5px;opacity:0.6'
1405
1574
  box.appendChild(more)
1406
1575
  }
1407
1576
 
1577
+ const foot = doc.createElement('div')
1578
+ foot.className = 'dsh-au-toast-foot'
1408
1579
  const close = doc.createElement('button')
1409
1580
  close.type = 'button'
1581
+ close.className = 'dsh-au-btn dsh-au-primary'
1410
1582
  close.textContent = T.toastDismiss
1411
- 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
1412
1587
  const dismiss = () => {
1588
+ if (closed) return
1589
+ closed = true
1413
1590
  toastOpen = false
1591
+ try { doc.removeEventListener('keydown', onKey, true) } catch {}
1414
1592
  try { box.remove() } catch {}
1415
1593
  }
1594
+ // Esc 也能关:浮层挡住右下角时,键盘用户不该只能等它自己消失。
1595
+ const onKey = (event) => {
1596
+ if (event.key === 'Escape') {
1597
+ event.stopPropagation()
1598
+ dismiss()
1599
+ }
1600
+ }
1416
1601
  close.addEventListener('click', dismiss)
1417
- box.appendChild(close)
1602
+ xBtn.addEventListener('click', dismiss)
1603
+ try { doc.addEventListener('keydown', onKey, true) } catch {}
1418
1604
  doc.body.appendChild(box)
1419
1605
  // 不点也不会一直挂着:15 秒后自己消失,省得挡住下面的界面。
1420
1606
  setTimeout(dismiss, 15000)
@@ -1453,6 +1639,8 @@ window.__ModuleLoader__.load({
1453
1639
  return {
1454
1640
  inject: ['slots'],
1455
1641
  apply(ctx) {
1642
+ // 样式表只注入一次;先把类挂上去,第一帧就是最终样子,不会闪一下。
1643
+ installStyles()
1456
1644
  // 提醒跟着插件一起上、一起卸:ctx.effect 收的是清理函数。
1457
1645
  if (typeof ctx.effect === 'function') ctx.effect(startUpdateNotifier, 'dsh-aupdate: update notices')
1458
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.2",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "description": "定时检查 DSH 插件更新,串行安装后就地生效,不重启;支持多种调度节奏、失败抑制、按包回滚,并在动手前留快照、忙时自动让开;不更新/只更新哪些插件改成勾选,发现更新在右下角提醒,日志最新在最上面,并在「设置 → 插件更新」里有独立一页。",
6
6
  "license": "MIT",