dsh-aupdate 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -1
- package/client.js +442 -207
- 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,19 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
|
|
|
213
219
|
关掉「发现更新时提醒我」就完全不弹,日志和设置页照常记录——提醒只是别让它装完你
|
|
214
220
|
还不知道,不是唯一的告知渠道。
|
|
215
221
|
|
|
222
|
+
提醒卡照 `dsh-cost-meter` 的「峰/谷切换提醒」做:最上面是**圆点徽标**(已更新 / 可更新),
|
|
223
|
+
下面标题行带 `×`,再一句正文说明「装好就地生效,不用重启」,然后是可滚动的插件清单和
|
|
224
|
+
右对齐的「知道了」主按钮;按 Esc 也能关,`prefers-reduced-motion` 下不播进场动画。
|
|
225
|
+
|
|
226
|
+
**「已更新」只在真的装完之后说**。`lastRun.updates` 记的是「发现了哪些新版本」——自动安装
|
|
227
|
+
被关掉、被空闲门槛让开、或者装失败时它照样有值。所以徽标、标题和「上一次」的统计卡都改看
|
|
228
|
+
`installed`(去掉带 `!failed` 的条目)算出来的「真装成了几个」:装成了说「已更新 N 个」,
|
|
229
|
+
只查到不动手说「可更新 N 个」,两个数字不会互相冒充。
|
|
230
|
+
|
|
231
|
+
「上一次」里的时间显示成 `26/11/26 12:38`(两位年/月/日 + 时:分,本地时区)。秒不显示,
|
|
232
|
+
因为统计卡里它只会把数字挤窄;年月日的顺序也写死成「年/月/日」,不跟 `Intl` 的
|
|
233
|
+
区域顺序走,中文环境下不会跳成 `2026/11/26`。
|
|
234
|
+
|
|
216
235
|
提醒用的是原生 DOM 浮层,不是新的槽位:槽位只在宿主页挂载时才渲染,而提醒要能在
|
|
217
236
|
会话、插件页、设置页都出现。
|
|
218
237
|
|
|
@@ -408,6 +427,13 @@ immediately without a restart. A number field fires per keystroke; that does not
|
|
|
408
427
|
one request per character. The same UI is also its own page under
|
|
409
428
|
**Settings → Plugin updates**, so it is not buried in the plugins page.
|
|
410
429
|
|
|
430
|
+
The layout follows the `dsh-cost-meter` settings page: stacked section cards, small section
|
|
431
|
+
headings, one-step-muted secondary text and two button tiers. "Last run" is no longer a run
|
|
432
|
+
of sentences glued with `·` but three stat cards (last check / packages checked / updates)
|
|
433
|
+
plus a status badge. Colours and borders come from the host theme variables
|
|
434
|
+
(`--dsw-alias-*`), so light and dark both hold; the stylesheet is injected once and every
|
|
435
|
+
selector is `dsh-au-` prefixed, so no host or other plugin rule is touched.
|
|
436
|
+
|
|
411
437
|
`exclude` is a checkbox list of the plugins actually installed in this profile, with
|
|
412
438
|
their installed versions, instead of a textarea you had to type package names into.
|
|
413
439
|
Search narrows the list; Select all / Clear only touch the rows currently shown, so
|
|
@@ -444,7 +470,25 @@ When a check finds updates, a notice appears in the bottom-right corner listing
|
|
|
444
470
|
plugin and its current → new version; past eight it adds "and N more", and it closes
|
|
445
471
|
itself after 15 seconds. Long package names are truncated on the name side so the
|
|
446
472
|
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.
|
|
473
|
+
settings page lists the same plugins and version pairs. The notice follows the
|
|
474
|
+
`dsh-cost-meter` peak/off-peak switch alert: a **dot badge** at the top (Updated /
|
|
475
|
+
Update available), a title row with `×`, one body line saying it was applied in place
|
|
476
|
+
without a restart, then the scrollable plugin list and a right-aligned primary "Got it"
|
|
477
|
+
button. `Esc` closes it too, and the entrance animation is skipped under
|
|
478
|
+
`prefers-reduced-motion`.
|
|
479
|
+
|
|
480
|
+
**"Updated" is only claimed once an install actually happened.** `lastRun.updates` records
|
|
481
|
+
which new versions were *found* — it is populated even when auto-install is off, when the
|
|
482
|
+
idle gate holds the run back, or when an install fails. The badge, the notice title and the
|
|
483
|
+
Last run stat card therefore read `installed` (minus entries ending in `!failed`): a real
|
|
484
|
+
install says "N updated", a check-only run says "N can update", and neither number
|
|
485
|
+
impersonates the other.
|
|
486
|
+
|
|
487
|
+
The Last run timestamp renders as `26/11/26 12:38` — two-digit year/month/day plus
|
|
488
|
+
hour:minute in local time. Seconds are dropped because they only squeeze the stat card, and
|
|
489
|
+
the field order is fixed to year/month/day rather than following `Intl`'s locale order, so a
|
|
490
|
+
Chinese locale does not produce `2026/11/26`.
|
|
491
|
+
Each batch is announced once — the signature is kept in
|
|
448
492
|
`localStorage` — and turning "Tell me when updates are found" off silences it entirely
|
|
449
493
|
while the log and settings page keep recording.
|
|
450
494
|
|
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,11 @@ window.__ModuleLoader__.load({
|
|
|
47
66
|
zh: {
|
|
48
67
|
title: '插件自动更新',
|
|
49
68
|
subtitle: '定时检查 registry,发现新版本就装好并就地生效',
|
|
69
|
+
secGeneral: '基本设置',
|
|
70
|
+
secSchedule: '调度与范围',
|
|
71
|
+
lastChecked: '上次检查',
|
|
72
|
+
lastUpdates: '可更新',
|
|
73
|
+
lastUpdated: '已更新',
|
|
50
74
|
unavailable: '读不到设置:后端路由没起来(插件仍会按默认设置自动更新)',
|
|
51
75
|
retry: '重试',
|
|
52
76
|
save: '保存',
|
|
@@ -67,6 +91,8 @@ window.__ModuleLoader__.load({
|
|
|
67
91
|
checked: '检查了',
|
|
68
92
|
packages: '个包',
|
|
69
93
|
updates: '个可更新',
|
|
94
|
+
updatedUnit: '个已更新',
|
|
95
|
+
updatedHint: '个插件',
|
|
70
96
|
upToDate: '全部都是最新的',
|
|
71
97
|
enabled: '启用定时检查',
|
|
72
98
|
enabledHint: '关掉之后不再自动跑,设置页仍然可用',
|
|
@@ -139,7 +165,12 @@ window.__ModuleLoader__.load({
|
|
|
139
165
|
langAuto: '跟随系统',
|
|
140
166
|
langZh: '中文',
|
|
141
167
|
langEn: 'English',
|
|
142
|
-
toastTitle: '{n}
|
|
168
|
+
toastTitle: '{n} 个插件已更新',
|
|
169
|
+
toastTitleFound: '{n} 个插件可更新',
|
|
170
|
+
toastBadge: '已更新',
|
|
171
|
+
toastBadgeFound: '可更新',
|
|
172
|
+
toastBody: '装好就地生效,不用重启;下面是这一轮换掉的版本。',
|
|
173
|
+
toastBodyFound: '下面是能升级到的新版本;自动安装关掉时只会检查,不会动手。',
|
|
143
174
|
toastMore: '还有 {n} 个',
|
|
144
175
|
toastDismiss: '知道了',
|
|
145
176
|
keepTitle: '保留期限',
|
|
@@ -162,6 +193,7 @@ window.__ModuleLoader__.load({
|
|
|
162
193
|
rolledBack: '已回滚',
|
|
163
194
|
policy: '更新策略',
|
|
164
195
|
minutes: '分钟',
|
|
196
|
+
min: '分钟',
|
|
165
197
|
scope: '这些设置只影响本机这个 profile',
|
|
166
198
|
about: '关于 aupdate',
|
|
167
199
|
aboutVersion: '版本',
|
|
@@ -181,6 +213,11 @@ window.__ModuleLoader__.load({
|
|
|
181
213
|
en: {
|
|
182
214
|
title: 'Plugin auto-update',
|
|
183
215
|
subtitle: 'Checks the registry on a timer and applies new versions in place',
|
|
216
|
+
secGeneral: 'Basics',
|
|
217
|
+
secSchedule: 'Schedule and scope',
|
|
218
|
+
lastChecked: 'Last check',
|
|
219
|
+
lastUpdates: 'Updates',
|
|
220
|
+
lastUpdated: 'Updated',
|
|
184
221
|
unavailable: 'Cannot read settings: the backend route is not up (defaults still apply)',
|
|
185
222
|
retry: 'Retry',
|
|
186
223
|
save: 'Save',
|
|
@@ -201,6 +238,8 @@ window.__ModuleLoader__.load({
|
|
|
201
238
|
checked: 'checked',
|
|
202
239
|
packages: 'packages',
|
|
203
240
|
updates: 'updates',
|
|
241
|
+
updatedUnit: 'updated',
|
|
242
|
+
updatedHint: 'plugins',
|
|
204
243
|
upToDate: 'everything is current',
|
|
205
244
|
enabled: 'Scheduled checks',
|
|
206
245
|
enabledHint: 'Turn off to stop automatic runs; this page keeps working',
|
|
@@ -273,7 +312,12 @@ window.__ModuleLoader__.load({
|
|
|
273
312
|
langAuto: 'Follow the system',
|
|
274
313
|
langZh: '中文',
|
|
275
314
|
langEn: 'English',
|
|
276
|
-
toastTitle: '{n} plugin(s)
|
|
315
|
+
toastTitle: '{n} plugin(s) updated',
|
|
316
|
+
toastTitleFound: '{n} plugin(s) can update',
|
|
317
|
+
toastBadge: 'Updated',
|
|
318
|
+
toastBadgeFound: 'Update available',
|
|
319
|
+
toastBody: 'Applied in place, no restart needed. Here is what changed this round.',
|
|
320
|
+
toastBodyFound: 'Newer versions are available. With auto-install off this only checks; nothing is installed.',
|
|
277
321
|
toastMore: 'and {n} more',
|
|
278
322
|
toastDismiss: 'Got it',
|
|
279
323
|
keepTitle: 'Retention',
|
|
@@ -295,6 +339,7 @@ window.__ModuleLoader__.load({
|
|
|
295
339
|
rollbackFailed: 'Rollback failed',
|
|
296
340
|
rolledBack: 'rolled back',
|
|
297
341
|
policy: 'Update policy',
|
|
342
|
+
minutes: 'minutes',
|
|
298
343
|
min: 'min',
|
|
299
344
|
scope: 'These settings apply to this profile only',
|
|
300
345
|
about: 'About aupdate',
|
|
@@ -381,17 +426,12 @@ window.__ModuleLoader__.load({
|
|
|
381
426
|
if (typeof iso !== 'string' || iso === '') return ''
|
|
382
427
|
const when = new Date(iso)
|
|
383
428
|
if (Number.isNaN(when.getTime())) return iso
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
} catch {
|
|
391
|
-
const pad = (n) => String(n).padStart(2, '0')
|
|
392
|
-
return when.getFullYear() + '-' + pad(when.getMonth() + 1) + '-' + pad(when.getDate()) +
|
|
393
|
-
' ' + pad(when.getHours()) + ':' + pad(when.getMinutes()) + ':' + pad(when.getSeconds())
|
|
394
|
-
}
|
|
429
|
+
// 26/11/26 12:38:两位年/月/日 + 时:分,秒不显示。
|
|
430
|
+
// 「上一次检查」这类时间看到分就够,秒只会把统计卡挤窄;
|
|
431
|
+
// 走本地时区取值,不用 Intl 的日期顺序(中文环境会排成 2026/11/26)。
|
|
432
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
433
|
+
return pad(when.getFullYear() % 100) + '/' + pad(when.getMonth() + 1) + '/' + pad(when.getDate()) +
|
|
434
|
+
' ' + pad(when.getHours()) + ':' + pad(when.getMinutes())
|
|
395
435
|
}
|
|
396
436
|
|
|
397
437
|
/**
|
|
@@ -496,45 +536,161 @@ window.__ModuleLoader__.load({
|
|
|
496
536
|
return response.json()
|
|
497
537
|
}
|
|
498
538
|
|
|
499
|
-
/* ── styles
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
539
|
+
/* ── styles ─────────────────────────────────────────────────────────
|
|
540
|
+
*
|
|
541
|
+
* 视觉风格对齐 dsh-cost-meter 的设置页:分区卡片、小号分区标题、次级说明
|
|
542
|
+
* 文字、主/次两级小按钮、右下角通知卡;颜色一律走 --dsw-alias-* 主题变量
|
|
543
|
+
* 并带字面量回退,取不到变量也不会变成看不见的字。
|
|
544
|
+
*
|
|
545
|
+
* 原来每个节点都挂一坨内联 style,代价有三:
|
|
546
|
+
* - hover / focus-visible / 动画做不了(内联样式没有伪类);
|
|
547
|
+
* - 每次渲染重建几十个样式对象,输入框每敲一个字符就重建一次;
|
|
548
|
+
* - 颜色写死 rgba,亮色/暗色主题只能靠碰运气。
|
|
549
|
+
*
|
|
550
|
+
* 所以改成「一张只注入一次的样式表 + 类名」。选择器全部带 dsh-au- 前缀,
|
|
551
|
+
* 只作用于本插件自己的节点,不碰宿主和其它插件的样式。
|
|
552
|
+
*/
|
|
553
|
+
const CSS_ID = 'dsh-aupdate-styles'
|
|
554
|
+
|
|
555
|
+
const CSS_TEXT = `
|
|
556
|
+
.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)}
|
|
557
|
+
.dsh-au-head{display:flex;flex-direction:column;gap:3px}
|
|
558
|
+
.dsh-au-title{margin:0;font-size:15px;font-weight:600}
|
|
559
|
+
.dsh-au-sub{margin:0;font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
|
|
560
|
+
|
|
561
|
+
.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))}
|
|
562
|
+
.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))}
|
|
563
|
+
.dsh-au-note{margin:0;font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
|
|
564
|
+
.dsh-au-err{margin:0;font-size:12px;color:var(--dsw-alias-state-error-primary,#d9534f)}
|
|
565
|
+
|
|
566
|
+
.dsh-au-row{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
|
|
567
|
+
.dsh-au-col{display:flex;flex-direction:column;gap:6px}
|
|
568
|
+
.dsh-au-line{display:flex;align-items:baseline;gap:8px}
|
|
569
|
+
.dsh-au-labelbox{display:flex;flex-direction:column;gap:1px;min-width:0}
|
|
570
|
+
.dsh-au-label{font-weight:500}
|
|
571
|
+
.dsh-au-hint{font-size:11.5px;color:var(--dsw-alias-label-caption,rgba(128,128,128,.85))}
|
|
572
|
+
.dsh-au-status{font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
|
|
573
|
+
.dsh-au-meta{display:flex;gap:12px;flex-wrap:wrap;font-size:12px;color:var(--dsw-alias-label-tertiary,rgba(128,128,128,.95))}
|
|
574
|
+
.dsh-au-num{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary,inherit)}
|
|
575
|
+
|
|
576
|
+
.dsh-au-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(152px,1fr));gap:10px}
|
|
577
|
+
.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))}
|
|
578
|
+
.dsh-au-stat-k{font-size:11.5px;color:var(--dsw-alias-label-caption,rgba(128,128,128,.85))}
|
|
579
|
+
.dsh-au-stat-v{font-size:17px;font-weight:600;font-variant-numeric:tabular-nums;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
580
|
+
|
|
581
|
+
.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)}
|
|
582
|
+
.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%)}
|
|
583
|
+
.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%)}
|
|
584
|
+
.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%)}
|
|
585
|
+
.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%)}
|
|
586
|
+
|
|
587
|
+
.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}
|
|
588
|
+
.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}
|
|
589
|
+
.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}
|
|
590
|
+
.dsh-au-input:focus,.dsh-au-select:focus,.dsh-au-search:focus{outline:none;border-color:var(--dsw-alias-state-business-primary,#4d6bfe)}
|
|
591
|
+
.dsh-au-input:disabled,.dsh-au-select:disabled{opacity:.55}
|
|
592
|
+
|
|
593
|
+
.dsh-au-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
594
|
+
.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}
|
|
595
|
+
.dsh-au-btn:hover:not(:disabled){background:var(--dsw-alias-bg-mask-2,rgba(128,128,128,.12))}
|
|
596
|
+
.dsh-au-btn:active:not(:disabled){background:var(--dsw-alias-bg-mask-3,rgba(128,128,128,.18))}
|
|
597
|
+
.dsh-au-btn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4d6bfe);outline-offset:1px}
|
|
598
|
+
.dsh-au-btn:disabled{opacity:.5;cursor:default}
|
|
599
|
+
.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}
|
|
600
|
+
.dsh-au-primary:hover:not(:disabled){background:color-mix(in oklch,var(--dsw-alias-button-primary-fill,#4d6bfe),black 8%)}
|
|
601
|
+
.dsh-au-primary:active:not(:disabled){background:color-mix(in oklch,var(--dsw-alias-button-primary-fill,#4d6bfe),black 14%)}
|
|
602
|
+
|
|
603
|
+
.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)}
|
|
604
|
+
.dsh-au-check:disabled{cursor:default;opacity:.5}
|
|
605
|
+
|
|
606
|
+
.dsh-au-scroll{display:flex;flex-direction:column;gap:6px;max-height:264px;overflow-y:auto;padding-right:4px}
|
|
607
|
+
.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}
|
|
608
|
+
.dsh-au-pkgrow{display:flex;align-items:center;gap:8px;padding:3px 6px;border-radius:6px;cursor:pointer}
|
|
609
|
+
.dsh-au-pkgrow:hover{background:var(--dsw-alias-bg-mask-1,rgba(128,128,128,.08))}
|
|
610
|
+
.dsh-au-pkgname{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
611
|
+
.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}
|
|
612
|
+
.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}
|
|
613
|
+
.dsh-au-logtime{color:var(--dsw-alias-label-caption,rgba(128,128,128,.8));font-variant-numeric:tabular-nums}
|
|
614
|
+
.dsh-au-logtext{color:inherit}
|
|
615
|
+
|
|
616
|
+
.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}
|
|
617
|
+
.dsh-au-link:hover{color:var(--dsw-alias-state-business-primary,#4d6bfe);border-color:currentColor}
|
|
618
|
+
.dsh-au-linkext{margin-left:3px;opacity:.5}
|
|
619
|
+
|
|
620
|
+
/* 通知卡:照 dsh-cost-meter 的「峰/谷切换提醒」做。
|
|
621
|
+
* 那张卡是「圆点徽标 + 标题 + 正文 + 右对齐按钮」,并按事件换主色;
|
|
622
|
+
* 这里同一结构用于「发现可更新」,主色取 business 蓝,边框和投影都走主题。 */
|
|
623
|
+
.dsh-au-toast{--au-toast-accent:var(--dsw-alias-state-business-primary,#4d6bfe);position:fixed;right:16px;bottom:16px;z-index:2147483000;display:flex;flex-direction:column;gap:9px;box-sizing:border-box;width:340px;max-width:calc(100vw - 32px);padding:14px 16px;border-radius:14px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-toast-bg,#f7f7f8));color:var(--dsw-alias-label-primary,#1f2328);box-shadow:0 14px 36px #00000038;font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;animation:dsh-au-in .22s cubic-bezier(.2,.8,.2,1)}
|
|
624
|
+
.dsh-au-toast-badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-weight:600;letter-spacing:.4px;text-transform:uppercase;color:var(--au-toast-accent)}
|
|
625
|
+
.dsh-au-toast-badge:before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor;box-shadow:0 0 0 4px color-mix(in srgb,currentColor 16%,transparent);flex:0 0 auto}
|
|
626
|
+
.dsh-au-toast-head{display:flex;align-items:flex-start;gap:8px}
|
|
627
|
+
.dsh-au-toast-title{flex:1 1 auto;min-width:0;font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary,#1f2328);line-height:1.4}
|
|
628
|
+
.dsh-au-toast-x{flex:0 0 auto;width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0;margin:-2px -4px 0 0;border:0;border-radius:6px;background:transparent;color:inherit;font:inherit;font-size:16px;line-height:1;opacity:.6;cursor:pointer;transition:background .15s,opacity .15s}
|
|
629
|
+
.dsh-au-toast-x:hover{opacity:1;background:var(--dsw-alias-bg-mask-2,rgba(128,128,128,.14))}
|
|
630
|
+
.dsh-au-toast-body{color:var(--dsw-alias-label-secondary,rgba(128,128,128,1));line-height:1.55;font-size:12.5px}
|
|
631
|
+
.dsh-au-toast-list{display:flex;flex-direction:column;gap:2px;max-height:190px;overflow:auto;margin:0 -4px}
|
|
632
|
+
.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))}
|
|
633
|
+
.dsh-au-toast-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-primary,inherit)}
|
|
634
|
+
.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}
|
|
635
|
+
.dsh-au-toast-more{font-size:11.5px;color:var(--dsw-alias-label-caption,rgba(128,128,128,.85))}
|
|
636
|
+
.dsh-au-toast-foot{display:flex;align-items:center;justify-content:flex-end;gap:8px;padding-top:2px}
|
|
637
|
+
@keyframes dsh-au-in{from{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}
|
|
638
|
+
@media (prefers-reduced-motion:reduce){.dsh-au-toast{animation:none}}
|
|
639
|
+
`
|
|
640
|
+
|
|
641
|
+
/** 只注入一次:id 存在就跳过,重复挂载/热更新都不会叠出第二份样式表。 */
|
|
642
|
+
function installStyles() {
|
|
643
|
+
try {
|
|
644
|
+
const doc = typeof document === 'undefined' ? null : document
|
|
645
|
+
if (doc === null || doc.head === null) return
|
|
646
|
+
if (doc.getElementById(CSS_ID) !== null) return
|
|
647
|
+
const tag = doc.createElement('style')
|
|
648
|
+
tag.id = CSS_ID
|
|
649
|
+
tag.setAttribute('data-dsh-aupdate', 'styles')
|
|
650
|
+
tag.textContent = CSS_TEXT
|
|
651
|
+
doc.head.appendChild(tag)
|
|
652
|
+
} catch {}
|
|
536
653
|
}
|
|
537
654
|
|
|
655
|
+
/* 类名映射:组件里写 S.card 就等于挂上 dsh-au-section。 */
|
|
656
|
+
const S = {
|
|
657
|
+
wrap: 'dsh-au-wrap',
|
|
658
|
+
head: 'dsh-au-head',
|
|
659
|
+
title: 'dsh-au-title',
|
|
660
|
+
sub: 'dsh-au-sub',
|
|
661
|
+
card: 'dsh-au-section',
|
|
662
|
+
h: 'dsh-au-h',
|
|
663
|
+
note: 'dsh-au-note',
|
|
664
|
+
row: 'dsh-au-row',
|
|
665
|
+
labelBox: 'dsh-au-labelbox',
|
|
666
|
+
label: 'dsh-au-label',
|
|
667
|
+
hint: 'dsh-au-hint',
|
|
668
|
+
input: 'dsh-au-input',
|
|
669
|
+
select: 'dsh-au-select',
|
|
670
|
+
search: 'dsh-au-search',
|
|
671
|
+
actions: 'dsh-au-actions',
|
|
672
|
+
btn: 'dsh-au-btn',
|
|
673
|
+
btnPrimary: 'dsh-au-btn dsh-au-primary',
|
|
674
|
+
status: 'dsh-au-status',
|
|
675
|
+
err: 'dsh-au-err',
|
|
676
|
+
meta: 'dsh-au-meta',
|
|
677
|
+
cards: 'dsh-au-cards',
|
|
678
|
+
stat: 'dsh-au-stat',
|
|
679
|
+
statK: 'dsh-au-stat-k',
|
|
680
|
+
statV: 'dsh-au-stat-v',
|
|
681
|
+
check: 'dsh-au-check',
|
|
682
|
+
logBox: 'dsh-au-log',
|
|
683
|
+
logTime: 'dsh-au-logtime',
|
|
684
|
+
logText: 'dsh-au-logtext',
|
|
685
|
+
scrollList: 'dsh-au-scroll',
|
|
686
|
+
pkgList: 'dsh-au-pkglist',
|
|
687
|
+
pkgRow: 'dsh-au-pkgrow',
|
|
688
|
+
pkgName: 'dsh-au-pkgname',
|
|
689
|
+
pkgVer: 'dsh-au-pkgver',
|
|
690
|
+
link: 'dsh-au-link',
|
|
691
|
+
linkExt: 'dsh-au-linkext',
|
|
692
|
+
ver: 'dsh-au-num',
|
|
693
|
+
}
|
|
538
694
|
function Toggle(props) {
|
|
539
695
|
const { checked, onChange, disabled } = props
|
|
540
696
|
return h('input', {
|
|
@@ -542,16 +698,16 @@ window.__ModuleLoader__.load({
|
|
|
542
698
|
checked: checked === true,
|
|
543
699
|
disabled: disabled === true,
|
|
544
700
|
onChange: (event) => onChange(event.target.checked),
|
|
545
|
-
|
|
701
|
+
className: S.check,
|
|
546
702
|
})
|
|
547
703
|
}
|
|
548
704
|
|
|
549
705
|
function SwitchRow(props) {
|
|
550
706
|
const { label, hint, value, onChange, disabled } = props
|
|
551
|
-
return h('div', {
|
|
552
|
-
h('div', {
|
|
553
|
-
h('span', {
|
|
554
|
-
hint ? h('span', {
|
|
707
|
+
return h('div', { className: S.row },
|
|
708
|
+
h('div', { className: S.labelBox },
|
|
709
|
+
h('span', { className: S.label }, label),
|
|
710
|
+
hint ? h('span', { className: S.hint }, hint) : null,
|
|
555
711
|
),
|
|
556
712
|
h(Toggle, { checked: value, onChange, disabled }),
|
|
557
713
|
)
|
|
@@ -559,10 +715,10 @@ window.__ModuleLoader__.load({
|
|
|
559
715
|
|
|
560
716
|
function NumberRow(props) {
|
|
561
717
|
const { label, hint, value, onChange, min, max, disabled } = props
|
|
562
|
-
return h('div', {
|
|
563
|
-
h('div', {
|
|
564
|
-
h('span', {
|
|
565
|
-
hint ? h('span', {
|
|
718
|
+
return h('div', { className: S.row },
|
|
719
|
+
h('div', { className: S.labelBox },
|
|
720
|
+
h('span', { className: S.label }, label),
|
|
721
|
+
hint ? h('span', { className: S.hint }, hint) : null,
|
|
566
722
|
),
|
|
567
723
|
h('input', {
|
|
568
724
|
type: 'number',
|
|
@@ -574,7 +730,7 @@ window.__ModuleLoader__.load({
|
|
|
574
730
|
const next = Number(event.target.value)
|
|
575
731
|
if (Number.isFinite(next)) onChange(next)
|
|
576
732
|
},
|
|
577
|
-
|
|
733
|
+
className: S.input,
|
|
578
734
|
}),
|
|
579
735
|
)
|
|
580
736
|
}
|
|
@@ -585,17 +741,17 @@ window.__ModuleLoader__.load({
|
|
|
585
741
|
*/
|
|
586
742
|
function ClockRow(props) {
|
|
587
743
|
const { label, hint, value, onChange, disabled } = props
|
|
588
|
-
return h('div', {
|
|
589
|
-
h('div', {
|
|
590
|
-
h('span', {
|
|
591
|
-
hint ? h('span', {
|
|
744
|
+
return h('div', { className: S.row },
|
|
745
|
+
h('div', { className: S.labelBox },
|
|
746
|
+
h('span', { className: S.label }, label),
|
|
747
|
+
hint ? h('span', { className: S.hint }, hint) : null,
|
|
592
748
|
),
|
|
593
749
|
h('input', {
|
|
594
750
|
type: 'time',
|
|
595
751
|
value: typeof value === 'string' ? value : '03:00',
|
|
596
752
|
disabled: disabled === true,
|
|
597
753
|
onChange: (event) => onChange(event.target.value),
|
|
598
|
-
|
|
754
|
+
className: S.input,
|
|
599
755
|
}),
|
|
600
756
|
)
|
|
601
757
|
}
|
|
@@ -608,16 +764,16 @@ window.__ModuleLoader__.load({
|
|
|
608
764
|
*/
|
|
609
765
|
function SelectRow(props) {
|
|
610
766
|
const { label, hint, value, options, onChange, disabled } = props
|
|
611
|
-
return h('div', {
|
|
612
|
-
h('div', {
|
|
613
|
-
h('span', {
|
|
614
|
-
hint ? h('span', {
|
|
767
|
+
return h('div', { className: S.row },
|
|
768
|
+
h('div', { className: S.labelBox },
|
|
769
|
+
h('span', { className: S.label }, label),
|
|
770
|
+
hint ? h('span', { className: S.hint }, hint) : null,
|
|
615
771
|
),
|
|
616
772
|
h('select', {
|
|
617
773
|
value,
|
|
618
774
|
disabled: disabled === true,
|
|
619
775
|
onChange: (event) => onChange(event.target.value),
|
|
620
|
-
|
|
776
|
+
className: S.select,
|
|
621
777
|
}, options.map((option) => h('option', { key: option.value, value: option.value }, option.label))),
|
|
622
778
|
)
|
|
623
779
|
}
|
|
@@ -641,8 +797,8 @@ window.__ModuleLoader__.load({
|
|
|
641
797
|
if (typeof gate.lock === 'string' && gate.lock !== '') {
|
|
642
798
|
parts.push(T.gateLocked.replace('{who}', gate.lock))
|
|
643
799
|
}
|
|
644
|
-
return h('div', {
|
|
645
|
-
h('span', {
|
|
800
|
+
return h('div', { className: S.labelBox },
|
|
801
|
+
h('span', { className: S.hint }, parts.join(' · ')),
|
|
646
802
|
)
|
|
647
803
|
}
|
|
648
804
|
|
|
@@ -685,30 +841,31 @@ window.__ModuleLoader__.load({
|
|
|
685
841
|
commit(next)
|
|
686
842
|
}
|
|
687
843
|
|
|
688
|
-
if (all.length === 0) return h('span', {
|
|
844
|
+
if (all.length === 0) return h('span', { className: S.status }, T.pkgsEmpty)
|
|
689
845
|
|
|
690
|
-
return h('div', {
|
|
691
|
-
h('div', {
|
|
846
|
+
return h('div', { className: 'dsh-au-col' },
|
|
847
|
+
h('div', { className: S.actions },
|
|
692
848
|
h('input', {
|
|
693
849
|
type: 'search',
|
|
694
850
|
value: query,
|
|
695
851
|
placeholder: T.pkgsSearch,
|
|
696
852
|
onChange: (event) => setQuery(event.target.value),
|
|
697
|
-
|
|
853
|
+
className: S.search,
|
|
854
|
+
style: { flex: '1 1 160px' },
|
|
698
855
|
}),
|
|
699
|
-
h('button', { type: 'button',
|
|
700
|
-
h('button', { type: 'button',
|
|
701
|
-
h('span', {
|
|
856
|
+
h('button', { type: 'button', className: S.btn, onClick: () => setVisible(true) }, T.pkgsAll),
|
|
857
|
+
h('button', { type: 'button', className: S.btn, onClick: () => setVisible(false) }, T.pkgsNone),
|
|
858
|
+
h('span', { className: S.hint }, T.pkgsCount.replace('{n}', String(chosen.size))),
|
|
702
859
|
),
|
|
703
|
-
h('div', {
|
|
860
|
+
h('div', { className: S.pkgList },
|
|
704
861
|
rows.length === 0
|
|
705
|
-
? h('span', {
|
|
706
|
-
: rows.map((item) => h('label', { key: item.name,
|
|
862
|
+
? h('span', { className: S.status, style: { padding: '4px' } }, T.pkgsNoMatch)
|
|
863
|
+
: rows.map((item) => h('label', { key: item.name, className: S.pkgRow, title: item.name },
|
|
707
864
|
h(Toggle, { checked: chosen.has(item.name), onChange: () => toggle(item.name) }),
|
|
708
|
-
h('span', {
|
|
865
|
+
h('span', { className: S.pkgName }, item.name),
|
|
709
866
|
item.version === ''
|
|
710
|
-
? h('span', {
|
|
711
|
-
: h('span', {
|
|
867
|
+
? h('span', { className: S.pkgVer }, T.pkgsNotInstalled)
|
|
868
|
+
: h('span', { className: S.pkgVer }, item.version),
|
|
712
869
|
)),
|
|
713
870
|
),
|
|
714
871
|
)
|
|
@@ -732,8 +889,8 @@ window.__ModuleLoader__.load({
|
|
|
732
889
|
href,
|
|
733
890
|
target: '_blank',
|
|
734
891
|
rel: 'noopener noreferrer',
|
|
735
|
-
|
|
736
|
-
}, label, h('span', {
|
|
892
|
+
className: S.link,
|
|
893
|
+
}, label, h('span', { className: S.linkExt, 'aria-hidden': 'true' }, '↗'))
|
|
737
894
|
|
|
738
895
|
const share = async () => {
|
|
739
896
|
try {
|
|
@@ -748,44 +905,44 @@ window.__ModuleLoader__.load({
|
|
|
748
905
|
}
|
|
749
906
|
}
|
|
750
907
|
|
|
751
|
-
return h('div', {
|
|
752
|
-
h('
|
|
753
|
-
h('div', {
|
|
754
|
-
h('span', {
|
|
755
|
-
h('span', {
|
|
908
|
+
return h('div', { className: S.card },
|
|
909
|
+
h('h3', { className: S.h }, T.about),
|
|
910
|
+
h('div', { className: S.row },
|
|
911
|
+
h('span', { className: S.label }, T.aboutVersion),
|
|
912
|
+
h('span', { className: S.ver }, version === '' ? '…' : 'v' + version),
|
|
756
913
|
),
|
|
757
|
-
h('div', {
|
|
758
|
-
h('span', {
|
|
914
|
+
h('div', { className: S.row },
|
|
915
|
+
h('span', { className: S.label }, T.aboutChangelog),
|
|
759
916
|
extLink(CHANGELOG_URL, T.aboutChangelogLink),
|
|
760
917
|
),
|
|
761
|
-
h('div', {
|
|
762
|
-
h('span', {
|
|
918
|
+
h('div', { className: S.row },
|
|
919
|
+
h('span', { className: S.label }, T.aboutRepo),
|
|
763
920
|
extLink(REPO_URL, 'GitHub'),
|
|
764
921
|
),
|
|
765
|
-
h('div', {
|
|
766
|
-
h('span', {
|
|
922
|
+
h('div', { className: S.row },
|
|
923
|
+
h('span', { className: S.label }, T.aboutFeedback),
|
|
767
924
|
extLink(ISSUES_URL, T.aboutFeedbackLink),
|
|
768
925
|
),
|
|
769
|
-
h('div', {
|
|
770
|
-
h('span', {
|
|
771
|
-
h('span', {
|
|
772
|
-
h('span', {
|
|
926
|
+
h('div', { className: S.row },
|
|
927
|
+
h('span', { className: S.labelBox },
|
|
928
|
+
h('span', { className: S.label }, T.aboutStar),
|
|
929
|
+
h('span', { className: S.hint }, T.aboutStarHint),
|
|
773
930
|
),
|
|
774
931
|
extLink(STARS_URL, 'GitHub'),
|
|
775
932
|
),
|
|
776
|
-
h('div', {
|
|
777
|
-
h('span', {
|
|
778
|
-
h('span', {
|
|
779
|
-
h('span', {
|
|
933
|
+
h('div', { className: S.row },
|
|
934
|
+
h('span', { className: S.labelBox },
|
|
935
|
+
h('span', { className: S.label }, T.aboutShare),
|
|
936
|
+
h('span', { className: S.hint }, T.aboutShareHint),
|
|
780
937
|
),
|
|
781
|
-
h('button', { type: 'button',
|
|
938
|
+
h('button', { type: 'button', className: S.btn, onClick: () => void share() }, T.aboutShare),
|
|
782
939
|
),
|
|
783
940
|
// 项目地址可点开、可选中复制,失败时用户还有这一条路。
|
|
784
|
-
h('div', {
|
|
785
|
-
h('span', {
|
|
941
|
+
h('div', { className: S.row },
|
|
942
|
+
h('span', { className: S.label }, T.aboutProject),
|
|
786
943
|
extLink(REPO_URL, REPO_URL.replace('https://', '')),
|
|
787
944
|
),
|
|
788
|
-
shareHint ? h('span', {
|
|
945
|
+
shareHint ? h('span', { className: S.status }, shareHint) : null,
|
|
789
946
|
)
|
|
790
947
|
}
|
|
791
948
|
|
|
@@ -994,24 +1151,26 @@ window.__ModuleLoader__.load({
|
|
|
994
1151
|
}, [rolling, running, confirming])
|
|
995
1152
|
|
|
996
1153
|
if (phase === 'error') {
|
|
997
|
-
return h('div', {
|
|
998
|
-
h('span', {
|
|
999
|
-
h('div', {
|
|
1154
|
+
return h('div', { className: S.card },
|
|
1155
|
+
h('span', { className: S.err }, T.unavailable),
|
|
1156
|
+
h('div', { className: S.actions }, h('button', { type: 'button', className: S.btn, onClick: () => void load() }, T.retry)),
|
|
1000
1157
|
)
|
|
1001
1158
|
}
|
|
1002
1159
|
|
|
1003
1160
|
if (phase === 'loading' || draft === null) {
|
|
1004
|
-
return h('div', {
|
|
1161
|
+
return h('div', { className: S.card }, h('span', { className: S.status }, '…'))
|
|
1005
1162
|
}
|
|
1006
1163
|
|
|
1007
1164
|
const last = state?.lastRun
|
|
1165
|
+
const applied = appliedCount(last)
|
|
1008
1166
|
|
|
1009
|
-
return h('div', {
|
|
1010
|
-
h('div', {
|
|
1011
|
-
h('h3', {
|
|
1012
|
-
h('p', {
|
|
1167
|
+
return h('div', { className: S.wrap },
|
|
1168
|
+
h('div', { className: S.head },
|
|
1169
|
+
h('h3', { className: S.title }, T.title),
|
|
1170
|
+
h('p', { className: S.sub }, T.subtitle),
|
|
1013
1171
|
),
|
|
1014
|
-
h('div', {
|
|
1172
|
+
h('div', { className: S.card },
|
|
1173
|
+
h('h3', { className: S.h }, T.secGeneral),
|
|
1015
1174
|
h(SelectRow, {
|
|
1016
1175
|
label: T.language,
|
|
1017
1176
|
hint: T.languageHint,
|
|
@@ -1036,7 +1195,8 @@ window.__ModuleLoader__.load({
|
|
|
1036
1195
|
h(SwitchRow, { label: T.idleOnly, hint: T.idleOnlyHint, value: draft.idleOnly, onChange: (v) => patch('idleOnly', v), disabled: !draft.enabled }),
|
|
1037
1196
|
h(SwitchRow, { label: T.notify, hint: T.notifyHint, value: draft.notify, onChange: (v) => patch('notify', v) }),
|
|
1038
1197
|
),
|
|
1039
|
-
h('div', {
|
|
1198
|
+
h('div', { className: S.card },
|
|
1199
|
+
h('h3', { className: S.h }, T.secSchedule),
|
|
1040
1200
|
h(SelectRow, {
|
|
1041
1201
|
label: T.schedule,
|
|
1042
1202
|
hint: T.scheduleHint,
|
|
@@ -1068,9 +1228,9 @@ window.__ModuleLoader__.load({
|
|
|
1068
1228
|
h(NumberRow, { label: T.maxPerCycle, hint: T.maxPerCycleHint, value: draft.maxPerCycle, min: 0, max: 50, onChange: (v) => patch('maxPerCycle', v), disabled: !draft.enabled }),
|
|
1069
1229
|
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
1230
|
gateLine(state),
|
|
1071
|
-
h('div', {
|
|
1072
|
-
h('span', {
|
|
1073
|
-
h('span', {
|
|
1231
|
+
h('div', { className: S.labelBox },
|
|
1232
|
+
h('span', { className: S.label }, T.pkgsExclude),
|
|
1233
|
+
h('span', { className: S.hint }, T.pkgsExcludeHint),
|
|
1074
1234
|
),
|
|
1075
1235
|
h(PackagePicker, {
|
|
1076
1236
|
packages: state?.packages,
|
|
@@ -1079,14 +1239,14 @@ window.__ModuleLoader__.load({
|
|
|
1079
1239
|
}),
|
|
1080
1240
|
),
|
|
1081
1241
|
// 策略:预发布 / 跨大版本,决定「什么算可以装」。
|
|
1082
|
-
h('div', {
|
|
1083
|
-
h('
|
|
1242
|
+
h('div', { className: S.card },
|
|
1243
|
+
h('h3', { className: S.h }, T.policy),
|
|
1084
1244
|
h(SwitchRow, { label: T.allowMajor, hint: T.allowMajorHint, value: draft.allowMajor, onChange: (v) => patch('allowMajor', v) }),
|
|
1085
1245
|
h(SwitchRow, { label: T.allowPrerelease, hint: T.allowPrereleaseHint, value: draft.allowPrerelease, onChange: (v) => patch('allowPrerelease', v) }),
|
|
1086
1246
|
),
|
|
1087
|
-
h('div', {
|
|
1088
|
-
h('
|
|
1089
|
-
h('
|
|
1247
|
+
h('div', { className: S.card },
|
|
1248
|
+
h('h3', { className: S.h }, T.keepTitle),
|
|
1249
|
+
h('p', { className: S.note }, T.keepHint),
|
|
1090
1250
|
h(SelectRow, {
|
|
1091
1251
|
label: T.keepHistory,
|
|
1092
1252
|
value: String(draft.historyRetentionDays ?? 3),
|
|
@@ -1113,33 +1273,55 @@ window.__ModuleLoader__.load({
|
|
|
1113
1273
|
{ value: '0', label: T.keepForever },
|
|
1114
1274
|
],
|
|
1115
1275
|
}),
|
|
1116
|
-
h('div', {
|
|
1117
|
-
h('button', { type: 'button',
|
|
1118
|
-
cleanHint ? h('span', {
|
|
1276
|
+
h('div', { className: S.actions },
|
|
1277
|
+
h('button', { type: 'button', className: S.btn, disabled: cleaning, onClick: () => void doCleanup() }, cleaning ? T.cleaning : T.cleanNow),
|
|
1278
|
+
cleanHint ? h('span', { className: S.status }, cleanHint) : null,
|
|
1119
1279
|
),
|
|
1120
1280
|
),
|
|
1121
|
-
h('div', {
|
|
1281
|
+
h('div', { className: S.card },
|
|
1122
1282
|
// 按钮和它动作的对象放在一起:读「上一次」的人最想做的事就是再跑一次。
|
|
1123
|
-
h('div', {
|
|
1124
|
-
h('
|
|
1125
|
-
|
|
1283
|
+
h('div', { className: S.row },
|
|
1284
|
+
h('div', { className: S.labelBox },
|
|
1285
|
+
h('h3', { className: S.h }, T.lastRun),
|
|
1286
|
+
last === null || last === undefined ? h('span', { className: S.hint }, T.never) : null,
|
|
1287
|
+
),
|
|
1288
|
+
h('button', { type: 'button', className: S.btnPrimary, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
|
|
1126
1289
|
),
|
|
1127
1290
|
// 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
|
|
1128
|
-
progress
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
last === null || last === undefined
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1291
|
+
progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
|
|
1292
|
+
// 三张统计卡,照 cost-meter 概览页的写法:一眼看到「什么时候查的、
|
|
1293
|
+
// 查了多少、几个能更」,而不是一串用 · 拼起来的句子。
|
|
1294
|
+
last === null || last === undefined ? null : h('div', { className: S.cards },
|
|
1295
|
+
h('div', { className: S.stat },
|
|
1296
|
+
h('span', { className: S.statK }, T.lastChecked),
|
|
1297
|
+
h('span', { className: S.statV, title: last.at || '' }, formatWhen(last.at) || '—'),
|
|
1298
|
+
relativeWhen(last.at) ? h('span', { className: S.hint }, relativeWhen(last.at)) : null,
|
|
1299
|
+
),
|
|
1300
|
+
h('div', { className: S.stat },
|
|
1301
|
+
h('span', { className: S.statK }, T.checked),
|
|
1302
|
+
h('span', { className: S.statV }, String(last.checked ?? 0)),
|
|
1303
|
+
h('span', { className: S.hint }, T.packages),
|
|
1304
|
+
),
|
|
1305
|
+
h('div', { className: S.stat },
|
|
1306
|
+
h('span', { className: S.statK }, applied > 0 ? T.lastUpdated : T.lastUpdates),
|
|
1307
|
+
h('span', { className: S.statV }, String(applied > 0 ? applied : (last.updates?.length ?? 0))),
|
|
1308
|
+
// 卡片里标题已经是「已更新」,副标题只补量词,不再重复一遍「已更新」。
|
|
1309
|
+
h('span', { className: S.hint }, applied > 0
|
|
1310
|
+
? T.updatedHint
|
|
1311
|
+
: (last.updates?.length ?? 0) > 0 ? T.updates : T.upToDate),
|
|
1312
|
+
),
|
|
1313
|
+
),
|
|
1314
|
+
// 原因只说一遍:徽标承接状态词,正文承接句子,两者不重复同一句话。
|
|
1315
|
+
(() => {
|
|
1316
|
+
if (last === null || last === undefined) return null
|
|
1317
|
+
const reason = typeof last.reason === 'string' ? last.reason : ''
|
|
1318
|
+
const status = statusLabel(last.status)
|
|
1319
|
+
if (reason === '' && status === '') return null
|
|
1320
|
+
return h('div', { className: S.row },
|
|
1321
|
+
reason === '' ? null : h('span', { className: S.note }, reason),
|
|
1322
|
+
status === '' ? null : h('span', { className: badgeClass(last.status) }, status),
|
|
1323
|
+
)
|
|
1324
|
+
})(),
|
|
1143
1325
|
// 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
|
|
1144
1326
|
// 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
|
|
1145
1327
|
(() => {
|
|
@@ -1147,31 +1329,31 @@ window.__ModuleLoader__.load({
|
|
|
1147
1329
|
.map((item) => describeUpdate(item))
|
|
1148
1330
|
.filter((row) => row !== null)
|
|
1149
1331
|
if (rows.length === 0) return null
|
|
1150
|
-
return h('div', {
|
|
1332
|
+
return h('div', { className: S.scrollList },
|
|
1151
1333
|
rows.map((row, index) => h('div', {
|
|
1152
1334
|
key: row.name + ':' + index,
|
|
1153
|
-
|
|
1335
|
+
className: 'dsh-au-line',
|
|
1154
1336
|
},
|
|
1155
|
-
h('span', {
|
|
1156
|
-
row.versions === '' ? null : h('span', {
|
|
1337
|
+
h('span', { className: S.pkgName, title: row.name }, row.name),
|
|
1338
|
+
row.versions === '' ? null : h('span', { className: S.pkgVer }, row.versions),
|
|
1157
1339
|
)),
|
|
1158
1340
|
)
|
|
1159
1341
|
})(),
|
|
1160
|
-
runHint ? h('span', {
|
|
1342
|
+
runHint ? h('span', { className: S.status }, runHint) : null,
|
|
1161
1343
|
),
|
|
1162
1344
|
// 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
|
|
1163
|
-
h('div', {
|
|
1164
|
-
h('
|
|
1345
|
+
h('div', { className: S.card },
|
|
1346
|
+
h('h3', { className: S.h }, T.history),
|
|
1165
1347
|
(state?.history?.length ?? 0) === 0
|
|
1166
|
-
? h('span', {
|
|
1167
|
-
: h('div', {
|
|
1348
|
+
? h('span', { className: S.status }, T.historyEmpty)
|
|
1349
|
+
: h('div', { className: S.scrollList },
|
|
1168
1350
|
state.history.map((row, index) => h('div', {
|
|
1169
1351
|
key: row.name + '@' + row.at + ':' + index,
|
|
1170
|
-
|
|
1352
|
+
className: S.row,
|
|
1171
1353
|
},
|
|
1172
|
-
h('div', {
|
|
1354
|
+
h('div', { className: S.labelBox },
|
|
1173
1355
|
h('span', null, row.name + ' ' + (row.from ?? '?') + ' → ' + (row.to ?? '?')),
|
|
1174
|
-
h('span', {
|
|
1356
|
+
h('span', { className: S.hint, title: row.at || '' },
|
|
1175
1357
|
formatWhen(row.at) + (relativeWhen(row.at) ? '(' + relativeWhen(row.at) + ')' : '') +
|
|
1176
1358
|
(row.rolledBack === true ? ' · ' + T.rolledBack : '')),
|
|
1177
1359
|
),
|
|
@@ -1179,18 +1361,18 @@ window.__ModuleLoader__.load({
|
|
|
1179
1361
|
? null
|
|
1180
1362
|
: h('button', {
|
|
1181
1363
|
type: 'button',
|
|
1182
|
-
|
|
1364
|
+
className: confirming === row.name ? S.btnPrimary : S.btn,
|
|
1183
1365
|
disabled: rolling !== '' || running,
|
|
1184
1366
|
onClick: () => void doRollback(row.name),
|
|
1185
1367
|
}, rolling === row.name ? T.rollingBack : confirming === row.name ? T.rollback + '?' : T.rollback),
|
|
1186
1368
|
)),
|
|
1187
1369
|
),
|
|
1188
|
-
rollHint ? h('span', {
|
|
1370
|
+
rollHint ? h('span', { className: S.status }, rollHint) : null,
|
|
1189
1371
|
),
|
|
1190
1372
|
h(LogCard, null),
|
|
1191
1373
|
// 没有保存按钮:改动自己在 350ms 后落盘,这里只报它落没落成。
|
|
1192
|
-
saveHint ? h('span', {
|
|
1193
|
-
h('span', {
|
|
1374
|
+
saveHint ? h('span', { className: S.status }, saveHint) : null,
|
|
1375
|
+
h('span', { className: S.hint }, T.scope),
|
|
1194
1376
|
h(AboutCard, { version: state?.version }),
|
|
1195
1377
|
)
|
|
1196
1378
|
}
|
|
@@ -1234,36 +1416,36 @@ window.__ModuleLoader__.load({
|
|
|
1234
1416
|
const rows = (data?.rows ?? []).slice().reverse()
|
|
1235
1417
|
const total = data?.total ?? 0
|
|
1236
1418
|
|
|
1237
|
-
return h('div', {
|
|
1238
|
-
h('div', {
|
|
1239
|
-
h('div', {
|
|
1240
|
-
h('
|
|
1241
|
-
h('span', {
|
|
1419
|
+
return h('div', { className: S.card },
|
|
1420
|
+
h('div', { className: S.row },
|
|
1421
|
+
h('div', { className: S.labelBox },
|
|
1422
|
+
h('h3', { className: S.h }, T.logs),
|
|
1423
|
+
h('span', { className: S.hint }, T.logsHint + ' · ' + T.logsNewest),
|
|
1242
1424
|
),
|
|
1243
|
-
h('div', {
|
|
1425
|
+
h('div', { className: S.actions },
|
|
1244
1426
|
h('select', {
|
|
1245
1427
|
value: String(lines),
|
|
1246
1428
|
onChange: (event) => setLines(Number(event.target.value)),
|
|
1247
|
-
|
|
1429
|
+
className: S.select,
|
|
1248
1430
|
}, [100, 200, 500, 1000].map((n) => h('option', { key: n, value: String(n) }, n + ' ' + T.logsLines))),
|
|
1249
|
-
h('button', { type: 'button',
|
|
1431
|
+
h('button', { type: 'button', className: S.btn, onClick: () => setTick((n) => n + 1) }, T.logsRefresh),
|
|
1250
1432
|
),
|
|
1251
1433
|
),
|
|
1252
1434
|
h(SwitchRow, { label: T.logsAuto, hint: T.logsAutoHint, value: auto, onChange: setAuto }),
|
|
1253
1435
|
phase === 'loading' && data === null
|
|
1254
|
-
? h('span', {
|
|
1436
|
+
? h('span', { className: S.status }, '…')
|
|
1255
1437
|
: phase === 'missing' || (data !== null && data.exists === false)
|
|
1256
|
-
? h('span', {
|
|
1438
|
+
? h('span', { className: S.status }, T.logsMissing)
|
|
1257
1439
|
: rows.length === 0
|
|
1258
|
-
? h('span', {
|
|
1259
|
-
: h('pre', {
|
|
1440
|
+
? h('span', { className: S.status }, T.logsEmpty)
|
|
1441
|
+
: h('pre', { className: S.logBox, title: data?.path || '' },
|
|
1260
1442
|
rows.map((row, index) => h('div', { key: index },
|
|
1261
|
-
row.at ? h('span', {
|
|
1262
|
-
h('span', {
|
|
1443
|
+
row.at ? h('span', { className: S.logTime }, formatLogWhen(row.at) + ' ') : null,
|
|
1444
|
+
h('span', { className: S.logText }, row.text),
|
|
1263
1445
|
)),
|
|
1264
1446
|
),
|
|
1265
1447
|
data !== null && data.exists !== false
|
|
1266
|
-
? h('div', {
|
|
1448
|
+
? h('div', { className: S.meta },
|
|
1267
1449
|
h('span', { title: data.path || '' }, T.logsTotal.replace('{n}', String(total))),
|
|
1268
1450
|
data.rotated === true ? h('span', null, T.logsRotated) : null,
|
|
1269
1451
|
)
|
|
@@ -1295,10 +1477,12 @@ window.__ModuleLoader__.load({
|
|
|
1295
1477
|
? (T.enabled + ':' + T.off)
|
|
1296
1478
|
: last === null || last === undefined
|
|
1297
1479
|
? T.never
|
|
1298
|
-
: (last
|
|
1299
|
-
? (last
|
|
1300
|
-
:
|
|
1301
|
-
|
|
1480
|
+
: appliedCount(last) > 0
|
|
1481
|
+
? appliedCount(last) + ' ' + T.updatedUnit
|
|
1482
|
+
: (last.updates?.length ?? 0) > 0
|
|
1483
|
+
? (last.updates?.length ?? 0) + ' ' + T.updates
|
|
1484
|
+
: T.upToDate
|
|
1485
|
+
return h('span', { className: S.status }, text)
|
|
1302
1486
|
}
|
|
1303
1487
|
|
|
1304
1488
|
/* ── 更新提醒 ────────────────────────────────────────────────────────
|
|
@@ -1345,6 +1529,19 @@ window.__ModuleLoader__.load({
|
|
|
1345
1529
|
return { name, versions: from + ' → ' + to }
|
|
1346
1530
|
}
|
|
1347
1531
|
|
|
1532
|
+
/**
|
|
1533
|
+
* 这一轮「真的换掉了几个版本」。
|
|
1534
|
+
*
|
|
1535
|
+
* lastRun.updates 是「发现了哪些新版本」,安装被关掉、被让开、装失败时它照样有值。
|
|
1536
|
+
* 界面上说「已更新 N 个」就必须是装成了的,否则把「查到 4 个」写成「更新了 4 个」
|
|
1537
|
+
* 是在撒谎。installed 里失败的条目带 ' !failed',要减掉。
|
|
1538
|
+
*/
|
|
1539
|
+
function appliedCount(last) {
|
|
1540
|
+
if (last === null || last === undefined) return 0
|
|
1541
|
+
const rows = Array.isArray(last.installed) ? last.installed : []
|
|
1542
|
+
return rows.filter((row) => typeof row === 'string' && !row.endsWith('!failed')).length
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1348
1545
|
function updateSignature(updates) {
|
|
1349
1546
|
return (Array.isArray(updates) ? updates : [])
|
|
1350
1547
|
.map((item) => describeUpdate(item))
|
|
@@ -1354,44 +1551,63 @@ window.__ModuleLoader__.load({
|
|
|
1354
1551
|
.join('|')
|
|
1355
1552
|
}
|
|
1356
1553
|
|
|
1357
|
-
function showUpdateToast(updates) {
|
|
1554
|
+
function showUpdateToast(updates, applied) {
|
|
1358
1555
|
if (toastOpen) return
|
|
1359
1556
|
const doc = typeof document === 'undefined' ? null : document
|
|
1360
1557
|
if (doc === null || doc.body === null) return
|
|
1361
1558
|
const rows = (Array.isArray(updates) ? updates : []).map((item) => describeUpdate(item)).filter((row) => row !== null)
|
|
1362
1559
|
if (rows.length === 0) return
|
|
1363
1560
|
toastOpen = true
|
|
1561
|
+
// 提醒可能在设置页之外弹出来,样式表没装就先补上(幂等)。
|
|
1562
|
+
installStyles()
|
|
1364
1563
|
const box = doc.createElement('div')
|
|
1365
1564
|
box.setAttribute('data-dsh-aupdate', 'toast')
|
|
1366
|
-
box.
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1565
|
+
box.className = 'dsh-au-toast'
|
|
1566
|
+
box.setAttribute('role', 'status')
|
|
1567
|
+
box.setAttribute('aria-live', 'polite')
|
|
1568
|
+
|
|
1569
|
+
// 结构与 cost-meter 的「峰/谷切换提醒」一致:圆点徽标 → 标题行(含 ×)
|
|
1570
|
+
// → 一句正文 → 清单 → 右对齐按钮。徽标是那张卡最好认的一处,这里复用它。
|
|
1571
|
+
const badge = doc.createElement('div')
|
|
1572
|
+
badge.className = 'dsh-au-toast-badge'
|
|
1573
|
+
badge.textContent = applied > 0 ? T.toastBadge : T.toastBadgeFound
|
|
1574
|
+
box.appendChild(badge)
|
|
1575
|
+
|
|
1576
|
+
const head = doc.createElement('div')
|
|
1577
|
+
head.className = 'dsh-au-toast-head'
|
|
1375
1578
|
const title = doc.createElement('div')
|
|
1376
|
-
title.
|
|
1377
|
-
|
|
1378
|
-
|
|
1579
|
+
title.className = 'dsh-au-toast-title'
|
|
1580
|
+
// 真的装完了才说「已更新」;只查到、没动手时说「可更新」,别把「发现」说成「装了」。
|
|
1581
|
+
title.textContent = (applied > 0 ? T.toastTitle : T.toastTitleFound).replace('{n}', String(rows.length))
|
|
1582
|
+
const xBtn = doc.createElement('button')
|
|
1583
|
+
xBtn.type = 'button'
|
|
1584
|
+
xBtn.className = 'dsh-au-toast-x'
|
|
1585
|
+
xBtn.textContent = '×'
|
|
1586
|
+
xBtn.setAttribute('aria-label', T.toastDismiss)
|
|
1587
|
+
head.appendChild(title)
|
|
1588
|
+
head.appendChild(xBtn)
|
|
1589
|
+
box.appendChild(head)
|
|
1590
|
+
|
|
1591
|
+
const body = doc.createElement('div')
|
|
1592
|
+
body.className = 'dsh-au-toast-body'
|
|
1593
|
+
body.textContent = applied > 0 ? T.toastBody : T.toastBodyFound
|
|
1594
|
+
box.appendChild(body)
|
|
1379
1595
|
|
|
1380
1596
|
const list = doc.createElement('div')
|
|
1381
|
-
|
|
1382
|
-
|
|
1597
|
+
list.className = 'dsh-au-toast-list'
|
|
1598
|
+
// 超过 12 条就在框内滚动:提醒不该占掉半屏。
|
|
1383
1599
|
for (const row of rows.slice(0, 12)) {
|
|
1384
1600
|
const line = doc.createElement('div')
|
|
1385
|
-
line.
|
|
1601
|
+
line.className = 'dsh-au-toast-item'
|
|
1386
1602
|
const nameEl = doc.createElement('span')
|
|
1603
|
+
nameEl.className = 'dsh-au-toast-name'
|
|
1387
1604
|
nameEl.textContent = row.name
|
|
1388
1605
|
// 包名可能很长(@scope/name),压缩它而不是压缩版本。
|
|
1389
|
-
nameEl.style.cssText = 'flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap'
|
|
1390
1606
|
line.appendChild(nameEl)
|
|
1391
1607
|
if (row.versions !== '') {
|
|
1392
1608
|
const verEl = doc.createElement('span')
|
|
1609
|
+
verEl.className = 'dsh-au-toast-ver'
|
|
1393
1610
|
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
1611
|
line.appendChild(verEl)
|
|
1396
1612
|
}
|
|
1397
1613
|
list.appendChild(line)
|
|
@@ -1400,21 +1616,38 @@ window.__ModuleLoader__.load({
|
|
|
1400
1616
|
|
|
1401
1617
|
if (rows.length > 12) {
|
|
1402
1618
|
const more = doc.createElement('div')
|
|
1619
|
+
more.className = 'dsh-au-toast-more'
|
|
1403
1620
|
more.textContent = T.toastMore.replace('{n}', String(rows.length - 12))
|
|
1404
|
-
more.style.cssText = 'font-size:11.5px;opacity:0.6'
|
|
1405
1621
|
box.appendChild(more)
|
|
1406
1622
|
}
|
|
1407
1623
|
|
|
1624
|
+
const foot = doc.createElement('div')
|
|
1625
|
+
foot.className = 'dsh-au-toast-foot'
|
|
1408
1626
|
const close = doc.createElement('button')
|
|
1409
1627
|
close.type = 'button'
|
|
1628
|
+
close.className = 'dsh-au-btn dsh-au-primary'
|
|
1410
1629
|
close.textContent = T.toastDismiss
|
|
1411
|
-
|
|
1630
|
+
foot.appendChild(close)
|
|
1631
|
+
box.appendChild(foot)
|
|
1632
|
+
|
|
1633
|
+
let closed = false
|
|
1412
1634
|
const dismiss = () => {
|
|
1635
|
+
if (closed) return
|
|
1636
|
+
closed = true
|
|
1413
1637
|
toastOpen = false
|
|
1638
|
+
try { doc.removeEventListener('keydown', onKey, true) } catch {}
|
|
1414
1639
|
try { box.remove() } catch {}
|
|
1415
1640
|
}
|
|
1641
|
+
// Esc 也能关:浮层挡住右下角时,键盘用户不该只能等它自己消失。
|
|
1642
|
+
const onKey = (event) => {
|
|
1643
|
+
if (event.key === 'Escape') {
|
|
1644
|
+
event.stopPropagation()
|
|
1645
|
+
dismiss()
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1416
1648
|
close.addEventListener('click', dismiss)
|
|
1417
|
-
|
|
1649
|
+
xBtn.addEventListener('click', dismiss)
|
|
1650
|
+
try { doc.addEventListener('keydown', onKey, true) } catch {}
|
|
1418
1651
|
doc.body.appendChild(box)
|
|
1419
1652
|
// 不点也不会一直挂着:15 秒后自己消失,省得挡住下面的界面。
|
|
1420
1653
|
setTimeout(dismiss, 15000)
|
|
@@ -1434,7 +1667,7 @@ window.__ModuleLoader__.load({
|
|
|
1434
1667
|
const sig = updateSignature(updates)
|
|
1435
1668
|
if (sig !== notifiedMark()) {
|
|
1436
1669
|
markNotified(sig)
|
|
1437
|
-
showUpdateToast(updates)
|
|
1670
|
+
showUpdateToast(updates, appliedCount(state?.lastRun))
|
|
1438
1671
|
}
|
|
1439
1672
|
}
|
|
1440
1673
|
}
|
|
@@ -1453,6 +1686,8 @@ window.__ModuleLoader__.load({
|
|
|
1453
1686
|
return {
|
|
1454
1687
|
inject: ['slots'],
|
|
1455
1688
|
apply(ctx) {
|
|
1689
|
+
// 样式表只注入一次;先把类挂上去,第一帧就是最终样子,不会闪一下。
|
|
1690
|
+
installStyles()
|
|
1456
1691
|
// 提醒跟着插件一起上、一起卸:ctx.effect 收的是清理函数。
|
|
1457
1692
|
if (typeof ctx.effect === 'function') ctx.effect(startUpdateNotifier, 'dsh-aupdate: update notices')
|
|
1458
1693
|
// key 的格式是「包名#条目id」:本插件在 cordis.patch.yml 里的条目 id 就是包名本身,
|
package/package.json
CHANGED