dsh-aupdate 0.8.5 → 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.
Files changed (3) hide show
  1. package/README.md +21 -9
  2. package/client.js +189 -278
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -169,10 +169,12 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
169
169
 
170
170
  ### 关于 aupdate
171
171
 
172
- 设置页底部有「关于 aupdate」信息组(照 Bloom 的「关于 Bloom」做):版本号(从 package.json
173
- 读取,发版不用改前端)、查看更新日志、源码仓库、提交问题,另有「点个星」(打开 GitHub
174
- stargazers)与「分享」(复制项目地址到剪贴板,任何环境都能用;失败时地址本身也可点开复制)。
175
- 外链一律 `target=_blank` + `rel=noopener noreferrer`。
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
 
@@ -496,12 +504,16 @@ The Last run card states the outcome once. Clicking Check now only adds a short
496
504
  the same reason plus a raw status word underneath. Status words are a localized fallback
497
505
  used only when no rendered reason exists.
498
506
 
499
- An **About aupdate** group sits at the bottom of the page (modeled on Bloom's About section):
500
- the version (read from package.json, so releases need no front-end edit), a changelog link,
501
- source repository, issue tracker, plus Star and Share (copies the project URL; the URL is
502
- also selectable if the copy fails). External links use target=_blank with
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
503
511
  rel=noopener noreferrer.
504
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
+
505
517
  The last run's outcome (when, how many checked, how many updatable, how many installed,
506
518
  why it failed) is persisted to `~/.dsh/aupdate-lastrun.json` and survives a restart. It
