dsh-aupdate 0.8.4 → 0.8.5

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 (4) hide show
  1. package/README.md +26 -2
  2. package/client.js +36 -12
  3. package/index.js +4 -1
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -224,7 +224,17 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
224
224
 
225
225
  这一页还把 aupdate 自己的设置嵌了进来(工具条上的「设置」),改完不用切回设置页。
226
226
 
227
- 工具条从左到右:搜索、检查更新(绕过缓存)、一键升级、升级选中 N 个、注册表、复制诊断、设置。
227
+ 工具条从左到右:搜索、主按钮、一键升级、升级选中 N 个、注册表、复制诊断、设置。
228
+
229
+ 主按钮的名字跟着「自动安装新版本」走:开着时叫**检查并安装**(重新查一遍 registry,查到就装),
230
+ 关掉时叫**只检查**(查到只列出来,不动手)。它以前一律叫「检查更新」、一律只查不装,于是开着
231
+ 自动安装的人点完发现什么都没装,只能再去点「一键升级」——现在名字和动作对上了。
232
+
233
+ **一键升级**永远真的装:它带 `force`,不受「自动安装」这个开关限制(那个开关管的是定时轮次,
234
+ 不是人按下的按钮),并且复用 10 分钟内的查询结果,点了就动手、不重查。
235
+
236
+ 「自动安装」关掉时,查到的可更新插件会**排到列表最上面**:这时「看得见」就等于「要不要动手」,
237
+ 埋在一屏之外等于没查到。开着自动安装时不需要这个排序。
228
238
  顶部三个数字分别是**需处理**(已装版本声明的 DSH 范围不满足,或者读不到已装版本——这些包很可能
229
239
  根本没被加载,升级救不了它们)、**可升级**、**已装**。
230
240
 
@@ -519,7 +529,21 @@ first paint: fetching packuments for a whole page of packages is unusably slow o
519
529
  This page also embeds aupdate's own settings (the **Settings** button in the toolbar), so there is
520
530
  no need to switch back to the settings page.
521
531
 
522
- The toolbar is: search, Check now (bypasses the cache), Upgrade all, Upgrade the N selected,
532
+ The toolbar is: search, the primary button, Upgrade all, Upgrade the N selected, Registries,
533
+ Copy diagnostics, Settings.
534
+
535
+ The primary button follows **Install new versions**: when that is on it reads **Check and install**
536
+ (re-queries the registry and installs what it finds); when it is off it reads **Check only** (lists
537
+ what is newer, touches nothing). It used to be called "Check now" and always ran a check-only pass,
538
+ so anyone with auto-install on saw nothing installed and had to press Upgrade all afterwards.
539
+
540
+ **Upgrade all** always installs: it sends `force`, so the auto-install switch does not gate it (that
541
+ switch governs scheduled cycles, not a button someone pressed), and it reuses a lookup less than 10
542
+ minutes old instead of re-querying.
543
+
544
+ With auto-install off, plugins that can update are sorted to the top of the list: seeing them is the
545
+ decision, and burying them below the fold is the same as not finding them. With auto-install on the
546
+ sort is unnecessary, so the list stays alphabetical.
523
547
  Registries, Copy diagnostics, Settings. The three numbers on top are **Needs attention** (the
524
548
  installed version declares a DSH range this host does not satisfy, or the installed version is
525
549
  unreadable — those bundles are likely not loaded at all, and upgrading cannot fix them),
