dsh-aupdate 0.8.4 → 0.8.6
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 +47 -11
- package/client.js +225 -290
- package/index.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,10 +169,12 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
169
169
|
|
|
170
170
|
### 关于 aupdate
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
「关于 aupdate」在**版本管理页**底部(0.8.6 起从设置页搬过去):版本号、DSH 版本、查看更新日志、
|
|
173
|
+
源码仓库、提交问题、分享(复制项目地址到剪贴板;失败时地址本身也能点开复制),两列排布,
|
|
174
|
+
项目地址占整行。外链一律 `target=_blank` + `rel=noopener noreferrer`。
|
|
175
|
+
|
|
176
|
+
「点个星」从关于里删掉了:整页最底部有一条 Star 条(和 `dsh-free-search` 同款,
|
|
177
|
+
`⭐ 顺手留颗 Star,作者能高兴一整天` → 右侧 `行,给你一颗 Star`),整条就是指向仓库的链接。
|
|
176
178
|
|
|
177
179
|
### 「上一次」不会再被重启清空
|
|
178
180
|
|
|
@@ -214,7 +216,13 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
|
|
|
214
216
|
|
|
215
217
|
## 版本管理
|
|
216
218
|
|
|
217
|
-
|
|
219
|
+
「插件」页顶栏多了一个「版本管理」标签,它是这个插件的主页:**工具条**(搜索、检查并安装、
|
|
220
|
+
一键升级、升级选中、注册表、复制诊断、设置)→ **现状**(上次检查时间、可升级、已更新、需处理
|
|
221
|
+
四格数字,一句结论和状态徽标)→ **插件列表** → **更新记录** → **运行日志** → **关于** →
|
|
222
|
+
最底部 **Star 条**。设置页只留参数调节(开关、数字、调度、安装源、兼容预检、保留期限),
|
|
223
|
+
观测类内容全在这一页。
|
|
224
|
+
|
|
225
|
+
下面这段是版本列表本身的说明:它列出每个已装插件、已装版本,以及该插件的全部已发布
|
|
218
226
|
版本;点某一版就直接切过去。走的是和定时更新同一条安装路径——安装、回读磁盘上的版本、记一条
|
|
219
227
|
更新记录、就地生效——所以切完能在「更新记录」里看到,也能再回滚回来。
|
|
220
228
|
|
|
@@ -224,7 +232,17 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
|
|
|
224
232
|
|
|
225
233
|
这一页还把 aupdate 自己的设置嵌了进来(工具条上的「设置」),改完不用切回设置页。
|
|
226
234
|
|
|
227
|
-
|
|
235
|
+
工具条从左到右:搜索、主按钮、一键升级、升级选中 N 个、注册表、复制诊断、设置。
|
|
236
|
+
|
|
237
|
+
主按钮的名字跟着「自动安装新版本」走:开着时叫**检查并安装**(重新查一遍 registry,查到就装),
|
|
238
|
+
关掉时叫**只检查**(查到只列出来,不动手)。它以前一律叫「检查更新」、一律只查不装,于是开着
|
|
239
|
+
自动安装的人点完发现什么都没装,只能再去点「一键升级」——现在名字和动作对上了。
|
|
240
|
+
|
|
241
|
+
**一键升级**永远真的装:它带 `force`,不受「自动安装」这个开关限制(那个开关管的是定时轮次,
|
|
242
|
+
不是人按下的按钮),并且复用 10 分钟内的查询结果,点了就动手、不重查。
|
|
243
|
+
|
|
244
|
+
「自动安装」关掉时,查到的可更新插件会**排到列表最上面**:这时「看得见」就等于「要不要动手」,
|
|
245
|
+
埋在一屏之外等于没查到。开着自动安装时不需要这个排序。
|
|
228
246
|
顶部三个数字分别是**需处理**(已装版本声明的 DSH 范围不满足,或者读不到已装版本——这些包很可能
|
|
229
247
|
根本没被加载,升级救不了它们)、**可升级**、**已装**。
|
|
230
248
|
|
|
@@ -486,12 +504,16 @@ The Last run card states the outcome once. Clicking Check now only adds a short
|
|
|
486
504
|
the same reason plus a raw status word underneath. Status words are a localized fallback
|
|
487
505
|
used only when no rendered reason exists.
|
|
488
506
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
507
|
+
**About aupdate** now lives at the bottom of the **Versions** tab (moved out of the settings page
|
|
508
|
+
in 0.8.6): version, DSH version, changelog, source repository, issue tracker and Share (copies the
|
|
509
|
+
project URL; the URL is also selectable if the copy fails), laid out as two key/value columns with
|
|
510
|
+
the project URL on its own full-width row. External links use target=_blank with
|
|
493
511
|
rel=noopener noreferrer.
|
|
494
512
|
|
|
513
|
+
The Star row was removed from About: the very bottom of the page carries a Star bar styled after
|
|
514
|
+
`dsh-free-search` (`⭐ 顺手留颗 Star,作者能高兴一整天` with `行,给你一颗 Star` on the right),
|
|
515
|
+
and the whole bar links to the repository.
|
|
516
|
+
|
|
495
517
|
The last run's outcome (when, how many checked, how many updatable, how many installed,
|
|
496
518
|
why it failed) is persisted to `~/.dsh/aupdate-lastrun.json` and survives a restart. It
|
|
497
519
|
used to live in memory only, so every restart reset the card to "never run" and looked
|
|
@@ -519,7 +541,21 @@ first paint: fetching packuments for a whole page of packages is unusably slow o
|
|
|
519
541
|
This page also embeds aupdate's own settings (the **Settings** button in the toolbar), so there is
|
|
520
542
|
no need to switch back to the settings page.
|
|
521
543
|
|
|
522
|
-
The toolbar is: search,
|
|
544
|
+
The toolbar is: search, the primary button, Upgrade all, Upgrade the N selected, Registries,
|
|
545
|
+
Copy diagnostics, Settings.
|
|
546
|
+
|
|
547
|
+
The primary button follows **Install new versions**: when that is on it reads **Check and install**
|
|
548
|
+
(re-queries the registry and installs what it finds); when it is off it reads **Check only** (lists
|
|
549
|
+
what is newer, touches nothing). It used to be called "Check now" and always ran a check-only pass,
|
|
550
|
+
so anyone with auto-install on saw nothing installed and had to press Upgrade all afterwards.
|
|
551
|
+
|
|
552
|
+
**Upgrade all** always installs: it sends `force`, so the auto-install switch does not gate it (that
|
|
553
|
+
switch governs scheduled cycles, not a button someone pressed), and it reuses a lookup less than 10
|
|
554
|
+
minutes old instead of re-querying.
|
|
555
|
+
|
|
556
|
+
With auto-install off, plugins that can update are sorted to the top of the list: seeing them is the
|
|
557
|
+
decision, and burying them below the fold is the same as not finding them. With auto-install on the
|
|
558
|
+
sort is unnecessary, so the list stays alphabetical.
|
|
523
559
|
Registries, Copy diagnostics, Settings. The three numbers on top are **Needs attention** (the
|
|
524
560
|
installed version declares a DSH range this host does not satisfy, or the installed version is
|
|
525
561
|
unreadable — those bundles are likely not loaded at all, and upgrading cannot fix them),
|
package/client.js
CHANGED
|
@@ -144,6 +144,8 @@ window.__ModuleLoader__.load({
|
|
|
144
144
|
lagNote: '{n} 个插件的镜像还没同步,官方源已经有新版本',
|
|
145
145
|
blockedNote: '{n} 个版本在这台 DSH 上装不了',
|
|
146
146
|
versionsTab: '版本管理',
|
|
147
|
+
starPrompt: '顺手留颗 Star,作者能高兴一整天',
|
|
148
|
+
starCta: '行,给你一颗 Star',
|
|
147
149
|
versionsTitle: '版本管理',
|
|
148
150
|
versionsSubtitle: '每个已装插件的全部已发布版本,点一下就切过去',
|
|
149
151
|
versionsSearch: '搜索插件名',
|
|
@@ -164,7 +166,8 @@ window.__ModuleLoader__.load({
|
|
|
164
166
|
versionsNoop: '已经是这一版',
|
|
165
167
|
versionsFail: '切换失败',
|
|
166
168
|
versionsTotal: '共 {n} 个版本',
|
|
167
|
-
|
|
169
|
+
versionsCheckInstall: '检查并安装',
|
|
170
|
+
versionsCheckOnly: '只检查',
|
|
168
171
|
versionsUpgradeAll: '一键升级',
|
|
169
172
|
versionsUpgradePicked: '升级选中 {n}',
|
|
170
173
|
versionsSources: '注册表',
|
|
@@ -260,8 +263,6 @@ window.__ModuleLoader__.load({
|
|
|
260
263
|
aboutRepo: '源码仓库',
|
|
261
264
|
aboutFeedback: '反馈问题',
|
|
262
265
|
aboutFeedbackLink: '提交问题',
|
|
263
|
-
aboutStar: '点个星',
|
|
264
|
-
aboutStarHint: '在 GitHub 上点 Star,让更多人看到',
|
|
265
266
|
aboutShare: '分享',
|
|
266
267
|
aboutShareHint: '复制项目地址,分享给朋友',
|
|
267
268
|
aboutShareDone: '项目地址已复制',
|
|
@@ -349,6 +350,8 @@ window.__ModuleLoader__.load({
|
|
|
349
350
|
lagNote: '{n} plugin(s) not synced to the mirror yet; upstream already has newer',
|
|
350
351
|
blockedNote: '{n} version(s) cannot be installed on this DSH',
|
|
351
352
|
versionsTab: 'Versions',
|
|
353
|
+
starPrompt: 'Leave a star — the author will beam all day',
|
|
354
|
+
starCta: 'Give a star',
|
|
352
355
|
versionsTitle: 'Version manager',
|
|
353
356
|
versionsSubtitle: 'Every published version of every installed plugin; click one to switch',
|
|
354
357
|
versionsSearch: 'Search plugin names',
|
|
@@ -369,7 +372,8 @@ window.__ModuleLoader__.load({
|
|
|
369
372
|
versionsNoop: 'Already on this version',
|
|
370
373
|
versionsFail: 'Switch failed',
|
|
371
374
|
versionsTotal: '{n} versions',
|
|
372
|
-
|
|
375
|
+
versionsCheckInstall: 'Check and install',
|
|
376
|
+
versionsCheckOnly: 'Check only',
|
|
373
377
|
versionsUpgradeAll: 'Upgrade all',
|
|
374
378
|
versionsUpgradePicked: 'Upgrade {n}',
|
|
375
379
|
versionsSources: 'Registries',
|
|
@@ -465,8 +469,6 @@ window.__ModuleLoader__.load({
|
|
|
465
469
|
aboutRepo: 'Source code',
|
|
466
470
|
aboutFeedback: 'Report an issue',
|
|
467
471
|
aboutFeedbackLink: 'Open an issue',
|
|
468
|
-
aboutStar: 'Star',
|
|
469
|
-
aboutStarHint: 'Star on GitHub to help others find it',
|
|
470
472
|
aboutShare: 'Share',
|
|
471
473
|
aboutShareHint: 'Copy the project link to share',
|
|
472
474
|
aboutShareDone: 'Project link copied',
|
|
@@ -747,6 +749,27 @@ window.__ModuleLoader__.load({
|
|
|
747
749
|
/* 通知卡:照 dsh-cost-meter 的「峰/谷切换提醒」做。
|
|
748
750
|
* 那张卡是「圆点徽标 + 标题 + 正文 + 右对齐按钮」,并按事件换主色;
|
|
749
751
|
* 这里同一结构用于「发现可更新」,主色取 business 蓝,边框和投影都走主题。 */
|
|
752
|
+
/* ── Star 条:照 dsh-free-search,整条是链接,右侧琥珀色 CTA ── */
|
|
753
|
+
.dsh-au-star{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:9px 12px;border-radius:10px;border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.08));background:rgba(255,196,0,.07);color:inherit;text-decoration:none;font-size:12.5px;line-height:1.4;transition:background .15s}
|
|
754
|
+
.dsh-au-star:hover{background:rgba(255,196,0,.16)}
|
|
755
|
+
.dsh-au-star:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4d6bfe);outline-offset:1px}
|
|
756
|
+
.dsh-au-starIcon{font-size:15px;line-height:1}
|
|
757
|
+
.dsh-au-starCta{margin-left:auto;color:#8a6d00;font-weight:600;white-space:nowrap}
|
|
758
|
+
@media (prefers-color-scheme:dark){.dsh-au-star{border-color:rgba(255,255,255,.14);background:rgba(255,196,0,.09)}.dsh-au-starCta{color:#e8c15a}}
|
|
759
|
+
/* ── 关于:两列键值 + 一条分隔线 + 贯穿整行的项目地址 ── */
|
|
760
|
+
.dsh-au-grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 22px}
|
|
761
|
+
.dsh-au-kv{display:flex;align-items:baseline;justify-content:space-between;gap:10px;min-width:0;font-size:12.5px;padding:2px 0}
|
|
762
|
+
.dsh-au-kv>span:first-child{color:var(--dsw-alias-label-secondary,rgba(0,0,0,.65));flex:0 0 auto}
|
|
763
|
+
.dsh-au-kv>span:last-child,.dsh-au-kv>a{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
764
|
+
.dsh-au-rule{height:1px;background:var(--dsw-alias-border-l1,rgba(128,128,128,.18));margin:4px 0}
|
|
765
|
+
/* ── 列表:行更紧、悬停底色;记录单行 ── */
|
|
766
|
+
.dsh-au-plist{display:flex;flex-direction:column;max-height:340px;overflow:auto}
|
|
767
|
+
.dsh-au-plist>.dsh-au-row{padding:5px 2px;border-radius:6px}
|
|
768
|
+
.dsh-au-plist>.dsh-au-row:hover{background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.04))}
|
|
769
|
+
.dsh-au-rec{display:flex;flex-direction:column;max-height:200px;overflow:auto}
|
|
770
|
+
.dsh-au-rec>.dsh-au-row{padding:5px 2px;border-radius:6px}
|
|
771
|
+
.dsh-au-rec>.dsh-au-row:hover{background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.04))}
|
|
772
|
+
|
|
750
773
|
.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)}
|
|
751
774
|
.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)}
|
|
752
775
|
.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}
|
|
@@ -825,7 +848,7 @@ window.__ModuleLoader__.load({
|
|
|
825
848
|
pkgVer: 'dsh-au-pkgver',
|
|
826
849
|
link: 'dsh-au-link',
|
|
827
850
|
linkExt: 'dsh-au-linkext',
|
|
828
|
-
|
|
851
|
+
num: 'dsh-au-num',
|
|
829
852
|
}
|
|
830
853
|
function Toggle(props) {
|
|
831
854
|
const { checked, onChange, disabled } = props
|
|
@@ -1020,6 +1043,7 @@ window.__ModuleLoader__.load({
|
|
|
1020
1043
|
useLang()
|
|
1021
1044
|
const [shareHint, setShareHint] = useState('')
|
|
1022
1045
|
const version = props.version || ''
|
|
1046
|
+
const dshVersion = props.dshVersion || ''
|
|
1023
1047
|
|
|
1024
1048
|
const extLink = (href, label) => h('a', {
|
|
1025
1049
|
href,
|
|
@@ -1041,43 +1065,25 @@ window.__ModuleLoader__.load({
|
|
|
1041
1065
|
}
|
|
1042
1066
|
}
|
|
1043
1067
|
|
|
1068
|
+
// 两列键值:同类相邻(版本/DSH 版本、更新日志/源码仓库、反馈/分享)。
|
|
1069
|
+
// 「点个星」不在这里了——Star 条在整页最底下。
|
|
1070
|
+
const kv = (key, label, value) => h('div', { className: 'dsh-au-kv', key },
|
|
1071
|
+
h('span', null, label),
|
|
1072
|
+
value,
|
|
1073
|
+
)
|
|
1074
|
+
|
|
1044
1075
|
return h('div', { className: S.card },
|
|
1045
1076
|
h('h3', { className: S.h }, T.about),
|
|
1046
|
-
h('div', { className:
|
|
1047
|
-
h('span', { className: S.
|
|
1048
|
-
h('span', { className: S.
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
),
|
|
1054
|
-
h('div', { className: S.row },
|
|
1055
|
-
h('span', { className: S.label }, T.aboutRepo),
|
|
1056
|
-
extLink(REPO_URL, 'GitHub'),
|
|
1057
|
-
),
|
|
1058
|
-
h('div', { className: S.row },
|
|
1059
|
-
h('span', { className: S.label }, T.aboutFeedback),
|
|
1060
|
-
extLink(ISSUES_URL, T.aboutFeedbackLink),
|
|
1061
|
-
),
|
|
1062
|
-
h('div', { className: S.row },
|
|
1063
|
-
h('span', { className: S.labelBox },
|
|
1064
|
-
h('span', { className: S.label }, T.aboutStar),
|
|
1065
|
-
h('span', { className: S.hint }, T.aboutStarHint),
|
|
1066
|
-
),
|
|
1067
|
-
extLink(STARS_URL, 'GitHub'),
|
|
1068
|
-
),
|
|
1069
|
-
h('div', { className: S.row },
|
|
1070
|
-
h('span', { className: S.labelBox },
|
|
1071
|
-
h('span', { className: S.label }, T.aboutShare),
|
|
1072
|
-
h('span', { className: S.hint }, T.aboutShareHint),
|
|
1073
|
-
),
|
|
1074
|
-
h('button', { type: 'button', className: S.btn, onClick: () => void share() }, T.aboutShare),
|
|
1075
|
-
),
|
|
1076
|
-
// 项目地址可点开、可选中复制,失败时用户还有这一条路。
|
|
1077
|
-
h('div', { className: S.row },
|
|
1078
|
-
h('span', { className: S.label }, T.aboutProject),
|
|
1079
|
-
extLink(REPO_URL, REPO_URL.replace('https://', '')),
|
|
1077
|
+
h('div', { className: 'dsh-au-grid2' },
|
|
1078
|
+
kv('version', T.aboutVersion, h('span', { className: S.num }, version === '' ? '…' : 'v' + version)),
|
|
1079
|
+
kv('dsh', T.dshVersion, h('span', { className: S.num }, dshVersion === '' ? '—' : dshVersion)),
|
|
1080
|
+
kv('changelog', T.aboutChangelog, extLink(CHANGELOG_URL, T.aboutChangelogLink)),
|
|
1081
|
+
kv('repo', T.aboutRepo, extLink(REPO_URL, 'GitHub')),
|
|
1082
|
+
kv('feedback', T.aboutFeedback, extLink(ISSUES_URL, T.aboutFeedbackLink)),
|
|
1083
|
+
kv('share', T.aboutShare, h('button', { type: 'button', className: S.btn, onClick: () => void share() }, T.aboutShare)),
|
|
1080
1084
|
),
|
|
1085
|
+
h('div', { className: 'dsh-au-rule' }),
|
|
1086
|
+
kv('url', T.aboutProject, extLink(REPO_URL, REPO_URL.replace('https://', ''))),
|
|
1081
1087
|
shareHint ? h('span', { className: S.status }, shareHint) : null,
|
|
1082
1088
|
)
|
|
1083
1089
|
}
|
|
@@ -1088,13 +1094,6 @@ window.__ModuleLoader__.load({
|
|
|
1088
1094
|
const [draft, setDraft] = useState(null)
|
|
1089
1095
|
const [phase, setPhase] = useState('loading') // loading | ready | error
|
|
1090
1096
|
const [saveHint, setSaveHint] = useState('')
|
|
1091
|
-
const [running, setRunning] = useState(false)
|
|
1092
|
-
// 安装可能耗好几分钟(网络重试时更久),运行按钮旁边显示实时进度。
|
|
1093
|
-
const [progress, setProgress] = useState(null)
|
|
1094
|
-
const [runHint, setRunHint] = useState('')
|
|
1095
|
-
const [rolling, setRolling] = useState('')
|
|
1096
|
-
const [rollHint, setRollHint] = useState('')
|
|
1097
|
-
const [confirming, setConfirming] = useState('')
|
|
1098
1097
|
const [cleaning, setCleaning] = useState(false)
|
|
1099
1098
|
const [cleanHint, setCleanHint] = useState('')
|
|
1100
1099
|
|
|
@@ -1117,25 +1116,6 @@ window.__ModuleLoader__.load({
|
|
|
1117
1116
|
|
|
1118
1117
|
useEffect(() => { void load() }, [load])
|
|
1119
1118
|
|
|
1120
|
-
// 进度轮询要常驻:更新多数是定时器自动触发的,若只在点「立刻检查」时轮询,
|
|
1121
|
-
// 自动跑的那一轮界面上什么也看不到——上次就是这个原因以为进度功能没生效。
|
|
1122
|
-
useEffect(() => {
|
|
1123
|
-
let alive = true
|
|
1124
|
-
const tick = async () => {
|
|
1125
|
-
try {
|
|
1126
|
-
const next = await getState(LANG)
|
|
1127
|
-
if (alive) {
|
|
1128
|
-
setProgress(next?.progress ?? null)
|
|
1129
|
-
// 别人(定时器 / 另一个窗口)触发的轮次,也把 running 点亮。
|
|
1130
|
-
if (next?.progress) setRunning(true)
|
|
1131
|
-
}
|
|
1132
|
-
} catch {}
|
|
1133
|
-
}
|
|
1134
|
-
void tick()
|
|
1135
|
-
const timer = setInterval(() => { void tick() }, 3000)
|
|
1136
|
-
return () => { alive = false; clearInterval(timer) }
|
|
1137
|
-
}, [LANG])
|
|
1138
|
-
|
|
1139
1119
|
/**
|
|
1140
1120
|
* 立即保存。
|
|
1141
1121
|
*
|
|
@@ -1197,57 +1177,6 @@ window.__ModuleLoader__.load({
|
|
|
1197
1177
|
}, [])
|
|
1198
1178
|
|
|
1199
1179
|
|
|
1200
|
-
/** 把后端进度翻成一行中文/英文;没进度就退回普通「正在检查」。 */
|
|
1201
|
-
const runningText = (() => {
|
|
1202
|
-
if (!progress) return ''
|
|
1203
|
-
if (progress.phase === 'installing' && progress.total > 0) {
|
|
1204
|
-
return T.progressInstall
|
|
1205
|
-
.replace('{n}', String(progress.index))
|
|
1206
|
-
.replace('{m}', String(progress.total))
|
|
1207
|
-
.replace('{name}', String(progress.name || ''))
|
|
1208
|
-
}
|
|
1209
|
-
if (progress.phase === 'applying') return T.progressApply
|
|
1210
|
-
if (progress.phase === 'checking') return T.progressCheck
|
|
1211
|
-
return T.running
|
|
1212
|
-
})()
|
|
1213
|
-
|
|
1214
|
-
const fire = useCallback(async () => {
|
|
1215
|
-
if (running) return
|
|
1216
|
-
setRunning(true)
|
|
1217
|
-
setRunHint(T.running)
|
|
1218
|
-
try {
|
|
1219
|
-
// 进度由上面的常驻轮询统一负责,这里只发请求。
|
|
1220
|
-
const result = await runNow('update')
|
|
1221
|
-
if (result?.started === false) {
|
|
1222
|
-
// 「已经有一轮在跑」这类信息在「上一次」里没有,必须显示。
|
|
1223
|
-
setRunHint(result.reason || T.runFailed)
|
|
1224
|
-
} else {
|
|
1225
|
-
// 只给一句「检查完成」。原因和状态已经写进「上一次」那张卡,
|
|
1226
|
-
// 这里再拼一遍 reason + status 会和它逐字重复(还有英文 done)。
|
|
1227
|
-
setRunHint(T.runDone)
|
|
1228
|
-
}
|
|
1229
|
-
// 跑完把状态刷一遍,页面上看到的就是最新结果。
|
|
1230
|
-
try {
|
|
1231
|
-
const next = await getState(LANG)
|
|
1232
|
-
setState(next)
|
|
1233
|
-
setDraft((prev) => (prev === null ? next.settings : prev))
|
|
1234
|
-
} catch {}
|
|
1235
|
-
} catch {
|
|
1236
|
-
setRunHint(T.runFailed)
|
|
1237
|
-
} finally {
|
|
1238
|
-
setRunning(false)
|
|
1239
|
-
// 不在这里清 progress:常驻轮询会在后端清掉后同步,手动作废会和它打架。
|
|
1240
|
-
}
|
|
1241
|
-
}, [running])
|
|
1242
|
-
|
|
1243
|
-
// 结束提示只是一次性反馈:6 秒后自己收掉,免得它一直挂在卡片里,
|
|
1244
|
-
// 和下面「上一次」的原因并列成两段一样的文字。
|
|
1245
|
-
useEffect(() => {
|
|
1246
|
-
if (running || runHint === '') return undefined
|
|
1247
|
-
const timer = setTimeout(() => setRunHint(''), 6000)
|
|
1248
|
-
return () => clearTimeout(timer)
|
|
1249
|
-
}, [running, runHint])
|
|
1250
|
-
|
|
1251
1180
|
const doCleanup = useCallback(async () => {
|
|
1252
1181
|
if (cleaning) return
|
|
1253
1182
|
setCleaning(true)
|
|
@@ -1267,32 +1196,6 @@ window.__ModuleLoader__.load({
|
|
|
1267
1196
|
}
|
|
1268
1197
|
}, [cleaning])
|
|
1269
1198
|
|
|
1270
|
-
const doRollback = useCallback(async (target) => {
|
|
1271
|
-
if (rolling !== '' || running) return
|
|
1272
|
-
// 回滚会换掉正在跑的代码,属于不可轻点的操作,先要一次确认。
|
|
1273
|
-
if (confirming !== target) {
|
|
1274
|
-
setConfirming(target)
|
|
1275
|
-
setRollHint('')
|
|
1276
|
-
return
|
|
1277
|
-
}
|
|
1278
|
-
setConfirming('')
|
|
1279
|
-
setRolling(target)
|
|
1280
|
-
setRollHint(T.rollingBack)
|
|
1281
|
-
try {
|
|
1282
|
-
const result = await rollback(target)
|
|
1283
|
-
setRollHint(result.ok ? T.rollbackDone + ' · ' + target : T.rollbackFailed + ' · ' + (result.payload?.reason ?? ''))
|
|
1284
|
-
try {
|
|
1285
|
-
const next = await getState(LANG)
|
|
1286
|
-
setState(next)
|
|
1287
|
-
setDraft((prev) => (prev === null ? next.settings : prev))
|
|
1288
|
-
} catch {}
|
|
1289
|
-
} catch {
|
|
1290
|
-
setRollHint(T.rollbackFailed)
|
|
1291
|
-
} finally {
|
|
1292
|
-
setRolling('')
|
|
1293
|
-
}
|
|
1294
|
-
}, [rolling, running, confirming])
|
|
1295
|
-
|
|
1296
1199
|
if (phase === 'error') {
|
|
1297
1200
|
return h('div', { className: S.card },
|
|
1298
1201
|
h('span', { className: S.err }, T.unavailable),
|
|
@@ -1458,112 +1361,10 @@ window.__ModuleLoader__.load({
|
|
|
1458
1361
|
cleanHint ? h('span', { className: S.status }, cleanHint) : null,
|
|
1459
1362
|
),
|
|
1460
1363
|
),
|
|
1461
|
-
h('div', { className: S.card },
|
|
1462
|
-
// 按钮和它动作的对象放在一起:读「上一次」的人最想做的事就是再跑一次。
|
|
1463
|
-
h('div', { className: S.row },
|
|
1464
|
-
h('div', { className: S.labelBox },
|
|
1465
|
-
h('h3', { className: S.h }, T.lastRun),
|
|
1466
|
-
last === null || last === undefined ? h('span', { className: S.hint }, T.never) : null,
|
|
1467
|
-
),
|
|
1468
|
-
h('button', { type: 'button', className: S.btnPrimary, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
|
|
1469
|
-
),
|
|
1470
|
-
// 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
|
|
1471
|
-
progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
|
|
1472
|
-
// 三张统计卡,照 cost-meter 概览页的写法:一眼看到「什么时候查的、
|
|
1473
|
-
// 查了多少、几个能更」,而不是一串用 · 拼起来的句子。
|
|
1474
|
-
last === null || last === undefined ? null : h('div', { className: S.cards },
|
|
1475
|
-
h('div', { className: S.stat },
|
|
1476
|
-
h('span', { className: S.statK }, T.lastChecked),
|
|
1477
|
-
h('span', { className: S.statV, title: last.at || '' }, formatWhen(last.at) || '—'),
|
|
1478
|
-
relativeWhen(last.at) ? h('span', { className: S.hint }, relativeWhen(last.at)) : null,
|
|
1479
|
-
),
|
|
1480
|
-
h('div', { className: S.stat },
|
|
1481
|
-
h('span', { className: S.statK }, T.checked),
|
|
1482
|
-
h('span', { className: S.statV }, String(last.checked ?? 0)),
|
|
1483
|
-
h('span', { className: S.hint }, T.packages),
|
|
1484
|
-
),
|
|
1485
|
-
h('div', { className: S.stat },
|
|
1486
|
-
h('span', { className: S.statK }, applied > 0 ? T.lastUpdated : T.lastUpdates),
|
|
1487
|
-
h('span', { className: S.statV }, String(applied > 0 ? applied : (last.updates?.length ?? 0))),
|
|
1488
|
-
// 卡片里标题已经是「已更新」,副标题只补量词,不再重复一遍「已更新」。
|
|
1489
|
-
h('span', { className: S.hint }, applied > 0
|
|
1490
|
-
? T.updatedHint
|
|
1491
|
-
: (last.updates?.length ?? 0) > 0 ? T.updates : T.upToDate),
|
|
1492
|
-
),
|
|
1493
|
-
),
|
|
1494
|
-
// 原因只说一遍:徽标承接状态词,正文承接句子,两者不重复同一句话。
|
|
1495
|
-
(() => {
|
|
1496
|
-
if (last === null || last === undefined) return null
|
|
1497
|
-
const reason = typeof last.reason === 'string' ? last.reason : ''
|
|
1498
|
-
const status = statusLabel(last.status)
|
|
1499
|
-
if (reason === '' && status === '') return null
|
|
1500
|
-
return h('div', { className: S.row },
|
|
1501
|
-
reason === '' ? null : h('span', { className: S.note }, reason),
|
|
1502
|
-
status === '' ? null : h('span', { className: badgeClass(last.status) }, status),
|
|
1503
|
-
)
|
|
1504
|
-
})(),
|
|
1505
|
-
// 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
|
|
1506
|
-
// 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
|
|
1507
|
-
(() => {
|
|
1508
|
-
const rows = (Array.isArray(last?.updates) ? last.updates : [])
|
|
1509
|
-
.map((item) => describeUpdate(item))
|
|
1510
|
-
.filter((row) => row !== null)
|
|
1511
|
-
if (rows.length === 0) return null
|
|
1512
|
-
return h('div', { className: S.scrollList },
|
|
1513
|
-
rows.map((row, index) => h('div', {
|
|
1514
|
-
key: row.name + ':' + index,
|
|
1515
|
-
className: 'dsh-au-line',
|
|
1516
|
-
},
|
|
1517
|
-
h('span', { className: S.pkgName, title: row.name }, row.name),
|
|
1518
|
-
row.versions === '' ? null : h('span', { className: S.pkgVer }, row.versions),
|
|
1519
|
-
)),
|
|
1520
|
-
)
|
|
1521
|
-
})(),
|
|
1522
|
-
// 镜像落后和「装不了」都要按名字说出来:只报「已是最新」或「一个没装上」,
|
|
1523
|
-
// 用户没法知道该换源还是该升 DSH。
|
|
1524
|
-
(last?.lagged?.length ?? 0) > 0
|
|
1525
|
-
? h('p', { className: S.note }, T.lagNote.replace('{n}', String(last.lagged.length)) + ' · ' +
|
|
1526
|
-
last.lagged.slice(0, 3).map((row) => row.name + ' ' + (row.mirror ?? '?') + ' → ' + (row.upstream ?? '?')).join(','))
|
|
1527
|
-
: null,
|
|
1528
|
-
(last?.blocked?.length ?? 0) > 0
|
|
1529
|
-
? h('p', { className: S.note }, T.blockedNote.replace('{n}', String(last.blocked.length)) + ' · ' +
|
|
1530
|
-
last.blocked.slice(0, 3).map((row) => row.name + '@' + (row.target ?? '?')).join(','))
|
|
1531
|
-
: null,
|
|
1532
|
-
runHint ? h('span', { className: S.status }, runHint) : null,
|
|
1533
|
-
),
|
|
1534
|
-
// 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
|
|
1535
|
-
h('div', { className: S.card },
|
|
1536
|
-
h('h3', { className: S.h }, T.history),
|
|
1537
|
-
(state?.history?.length ?? 0) === 0
|
|
1538
|
-
? h('span', { className: S.status }, T.historyEmpty)
|
|
1539
|
-
: h('div', { className: S.scrollList },
|
|
1540
|
-
state.history.map((row, index) => h('div', {
|
|
1541
|
-
key: row.name + '@' + row.at + ':' + index,
|
|
1542
|
-
className: S.row,
|
|
1543
|
-
},
|
|
1544
|
-
h('div', { className: S.labelBox },
|
|
1545
|
-
h('span', null, row.name + ' ' + (row.from ?? '?') + ' → ' + (row.to ?? '?')),
|
|
1546
|
-
h('span', { className: S.hint, title: row.at || '' },
|
|
1547
|
-
formatWhen(row.at) + (relativeWhen(row.at) ? '(' + relativeWhen(row.at) + ')' : '') +
|
|
1548
|
-
(row.rolledBack === true ? ' · ' + T.rolledBack : '')),
|
|
1549
|
-
),
|
|
1550
|
-
row.rolledBack === true || typeof row.from !== 'string' || row.from === ''
|
|
1551
|
-
? null
|
|
1552
|
-
: h('button', {
|
|
1553
|
-
type: 'button',
|
|
1554
|
-
className: confirming === row.name ? S.btnPrimary : S.btn,
|
|
1555
|
-
disabled: rolling !== '' || running,
|
|
1556
|
-
onClick: () => void doRollback(row.name),
|
|
1557
|
-
}, rolling === row.name ? T.rollingBack : confirming === row.name ? T.rollback + '?' : T.rollback),
|
|
1558
|
-
)),
|
|
1559
|
-
),
|
|
1560
|
-
rollHint ? h('span', { className: S.status }, rollHint) : null,
|
|
1561
|
-
),
|
|
1562
|
-
h(LogCard, null),
|
|
1563
1364
|
// 没有保存按钮:改动自己在 350ms 后落盘,这里只报它落没落成。
|
|
1564
1365
|
saveHint ? h('span', { className: S.status }, saveHint) : null,
|
|
1565
1366
|
h('span', { className: S.hint }, T.scope),
|
|
1566
|
-
|
|
1367
|
+
|
|
1567
1368
|
)
|
|
1568
1369
|
}
|
|
1569
1370
|
|
|
@@ -1928,13 +1729,6 @@ window.__ModuleLoader__.load({
|
|
|
1928
1729
|
}
|
|
1929
1730
|
}
|
|
1930
1731
|
|
|
1931
|
-
/**
|
|
1932
|
-
* 「版本管理」标签页。
|
|
1933
|
-
*
|
|
1934
|
-
* 和设置页的分工:设置页管「什么时候自动升」,这一页管「现在就要某一版」。
|
|
1935
|
-
* 版本列表按包按需拉(一次一个包),不进首屏:整页一次拉一堆包的 packument
|
|
1936
|
-
* 在镜像上会慢到没法用。
|
|
1937
|
-
*/
|
|
1938
1732
|
/**
|
|
1939
1733
|
* 「版本管理」标签页。
|
|
1940
1734
|
*
|
|
@@ -1944,6 +1738,133 @@ window.__ModuleLoader__.load({
|
|
|
1944
1738
|
*
|
|
1945
1739
|
* 和设置页的分工没变:设置页管「什么时候自动升」,这一页管「现在就要某一版」。
|
|
1946
1740
|
*/
|
|
1741
|
+
/**
|
|
1742
|
+
* 「现状」:上一次检查的结论 + 这一轮的数字。
|
|
1743
|
+
*
|
|
1744
|
+
* 刻意没有标题、也没有「立刻检查」按钮——工具条上已经有「检查并安装」,
|
|
1745
|
+
* 同一页里再放一个重复的按钮只会让人犹豫该点哪个。时间改成第一格统计,
|
|
1746
|
+
* 状态徽标跟在原因后面,四格数字就是全部要点。
|
|
1747
|
+
*/
|
|
1748
|
+
function LastRunCard(props) {
|
|
1749
|
+
useLang()
|
|
1750
|
+
const last = props.state?.lastRun
|
|
1751
|
+
const applied = appliedCount(last)
|
|
1752
|
+
const updates = (Array.isArray(last?.updates) ? last.updates : [])
|
|
1753
|
+
.map((item) => describeUpdate(item))
|
|
1754
|
+
.filter((row) => row !== null)
|
|
1755
|
+
const attention = Array.isArray(props.attention) ? props.attention : []
|
|
1756
|
+
const progress = props.state?.progress
|
|
1757
|
+
const runningText = (() => {
|
|
1758
|
+
if (!progress) return ''
|
|
1759
|
+
if (progress.phase === 'installing' && progress.total > 0) {
|
|
1760
|
+
return T.progressInstall
|
|
1761
|
+
.replace('{n}', String(progress.index))
|
|
1762
|
+
.replace('{m}', String(progress.total))
|
|
1763
|
+
.replace('{name}', String(progress.name || ''))
|
|
1764
|
+
}
|
|
1765
|
+
if (progress.phase === 'applying') return T.progressApply
|
|
1766
|
+
return T.running
|
|
1767
|
+
})()
|
|
1768
|
+
const stat = (key, label, value, hint) => h('div', { className: S.stat, key },
|
|
1769
|
+
h('span', { className: S.statK }, label),
|
|
1770
|
+
h('span', { className: S.statV }, value),
|
|
1771
|
+
hint ? h('span', { className: S.hint }, hint) : null,
|
|
1772
|
+
)
|
|
1773
|
+
const status = statusLabel(last?.status)
|
|
1774
|
+
return h('div', { className: S.card },
|
|
1775
|
+
h('div', { className: S.cards },
|
|
1776
|
+
stat('at', T.lastChecked, formatWhen(last?.at) || '—',
|
|
1777
|
+
last === null || last === undefined ? T.never : relativeWhen(last?.at) || ''),
|
|
1778
|
+
stat('up', T.versionsUpgradable, String(updates.length),
|
|
1779
|
+
updates.length > 0 ? updates[0].name + (updates.length > 1 ? ' …' : '') : T.upToDate),
|
|
1780
|
+
stat('done', T.lastUpdated, String(applied), T.updatedHint),
|
|
1781
|
+
stat('bad', T.versionsAttention, String(attention.length), attention.length > 0 ? attention[0].name : ''),
|
|
1782
|
+
),
|
|
1783
|
+
progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
|
|
1784
|
+
(last?.reason || status !== '')
|
|
1785
|
+
? h('div', { className: S.row },
|
|
1786
|
+
last?.reason ? h('p', { className: S.note }, last.reason) : h('span', null),
|
|
1787
|
+
status !== '' ? h('span', { className: badgeClass(last?.status) }, status) : null,
|
|
1788
|
+
)
|
|
1789
|
+
: null,
|
|
1790
|
+
updates.length > 0
|
|
1791
|
+
? h('div', { className: S.scrollList },
|
|
1792
|
+
updates.map((row, index) => h('div', { key: row.name + ':' + index, className: 'dsh-au-line' },
|
|
1793
|
+
h('span', { className: S.pkgName, title: row.name }, row.name),
|
|
1794
|
+
row.versions === '' ? null : h('span', { className: S.pkgVer }, row.versions),
|
|
1795
|
+
)),
|
|
1796
|
+
)
|
|
1797
|
+
: null,
|
|
1798
|
+
)
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
/**
|
|
1802
|
+
* 「更新记录」:单行一条——包名 + 旧→新、时间靠右、回滚在最右。
|
|
1803
|
+
*
|
|
1804
|
+
* 原来是两行一条(名字/版本、时间),四条就吃掉半屏。回滚仍要确认一次:
|
|
1805
|
+
* 第一次点只改文案,第二次才真的动手。
|
|
1806
|
+
*/
|
|
1807
|
+
function HistoryCard(props) {
|
|
1808
|
+
useLang()
|
|
1809
|
+
const [rolling, setRolling] = useState('')
|
|
1810
|
+
const [confirming, setConfirming] = useState('')
|
|
1811
|
+
const [hint, setHint] = useState('')
|
|
1812
|
+
const rows = Array.isArray(props.state?.history) ? props.state.history : []
|
|
1813
|
+
|
|
1814
|
+
const doRollback = async (name) => {
|
|
1815
|
+
if (rolling !== '' || props.busy === true) return
|
|
1816
|
+
if (confirming !== name) {
|
|
1817
|
+
setConfirming(name)
|
|
1818
|
+
setHint('')
|
|
1819
|
+
return
|
|
1820
|
+
}
|
|
1821
|
+
setConfirming('')
|
|
1822
|
+
setRolling(name)
|
|
1823
|
+
setHint(T.rollingBack)
|
|
1824
|
+
try {
|
|
1825
|
+
const response = await fetch(endpoint('rollback') + langQuery(), {
|
|
1826
|
+
method: 'POST',
|
|
1827
|
+
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
1828
|
+
body: JSON.stringify({ name }),
|
|
1829
|
+
})
|
|
1830
|
+
const payload = await response.json().catch(() => null)
|
|
1831
|
+
setHint(response.ok ? T.rollbackDone + ' · ' + name : T.rollbackFailed + ' · ' + (payload?.reason ?? ''))
|
|
1832
|
+
if (typeof props.onReload === 'function') await props.onReload()
|
|
1833
|
+
} catch {
|
|
1834
|
+
setHint(T.rollbackFailed)
|
|
1835
|
+
} finally {
|
|
1836
|
+
setRolling('')
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
return h('div', { className: S.card },
|
|
1841
|
+
h('h3', { className: S.h }, T.history),
|
|
1842
|
+
rows.length === 0
|
|
1843
|
+
? h('span', { className: S.status }, T.historyEmpty)
|
|
1844
|
+
: h('div', { className: 'dsh-au-rec' },
|
|
1845
|
+
rows.map((row, index) => h('div', {
|
|
1846
|
+
key: row.name + '@' + row.at + ':' + index,
|
|
1847
|
+
className: S.row,
|
|
1848
|
+
},
|
|
1849
|
+
h('div', { className: S.pkgName, style: { flex: '1 1 auto' } },
|
|
1850
|
+
h('span', null, row.name),
|
|
1851
|
+
h('span', { className: S.num, style: { marginLeft: '6px' } }, (row.from ?? '?') + ' → ' + (row.to ?? '?')),
|
|
1852
|
+
),
|
|
1853
|
+
h('span', { className: S.hint, style: { flex: '0 0 auto' }, title: row.at || '' }, formatWhen(row.at)),
|
|
1854
|
+
row.rolledBack === true || typeof row.from !== 'string' || row.from === ''
|
|
1855
|
+
? h('span', { className: S.hint, style: { minWidth: '54px', textAlign: 'right' } }, T.rolledBack)
|
|
1856
|
+
: h('button', {
|
|
1857
|
+
type: 'button',
|
|
1858
|
+
className: confirming === row.name ? S.btnPrimary : S.btn,
|
|
1859
|
+
disabled: rolling !== '' || props.busy === true,
|
|
1860
|
+
onClick: () => void doRollback(row.name),
|
|
1861
|
+
}, rolling === row.name ? T.rollingBack : confirming === row.name ? T.rollback + '?' : T.rollback),
|
|
1862
|
+
)),
|
|
1863
|
+
),
|
|
1864
|
+
hint ? h('span', { className: S.status }, hint) : null,
|
|
1865
|
+
)
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1947
1868
|
function VersionsTab() {
|
|
1948
1869
|
useLang()
|
|
1949
1870
|
const [state, setState] = useState(null)
|
|
@@ -1992,10 +1913,6 @@ window.__ModuleLoader__.load({
|
|
|
1992
1913
|
}, [])
|
|
1993
1914
|
|
|
1994
1915
|
const packages = useMemo(() => (Array.isArray(state?.packages) ? state.packages : []), [state])
|
|
1995
|
-
const rows = useMemo(() => {
|
|
1996
|
-
const needle = query.trim().toLowerCase()
|
|
1997
|
-
return needle === '' ? packages : packages.filter((item) => String(item.name).toLowerCase().includes(needle))
|
|
1998
|
-
}, [packages, query])
|
|
1999
1916
|
|
|
2000
1917
|
// 最近一轮里「查到的可更新版本」和「镜像落后」:都用名字索引,行上直接查。
|
|
2001
1918
|
const updatable = useMemo(() => {
|
|
@@ -2016,6 +1933,23 @@ window.__ModuleLoader__.load({
|
|
|
2016
1933
|
return mark
|
|
2017
1934
|
}, [state])
|
|
2018
1935
|
|
|
1936
|
+
// 「自动安装」关掉时,把查到的可更新项顶到最上面:这时「看得见」就等于「要不要动手」,
|
|
1937
|
+
// 埋在一屏之外的长列表里等于没查到。开着自动安装时它们会被装掉,不需要这个排序。
|
|
1938
|
+
const autoApply = state?.settings?.autoApply !== false
|
|
1939
|
+
const ordered = useMemo(() => {
|
|
1940
|
+
const filtered = (() => {
|
|
1941
|
+
const needle = query.trim().toLowerCase()
|
|
1942
|
+
return needle === '' ? packages : packages.filter((item) => String(item.name).toLowerCase().includes(needle))
|
|
1943
|
+
})()
|
|
1944
|
+
if (autoApply) return filtered
|
|
1945
|
+
return filtered.slice().sort((a, b) => {
|
|
1946
|
+
const ua = updatable.has(a.name) ? 0 : 1
|
|
1947
|
+
const ub = updatable.has(b.name) ? 0 : 1
|
|
1948
|
+
if (ua !== ub) return ua - ub
|
|
1949
|
+
return a.name < b.name ? -1 : a.name > b.name ? 1 : 0
|
|
1950
|
+
})
|
|
1951
|
+
}, [packages, query, autoApply, updatable])
|
|
1952
|
+
|
|
2019
1953
|
const attention = useMemo(() => packages.filter((item) => item.ok === false || item.version === ''), [packages])
|
|
2020
1954
|
const pickedNames = useMemo(() => packages.filter((item) => picked[item.name] === true).map((item) => item.name), [packages, picked])
|
|
2021
1955
|
|
|
@@ -2082,11 +2016,11 @@ window.__ModuleLoader__.load({
|
|
|
2082
2016
|
await reload()
|
|
2083
2017
|
}, [busy, post, reload])
|
|
2084
2018
|
|
|
2085
|
-
const runCycle = useCallback(async (mode, names, fresh) => {
|
|
2019
|
+
const runCycle = useCallback(async (mode, names, fresh, force) => {
|
|
2086
2020
|
if (busy !== '') return
|
|
2087
2021
|
setBusy('cycle')
|
|
2088
2022
|
setHint('')
|
|
2089
|
-
const { ok, payload } = await post('run', { mode, names: names ?? [], fresh: fresh === true })
|
|
2023
|
+
const { ok, payload } = await post('run', { mode, names: names ?? [], fresh: fresh === true, force: force === true })
|
|
2090
2024
|
if (!ok) setHint(T.versionsFail)
|
|
2091
2025
|
else if (payload?.started === false) setHint(payload?.reason || T.running)
|
|
2092
2026
|
else setHint(T.runDone)
|
|
@@ -2131,31 +2065,9 @@ window.__ModuleLoader__.load({
|
|
|
2131
2065
|
h('h3', { className: S.title }, T.versionsTitle),
|
|
2132
2066
|
h('p', { className: S.sub }, T.versionsSubtitle),
|
|
2133
2067
|
),
|
|
2134
|
-
//
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
h('div', { className: S.stat },
|
|
2138
|
-
h('span', { className: S.statK }, T.versionsAttention),
|
|
2139
|
-
h('span', { className: S.statV }, String(attention.length)),
|
|
2140
|
-
h('span', { className: S.hint }, attention.length > 0 ? attention.slice(0, 2).map((item) => item.name).join('、') : T.versionsEmpty),
|
|
2141
|
-
),
|
|
2142
|
-
h('div', { className: S.stat },
|
|
2143
|
-
h('span', { className: S.statK }, T.versionsUpgradable),
|
|
2144
|
-
h('span', { className: S.statV }, String(updatable.size)),
|
|
2145
|
-
h('span', { className: S.hint }, state?.lastRun?.at ? formatWhen(state.lastRun.at) : T.never),
|
|
2146
|
-
),
|
|
2147
|
-
h('div', { className: S.stat },
|
|
2148
|
-
h('span', { className: S.statK }, T.versionsInstalledCount),
|
|
2149
|
-
h('span', { className: S.statV }, String(packages.length)),
|
|
2150
|
-
h('span', { className: S.hint }, T.versionsCount.replace('{n}', String(packages.length))),
|
|
2151
|
-
),
|
|
2152
|
-
),
|
|
2153
|
-
h('div', { className: S.meta },
|
|
2154
|
-
h('span', null, T.dshVersion + ': ' + (state?.dshVersion ?? '—')),
|
|
2155
|
-
h('span', null, T.registry + ': ' + (state?.registry === '' || !state?.registry ? T.regPnpm : state.registry)),
|
|
2156
|
-
),
|
|
2157
|
-
progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
|
|
2158
|
-
),
|
|
2068
|
+
// 现状只有数字和一句结论:标题和「立刻检查」都去掉了——工具条上已经有
|
|
2069
|
+
// 「检查并安装」,同一页里放两个功能相同的按钮只会让人犹豫点哪个。
|
|
2070
|
+
h(LastRunCard, { state: state, attention: attention, busy: busy !== '' }),
|
|
2159
2071
|
// 工具条
|
|
2160
2072
|
h('div', { className: S.card },
|
|
2161
2073
|
h('div', { className: S.vhead },
|
|
@@ -2168,8 +2080,17 @@ window.__ModuleLoader__.load({
|
|
|
2168
2080
|
style: { flex: '1 1 200px' },
|
|
2169
2081
|
}),
|
|
2170
2082
|
h('div', { className: S.actions },
|
|
2171
|
-
|
|
2172
|
-
|
|
2083
|
+
// 主按钮的语义跟着设置走:开着自动安装时它就是「检查并安装」(查到就装),
|
|
2084
|
+
// 关掉时退化成「只检查」。名字必须跟着变,否则「检查更新」不装东西会像 bug。
|
|
2085
|
+
h('button', {
|
|
2086
|
+
type: 'button',
|
|
2087
|
+
className: S.btn,
|
|
2088
|
+
disabled: busy !== '',
|
|
2089
|
+
onClick: () => void runCycle(autoApply ? 'update' : 'check', [], true, autoApply),
|
|
2090
|
+
}, autoApply ? T.versionsCheckInstall : T.versionsCheckOnly),
|
|
2091
|
+
// 「一键升级」永远真的装:force 让它不被「自动安装」开关挡住,
|
|
2092
|
+
// 但复用 10 分钟内的查询结果(fresh=false),点了就动手、不重查。
|
|
2093
|
+
h('button', { type: 'button', className: S.btnPrimary, disabled: busy !== '', onClick: () => void runCycle('update', [], false, true) }, T.versionsUpgradeAll),
|
|
2173
2094
|
h('button', { type: 'button', className: S.btn, disabled: busy !== '' || pickedNames.length === 0, onClick: () => void runCycle('update', pickedNames, false) }, T.versionsUpgradePicked.replace('{n}', String(pickedNames.length))),
|
|
2174
2095
|
h('button', { type: 'button', className: S.btn, onClick: () => setShowSources((v) => !v) }, T.versionsSources),
|
|
2175
2096
|
h('button', { type: 'button', className: S.btn, onClick: () => void copyDiagnostics() }, T.versionsDiagnostics),
|
|
@@ -2230,10 +2151,10 @@ window.__ModuleLoader__.load({
|
|
|
2230
2151
|
: null,
|
|
2231
2152
|
// 包列表:勾选 → 升级选中;展开 → 全部版本 → 切过去。
|
|
2232
2153
|
h('div', { className: S.card },
|
|
2233
|
-
|
|
2154
|
+
ordered.length === 0
|
|
2234
2155
|
? h('span', { className: S.status }, T.versionsEmpty)
|
|
2235
|
-
: h('div', { className:
|
|
2236
|
-
|
|
2156
|
+
: h('div', { className: 'dsh-au-plist' },
|
|
2157
|
+
ordered.map((item) => {
|
|
2237
2158
|
const listed = lists[item.name]
|
|
2238
2159
|
const expanded = openName === item.name
|
|
2239
2160
|
const behind = lagged.get(item.name)
|
|
@@ -2294,6 +2215,20 @@ window.__ModuleLoader__.load({
|
|
|
2294
2215
|
}),
|
|
2295
2216
|
),
|
|
2296
2217
|
),
|
|
2218
|
+
h(HistoryCard, { state: state, busy: busy !== '', onReload: reload }),
|
|
2219
|
+
h(LogCard, null),
|
|
2220
|
+
h(AboutCard, { version: state?.version, dshVersion: state?.dshVersion }),
|
|
2221
|
+
// Star 条在最底下:它不参与操作,读完页面顺手露一下就够了。
|
|
2222
|
+
h('a', {
|
|
2223
|
+
className: 'dsh-au-star',
|
|
2224
|
+
href: STARS_URL,
|
|
2225
|
+
target: '_blank',
|
|
2226
|
+
rel: 'noopener noreferrer',
|
|
2227
|
+
},
|
|
2228
|
+
h('span', { className: 'dsh-au-starIcon', 'aria-hidden': 'true' }, '⭐'),
|
|
2229
|
+
h('span', null, T.starPrompt),
|
|
2230
|
+
h('span', { className: 'dsh-au-starCta' }, T.starCta),
|
|
2231
|
+
),
|
|
2297
2232
|
h('span', { className: S.hint }, T.scope),
|
|
2298
2233
|
)
|
|
2299
2234
|
}
|
package/index.js
CHANGED
|
@@ -2249,7 +2249,9 @@ async function runCycle(mode, ctxRef, options = {}) {
|
|
|
2249
2249
|
report.updates = report.updates.slice(0, settings.maxPerCycle)
|
|
2250
2250
|
writeLog('capped', [settings.maxPerCycle, deferred])
|
|
2251
2251
|
}
|
|
2252
|
-
|
|
2252
|
+
// 手动「一键升级」传 force:用户当场点了装,就不该被「自动安装」这个开关挡住——
|
|
2253
|
+
// 那个开关管的是定时轮次,不是人按下的按钮。
|
|
2254
|
+
if (mode === 'check' || (!settings.autoApply && options.force !== true)) {
|
|
2253
2255
|
report.reason = { code: 'checkOnly' }
|
|
2254
2256
|
return report
|
|
2255
2257
|
}
|
|
@@ -2868,6 +2870,7 @@ function registerRoutes(scope, ctxRef) {
|
|
|
2868
2870
|
const report = await beginningRun(mode, ctxRef, {
|
|
2869
2871
|
names: Array.isArray(body?.names) ? body.names : [],
|
|
2870
2872
|
fresh: body?.fresh === true,
|
|
2873
|
+
force: body?.force === true,
|
|
2871
2874
|
})
|
|
2872
2875
|
if (report === null) {
|
|
2873
2876
|
sendJson(res, 200, { started: false, reason: renderReason({ code: 'alreadyRunning' }, url.searchParams.get('lang')) })
|
package/package.json
CHANGED