507
519
  used to live in memory only, so every restart reset the card to "never run" and looked
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: '搜索插件名',
@@ -261,8 +263,6 @@ window.__ModuleLoader__.load({
261
263
  aboutRepo: '源码仓库',
262
264
  aboutFeedback: '反馈问题',
263
265
  aboutFeedbackLink: '提交问题',
264
- aboutStar: '点个星',
265
- aboutStarHint: '在 GitHub 上点 Star,让更多人看到',
266
266
  aboutShare: '分享',
267
267
  aboutShareHint: '复制项目地址,分享给朋友',
268
268
  aboutShareDone: '项目地址已复制',
@@ -350,6 +350,8 @@ window.__ModuleLoader__.load({
350
350
  lagNote: '{n} plugin(s) not synced to the mirror yet; upstream already has newer',
351
351
  blockedNote: '{n} version(s) cannot be installed on this DSH',
352
352
  versionsTab: 'Versions',
353
+ starPrompt: 'Leave a star — the author will beam all day',
354
+ starCta: 'Give a star',
353
355
  versionsTitle: 'Version manager',
354
356
  versionsSubtitle: 'Every published version of every installed plugin; click one to switch',
355
357
  versionsSearch: 'Search plugin names',
@@ -467,8 +469,6 @@ window.__ModuleLoader__.load({
467
469
  aboutRepo: 'Source code',
468
470
  aboutFeedback: 'Report an issue',
469
471
  aboutFeedbackLink: 'Open an issue',
470
- aboutStar: 'Star',
471
- aboutStarHint: 'Star on GitHub to help others find it',
472
472
  aboutShare: 'Share',
473
473
  aboutShareHint: 'Copy the project link to share',
474
474
  aboutShareDone: 'Project link copied',
@@ -749,6 +749,27 @@ window.__ModuleLoader__.load({
749
749
  /* 通知卡:照 dsh-cost-meter 的「峰/谷切换提醒」做。
750
750
  * 那张卡是「圆点徽标 + 标题 + 正文 + 右对齐按钮」,并按事件换主色;
751
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
+
752
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)}
753
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)}
754
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}
@@ -827,7 +848,7 @@ window.__ModuleLoader__.load({
827
848
  pkgVer: 'dsh-au-pkgver',
828
849
  link: 'dsh-au-link',
829
850
  linkExt: 'dsh-au-linkext',
830
- ver: 'dsh-au-num',
851
+ num: 'dsh-au-num',
831
852
  }
832
853
  function Toggle(props) {
833
854
  const { checked, onChange, disabled } = props
@@ -1022,6 +1043,7 @@ window.__ModuleLoader__.load({
1022
1043
  useLang()
1023
1044
  const [shareHint, setShareHint] = useState('')
1024
1045
  const version = props.version || ''
1046
+ const dshVersion = props.dshVersion || ''
1025
1047
 
1026
1048
  const extLink = (href, label) => h('a', {
1027
1049
  href,
@@ -1043,43 +1065,25 @@ window.__ModuleLoader__.load({
1043
1065
  }
1044
1066
  }
1045
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
+
1046
1075
  return h('div', { className: S.card },
1047
1076
  h('h3', { className: S.h }, T.about),
1048
- h('div', { className: S.row },
1049
- h('span', { className: S.label }, T.aboutVersion),
1050
- h('span', { className: S.ver }, version === '' ? '…' : 'v' + version),
1051
- ),
1052
- h('div', { className: S.row },
1053
- h('span', { className: S.label }, T.aboutChangelog),
1054
- extLink(CHANGELOG_URL, T.aboutChangelogLink),
1055
- ),
1056
- h('div', { className: S.row },
1057
- h('span', { className: S.label }, T.aboutRepo),
1058
- extLink(REPO_URL, 'GitHub'),
1059
- ),
1060
- h('div', { className: S.row },
1061
- h('span', { className: S.label }, T.aboutFeedback),
1062
- extLink(ISSUES_URL, T.aboutFeedbackLink),
1063
- ),
1064
- h('div', { className: S.row },
1065
- h('span', { className: S.labelBox },
1066
- h('span', { className: S.label }, T.aboutStar),
1067
- h('span', { className: S.hint }, T.aboutStarHint),
1068
- ),
1069
- extLink(STARS_URL, 'GitHub'),
1070
- ),
1071
- h('div', { className: S.row },
1072
- h('span', { className: S.labelBox },
1073
- h('span', { className: S.label }, T.aboutShare),
1074
- h('span', { className: S.hint }, T.aboutShareHint),
1075
- ),
1076
- h('button', { type: 'button', className: S.btn, onClick: () => void share() }, T.aboutShare),
1077
- ),
1078
- // 项目地址可点开、可选中复制,失败时用户还有这一条路。
1079
- h('div', { className: S.row },
1080
- h('span', { className: S.label }, T.aboutProject),
1081
- 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)),
1082
1084
  ),
1085
+ h('div', { className: 'dsh-au-rule' }),
1086
+ kv('url', T.aboutProject, extLink(REPO_URL, REPO_URL.replace('https://', ''))),
1083
1087
  shareHint ? h('span', { className: S.status }, shareHint) : null,
1084
1088
  )
1085
1089
  }
@@ -1090,13 +1094,6 @@ window.__ModuleLoader__.load({
1090
1094
  const [draft, setDraft] = useState(null)
1091
1095
  const [phase, setPhase] = useState('loading') // loading | ready | error
1092
1096
  const [saveHint, setSaveHint] = useState('')
1093
- const [running, setRunning] = useState(false)
1094
- // 安装可能耗好几分钟(网络重试时更久),运行按钮旁边显示实时进度。
1095
- const [progress, setProgress] = useState(null)
1096
- const [runHint, setRunHint] = useState('')
1097
- const [rolling, setRolling] = useState('')
1098
- const [rollHint, setRollHint] = useState('')
1099
- const [confirming, setConfirming] = useState('')
1100
1097
  const [cleaning, setCleaning] = useState(false)
1101
1098
  const [cleanHint, setCleanHint] = useState('')
1102
1099
 
@@ -1119,25 +1116,6 @@ window.__ModuleLoader__.load({
1119
1116
 
1120
1117
  useEffect(() => { void load() }, [load])
1121
1118
 
1122
- // 进度轮询要常驻:更新多数是定时器自动触发的,若只在点「立刻检查」时轮询,
1123
- // 自动跑的那一轮界面上什么也看不到——上次就是这个原因以为进度功能没生效。
1124
- useEffect(() => {
1125
- let alive = true
1126
- const tick = async () => {
1127
- try {
1128
- const next = await getState(LANG)
1129
- if (alive) {
1130
- setProgress(next?.progress ?? null)
1131
- // 别人(定时器 / 另一个窗口)触发的轮次,也把 running 点亮。
1132
- if (next?.progress) setRunning(true)
1133
- }
1134
- } catch {}
1135
- }
1136
- void tick()
1137
- const timer = setInterval(() => { void tick() }, 3000)
1138
- return () => { alive = false; clearInterval(timer) }
1139
- }, [LANG])
1140
-
1141
1119
  /**
1142
1120
  * 立即保存。
1143
1121
  *
@@ -1199,57 +1177,6 @@ window.__ModuleLoader__.load({
1199
1177
  }, [])
1200
1178
 
1201
1179
 
1202
- /** 把后端进度翻成一行中文/英文;没进度就退回普通「正在检查」。 */
1203
- const runningText = (() => {
1204
- if (!progress) return ''
1205
- if (progress.phase === 'installing' && progress.total > 0) {
1206
- return T.progressInstall
1207
- .replace('{n}', String(progress.index))
1208
- .replace('{m}', String(progress.total))
1209
- .replace('{name}', String(progress.name || ''))
1210
- }
1211
- if (progress.phase === 'applying') return T.progressApply
1212
- if (progress.phase === 'checking') return T.progressCheck
1213
- return T.running
1214
- })()
1215
-
1216
- const fire = useCallback(async () => {
1217
- if (running) return
1218
- setRunning(true)
1219
- setRunHint(T.running)
1220
- try {
1221
- // 进度由上面的常驻轮询统一负责,这里只发请求。
1222
- const result = await runNow('update')
1223
- if (result?.started === false) {
1224
- // 「已经有一轮在跑」这类信息在「上一次」里没有,必须显示。
1225
- setRunHint(result.reason || T.runFailed)
1226
- } else {
1227
- // 只给一句「检查完成」。原因和状态已经写进「上一次」那张卡,
1228
- // 这里再拼一遍 reason + status 会和它逐字重复(还有英文 done)。
1229
- setRunHint(T.runDone)
1230
- }
1231
- // 跑完把状态刷一遍,页面上看到的就是最新结果。
1232
- try {
1233
- const next = await getState(LANG)
1234
- setState(next)
1235
- setDraft((prev) => (prev === null ? next.settings : prev))
1236
- } catch {}
1237
- } catch {
1238
- setRunHint(T.runFailed)
1239
- } finally {
1240
- setRunning(false)
1241
- // 不在这里清 progress:常驻轮询会在后端清掉后同步,手动作废会和它打架。
1242
- }
1243
- }, [running])
1244
-
1245
- // 结束提示只是一次性反馈:6 秒后自己收掉,免得它一直挂在卡片里,
1246
- // 和下面「上一次」的原因并列成两段一样的文字。
1247
- useEffect(() => {
1248
- if (running || runHint === '') return undefined
1249
- const timer = setTimeout(() => setRunHint(''), 6000)
1250
- return () => clearTimeout(timer)
1251
- }, [running, runHint])
1252
-
1253
1180
  const doCleanup = useCallback(async () => {
1254
1181
  if (cleaning) return
1255
1182
  setCleaning(true)
@@ -1269,32 +1196,6 @@ window.__ModuleLoader__.load({
1269
1196
  }
1270
1197
  }, [cleaning])
1271
1198
 
1272
- const doRollback = useCallback(async (target) => {
1273
- if (rolling !== '' || running) return
1274
- // 回滚会换掉正在跑的代码,属于不可轻点的操作,先要一次确认。
1275
- if (confirming !== target) {
1276
- setConfirming(target)
1277
- setRollHint('')
1278
- return
1279
- }
1280
- setConfirming('')
1281
- setRolling(target)
1282
- setRollHint(T.rollingBack)
1283
- try {
1284
- const result = await rollback(target)
1285
- setRollHint(result.ok ? T.rollbackDone + ' · ' + target : T.rollbackFailed + ' · ' + (result.payload?.reason ?? ''))
1286
- try {
1287
- const next = await getState(LANG)
1288
- setState(next)
1289
- setDraft((prev) => (prev === null ? next.settings : prev))
1290
- } catch {}
1291
- } catch {
1292
- setRollHint(T.rollbackFailed)
1293
- } finally {
1294
- setRolling('')
1295
- }
1296
- }, [rolling, running, confirming])
1297
-
1298
1199
  if (phase === 'error') {
1299
1200
  return h('div', { className: S.card },
1300
1201
  h('span', { className: S.err }, T.unavailable),
@@ -1460,112 +1361,10 @@ window.__ModuleLoader__.load({
1460
1361
  cleanHint ? h('span', { className: S.status }, cleanHint) : null,
1461
1362
  ),
1462
1363
  ),
1463
- h('div', { className: S.card },
1464
- // 按钮和它动作的对象放在一起:读「上一次」的人最想做的事就是再跑一次。
1465
- h('div', { className: S.row },
1466
- h('div', { className: S.labelBox },
1467
- h('h3', { className: S.h }, T.lastRun),
1468
- last === null || last === undefined ? h('span', { className: S.hint }, T.never) : null,
1469
- ),
1470
- h('button', { type: 'button', className: S.btnPrimary, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
1471
- ),
1472
- // 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
1473
- progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
1474
- // 三张统计卡,照 cost-meter 概览页的写法:一眼看到「什么时候查的、
1475
- // 查了多少、几个能更」,而不是一串用 · 拼起来的句子。
1476
- last === null || last === undefined ? null : h('div', { className: S.cards },
1477
- h('div', { className: S.stat },
1478
- h('span', { className: S.statK }, T.lastChecked),
1479
- h('span', { className: S.statV, title: last.at || '' }, formatWhen(last.at) || '—'),
1480
- relativeWhen(last.at) ? h('span', { className: S.hint }, relativeWhen(last.at)) : null,
1481
- ),
1482
- h('div', { className: S.stat },
1483
- h('span', { className: S.statK }, T.checked),
1484
- h('span', { className: S.statV }, String(last.checked ?? 0)),
1485
- h('span', { className: S.hint }, T.packages),
1486
- ),
1487
- h('div', { className: S.stat },
1488
- h('span', { className: S.statK }, applied > 0 ? T.lastUpdated : T.lastUpdates),
1489
- h('span', { className: S.statV }, String(applied > 0 ? applied : (last.updates?.length ?? 0))),
1490
- // 卡片里标题已经是「已更新」,副标题只补量词,不再重复一遍「已更新」。
1491
- h('span', { className: S.hint }, applied > 0
1492
- ? T.updatedHint
1493
- : (last.updates?.length ?? 0) > 0 ? T.updates : T.upToDate),
1494
- ),
1495
- ),
1496
- // 原因只说一遍:徽标承接状态词,正文承接句子,两者不重复同一句话。
1497
- (() => {
1498
- if (last === null || last === undefined) return null
1499
- const reason = typeof last.reason === 'string' ? last.reason : ''
1500
- const status = statusLabel(last.status)
1501
- if (reason === '' && status === '') return null
1502
- return h('div', { className: S.row },
1503
- reason === '' ? null : h('span', { className: S.note }, reason),
1504
- status === '' ? null : h('span', { className: badgeClass(last.status) }, status),
1505
- )
1506
- })(),
1507
- // 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
1508
- // 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
1509
- (() => {
1510
- const rows = (Array.isArray(last?.updates) ? last.updates : [])
1511
- .map((item) => describeUpdate(item))
1512
- .filter((row) => row !== null)
1513
- if (rows.length === 0) return null
1514
- return h('div', { className: S.scrollList },
1515
- rows.map((row, index) => h('div', {
1516
- key: row.name + ':' + index,
1517
- className: 'dsh-au-line',
1518
- },
1519
- h('span', { className: S.pkgName, title: row.name }, row.name),
1520
- row.versions === '' ? null : h('span', { className: S.pkgVer }, row.versions),
1521
- )),
1522
- )
1523
- })(),
1524
- // 镜像落后和「装不了」都要按名字说出来:只报「已是最新」或「一个没装上」,
1525
- // 用户没法知道该换源还是该升 DSH。
1526
- (last?.lagged?.length ?? 0) > 0
1527
- ? h('p', { className: S.note }, T.lagNote.replace('{n}', String(last.lagged.length)) + ' · ' +
1528
- last.lagged.slice(0, 3).map((row) => row.name + ' ' + (row.mirror ?? '?') + ' → ' + (row.upstream ?? '?')).join(','))
1529
- : null,
1530
- (last?.blocked?.length ?? 0) > 0
1531
- ? h('p', { className: S.note }, T.blockedNote.replace('{n}', String(last.blocked.length)) + ' · ' +
1532
- last.blocked.slice(0, 3).map((row) => row.name + '@' + (row.target ?? '?')).join(','))
1533
- : null,
1534
- runHint ? h('span', { className: S.status }, runHint) : null,
1535
- ),
1536
- // 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
1537
- h('div', { className: S.card },
1538
- h('h3', { className: S.h }, T.history),
1539
- (state?.history?.length ?? 0) === 0
1540
- ? h('span', { className: S.status }, T.historyEmpty)
1541
- : h('div', { className: S.scrollList },
1542
- state.history.map((row, index) => h('div', {
1543
- key: row.name + '@' + row.at + ':' + index,
1544
- className: S.row,
1545
- },
1546
- h('div', { className: S.labelBox },
1547
- h('span', null, row.name + ' ' + (row.from ?? '?') + ' → ' + (row.to ?? '?')),
1548
- h('span', { className: S.hint, title: row.at || '' },
1549
- formatWhen(row.at) + (relativeWhen(row.at) ? '(' + relativeWhen(row.at) + ')' : '') +
1550
- (row.rolledBack === true ? ' · ' + T.rolledBack : '')),
1551
- ),
1552
- row.rolledBack === true || typeof row.from !== 'string' || row.from === ''
1553
- ? null
1554
- : h('button', {
1555
- type: 'button',
1556
- className: confirming === row.name ? S.btnPrimary : S.btn,
1557
- disabled: rolling !== '' || running,
1558
- onClick: () => void doRollback(row.name),
1559
- }, rolling === row.name ? T.rollingBack : confirming === row.name ? T.rollback + '?' : T.rollback),
1560
- )),
1561
- ),
1562
- rollHint ? h('span', { className: S.status }, rollHint) : null,
1563
- ),
1564
- h(LogCard, null),
1565
1364
  // 没有保存按钮:改动自己在 350ms 后落盘,这里只报它落没落成。
1566
1365
  saveHint ? h('span', { className: S.status }, saveHint) : null,
1567
1366
  h('span', { className: S.hint }, T.scope),
1568
- h(AboutCard, { version: state?.version }),
1367
+
1569
1368
  )
1570
1369
  }
1571
1370
 
@@ -1930,13 +1729,6 @@ window.__ModuleLoader__.load({
1930
1729
  }
1931
1730
  }
1932
1731
 
1933
- /**
1934
- * 「版本管理」标签页。
1935
- *
1936
- * 和设置页的分工:设置页管「什么时候自动升」,这一页管「现在就要某一版」。
1937
- * 版本列表按包按需拉(一次一个包),不进首屏:整页一次拉一堆包的 packument
1938
- * 在镜像上会慢到没法用。
1939
- */
1940
1732
  /**
1941
1733
  * 「版本管理」标签页。
1942
1734
  *
@@ -1946,6 +1738,133 @@ window.__ModuleLoader__.load({
1946
1738
  *
1947
1739
  * 和设置页的分工没变:设置页管「什么时候自动升」,这一页管「现在就要某一版」。
1948
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
+
1949
1868
  function VersionsTab() {
1950
1869
  useLang()
1951
1870
  const [state, setState] = useState(null)
@@ -2146,31 +2065,9 @@ window.__ModuleLoader__.load({
2146
2065
  h('h3', { className: S.title }, T.versionsTitle),
2147
2066
  h('p', { className: S.sub }, T.versionsSubtitle),
2148
2067
  ),
2149
- // 概览:需处理 / 可升级 / 已装。刻意只留三个能让人立刻行动的数字。
2150
- h('div', { className: S.card },
2151
- h('div', { className: S.cards },
2152
- h('div', { className: S.stat },
2153
- h('span', { className: S.statK }, T.versionsAttention),
2154
- h('span', { className: S.statV }, String(attention.length)),
2155
- h('span', { className: S.hint }, attention.length > 0 ? attention.slice(0, 2).map((item) => item.name).join('、') : T.versionsEmpty),
2156
- ),
2157
- h('div', { className: S.stat },
2158
- h('span', { className: S.statK }, T.versionsUpgradable),
2159
- h('span', { className: S.statV }, String(updatable.size)),
2160
- h('span', { className: S.hint }, state?.lastRun?.at ? formatWhen(state.lastRun.at) : T.never),
2161
- ),
2162
- h('div', { className: S.stat },
2163
- h('span', { className: S.statK }, T.versionsInstalledCount),
2164
- h('span', { className: S.statV }, String(packages.length)),
2165
- h('span', { className: S.hint }, T.versionsCount.replace('{n}', String(packages.length))),
2166
- ),
2167
- ),
2168
- h('div', { className: S.meta },
2169
- h('span', null, T.dshVersion + ': ' + (state?.dshVersion ?? '—')),
2170
- h('span', null, T.registry + ': ' + (state?.registry === '' || !state?.registry ? T.regPnpm : state.registry)),
2171
- ),
2172
- progress ? h('span', { className: 'dsh-au-badge run' }, runningText) : null,
2173
- ),
2068
+ // 现状只有数字和一句结论:标题和「立刻检查」都去掉了——工具条上已经有
2069
+ // 「检查并安装」,同一页里放两个功能相同的按钮只会让人犹豫点哪个。
2070
+ h(LastRunCard, { state: state, attention: attention, busy: busy !== '' }),
2174
2071
  // 工具条
2175
2072
  h('div', { className: S.card },
2176
2073
  h('div', { className: S.vhead },
@@ -2256,7 +2153,7 @@ window.__ModuleLoader__.load({
2256
2153
  h('div', { className: S.card },
2257
2154
  ordered.length === 0
2258
2155
  ? h('span', { className: S.status }, T.versionsEmpty)
2259
- : h('div', { className: S.scrollList },
2156
+ : h('div', { className: 'dsh-au-plist' },
2260
2157
  ordered.map((item) => {
2261
2158
  const listed = lists[item.name]
2262
2159
  const expanded = openName === item.name
@@ -2318,6 +2215,20 @@ window.__ModuleLoader__.load({
2318
2215
  }),
2319
2216
  ),
2320
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
+ ),
2321
2232
  h('span', { className: S.hint }, T.scope),
2322
2233
  )
2323
2234
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aupdate",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "type": "module",
5
5
  "description": "定时检查 DSH 插件更新,串行安装后就地生效,不重启;支持多种调度节奏、失败抑制、按包回滚,并在动手前留快照、忙时自动让开;不更新/只更新哪些插件改成勾选,发现更新在右下角提醒,日志最新在最上面,并在「设置 → 插件更新」里有独立一页。",
6
6
  "license": "MIT",