package/client.js CHANGED
@@ -164,7 +164,8 @@ window.__ModuleLoader__.load({
164
164
  versionsNoop: '已经是这一版',
165
165
  versionsFail: '切换失败',
166
166
  versionsTotal: '共 {n} 个版本',
167
- versionsChecks: '检查更新',
167
+ versionsCheckInstall: '检查并安装',
168
+ versionsCheckOnly: '只检查',
168
169
  versionsUpgradeAll: '一键升级',
169
170
  versionsUpgradePicked: '升级选中 {n}',
170
171
  versionsSources: '注册表',
@@ -369,7 +370,8 @@ window.__ModuleLoader__.load({
369
370
  versionsNoop: 'Already on this version',
370
371
  versionsFail: 'Switch failed',
371
372
  versionsTotal: '{n} versions',
372
- versionsChecks: 'Check now',
373
+ versionsCheckInstall: 'Check and install',
374
+ versionsCheckOnly: 'Check only',
373
375
  versionsUpgradeAll: 'Upgrade all',
374
376
  versionsUpgradePicked: 'Upgrade {n}',
375
377
  versionsSources: 'Registries',
@@ -1992,10 +1994,6 @@ window.__ModuleLoader__.load({
1992
1994
  }, [])
1993
1995
 
1994
1996
  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
1997
 
2000
1998
  // 最近一轮里「查到的可更新版本」和「镜像落后」:都用名字索引,行上直接查。
2001
1999
  const updatable = useMemo(() => {
@@ -2016,6 +2014,23 @@ window.__ModuleLoader__.load({
2016
2014
  return mark
2017
2015
  }, [state])
2018
2016
 
2017
+ // 「自动安装」关掉时,把查到的可更新项顶到最上面:这时「看得见」就等于「要不要动手」,
2018
+ // 埋在一屏之外的长列表里等于没查到。开着自动安装时它们会被装掉,不需要这个排序。
2019
+ const autoApply = state?.settings?.autoApply !== false
2020
+ const ordered = useMemo(() => {
2021
+ const filtered = (() => {
2022
+ const needle = query.trim().toLowerCase()
2023
+ return needle === '' ? packages : packages.filter((item) => String(item.name).toLowerCase().includes(needle))
2024
+ })()
2025
+ if (autoApply) return filtered
2026
+ return filtered.slice().sort((a, b) => {
2027
+ const ua = updatable.has(a.name) ? 0 : 1
2028
+ const ub = updatable.has(b.name) ? 0 : 1
2029
+ if (ua !== ub) return ua - ub
2030
+ return a.name < b.name ? -1 : a.name > b.name ? 1 : 0
2031
+ })
2032
+ }, [packages, query, autoApply, updatable])
2033
+
2019
2034
  const attention = useMemo(() => packages.filter((item) => item.ok === false || item.version === ''), [packages])
2020
2035
  const pickedNames = useMemo(() => packages.filter((item) => picked[item.name] === true).map((item) => item.name), [packages, picked])
2021
2036
 
@@ -2082,11 +2097,11 @@ window.__ModuleLoader__.load({
2082
2097
  await reload()
2083
2098
  }, [busy, post, reload])
2084
2099
 
2085
- const runCycle = useCallback(async (mode, names, fresh) => {
2100
+ const runCycle = useCallback(async (mode, names, fresh, force) => {
2086
2101
  if (busy !== '') return
2087
2102
  setBusy('cycle')
2088
2103
  setHint('')
2089
- const { ok, payload } = await post('run', { mode, names: names ?? [], fresh: fresh === true })
2104
+ const { ok, payload } = await post('run', { mode, names: names ?? [], fresh: fresh === true, force: force === true })
2090
2105
  if (!ok) setHint(T.versionsFail)
2091
2106
  else if (payload?.started === false) setHint(payload?.reason || T.running)
2092
2107
  else setHint(T.runDone)
@@ -2168,8 +2183,17 @@ window.__ModuleLoader__.load({
2168
2183
  style: { flex: '1 1 200px' },
2169
2184
  }),
2170
2185
  h('div', { className: S.actions },
2171
- h('button', { type: 'button', className: S.btn, disabled: busy !== '', onClick: () => void runCycle('check', [], true) }, T.versionsChecks),
2172
- h('button', { type: 'button', className: S.btnPrimary, disabled: busy !== '', onClick: () => void runCycle('update', [], true) }, T.versionsUpgradeAll),
2186
+ // 主按钮的语义跟着设置走:开着自动安装时它就是「检查并安装」(查到就装),
2187
+ // 关掉时退化成「只检查」。名字必须跟着变,否则「检查更新」不装东西会像 bug。
2188
+ h('button', {
2189
+ type: 'button',
2190
+ className: S.btn,
2191
+ disabled: busy !== '',
2192
+ onClick: () => void runCycle(autoApply ? 'update' : 'check', [], true, autoApply),
2193
+ }, autoApply ? T.versionsCheckInstall : T.versionsCheckOnly),
2194
+ // 「一键升级」永远真的装:force 让它不被「自动安装」开关挡住,
2195
+ // 但复用 10 分钟内的查询结果(fresh=false),点了就动手、不重查。
2196
+ h('button', { type: 'button', className: S.btnPrimary, disabled: busy !== '', onClick: () => void runCycle('update', [], false, true) }, T.versionsUpgradeAll),
2173
2197
  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
2198
  h('button', { type: 'button', className: S.btn, onClick: () => setShowSources((v) => !v) }, T.versionsSources),
2175
2199
  h('button', { type: 'button', className: S.btn, onClick: () => void copyDiagnostics() }, T.versionsDiagnostics),
@@ -2230,10 +2254,10 @@ window.__ModuleLoader__.load({
2230
2254
  : null,
2231
2255
  // 包列表:勾选 → 升级选中;展开 → 全部版本 → 切过去。
2232
2256
  h('div', { className: S.card },
2233
- rows.length === 0
2257
+ ordered.length === 0
2234
2258
  ? h('span', { className: S.status }, T.versionsEmpty)
2235
2259
  : h('div', { className: S.scrollList },
2236
- rows.map((item) => {
2260
+ ordered.map((item) => {
2237
2261
  const listed = lists[item.name]
2238
2262
  const expanded = openName === item.name
2239
2263
  const behind = lagged.get(item.name)
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
- if (mode === 'check' || !settings.autoApply) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aupdate",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "type": "module",
5
5
  "description": "定时检查 DSH 插件更新,串行安装后就地生效,不重启;支持多种调度节奏、失败抑制、按包回滚,并在动手前留快照、忙时自动让开;不更新/只更新哪些插件改成勾选,发现更新在右下角提醒,日志最新在最上面,并在「设置 → 插件更新」里有独立一页。",
6
6
  "license": "MIT",