dsh-aupdate 0.8.2 → 0.8.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 +11 -20
- package/client.js +148 -153
- package/index.js +24 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,9 +136,15 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
136
136
|
插件页里的这一行有摘要和整页两种视图。**没有保存按钮**:每个改动就地落盘(攒 350ms
|
|
137
137
|
合成一次请求,请求串行,不并发写同一个设置文件),落盘后立刻按新节奏重排,不用重启。
|
|
138
138
|
数字框每敲一个字符都会变一次,但不会一个字符发一个请求。
|
|
139
|
-
|
|
139
|
+
这份界面挂在**插件页那一行**和**插件配置页**里;0.8.3 起不再单独占「设置 → 插件更新」一页,
|
|
140
|
+
额外入口是插件页顶栏「版本管理」里的「设置」按钮。升级后第一次打开会弹一张一次性提示卡告诉你入口搬到哪了。
|
|
140
141
|
读写走 `/api/dsh-aupdate/{state,run,rollback,logs}`。
|
|
141
142
|
|
|
143
|
+
保存走覆盖层:只有这里改过的键才写进 `~/.dsh/aupdate-settings.json`,其余沿用默认值。
|
|
144
|
+
后端对每个键都有校验分支(布尔键只认布尔、数字键按范围夹紧、`registryMode` 认四种模式、
|
|
145
|
+
`registryUrl` 只认 `http(s)`),**没有分支的键会被丢掉**;所以保存之后界面会拿服务端返回的
|
|
146
|
+
快照和刚才提交的值比对,没存下来的键会直接写「这些没存下来:…」而不是「已保存」。
|
|
147
|
+
|
|
142
148
|
版面按 `dsh-cost-meter` 的设置页组织:一栏一栏的分区卡片、小号分区标题、浅一档的说明
|
|
143
149
|
文字,主/次两级小按钮;「上一次」不再是一串用 `·` 拼起来的句子,而是三张统计卡
|
|
144
150
|
(上次检查 / 检查包数 / 可更新)加一个状态徽标。颜色与边框全部取自宿主主题变量
|
|
@@ -225,14 +231,6 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
|
|
|
225
231
|
「注册表」面板列出三档预设,每行能单独测(`/-/ping` 和根地址同时发,谁先答应用谁,整次 5 秒
|
|
226
232
|
封顶),也能直接切过去;自定义源可以填完先测再切。
|
|
227
233
|
|
|
228
|
-
## 显示位置
|
|
229
|
-
|
|
230
|
-
设置页有一组开关,决定这个插件挂在哪些地方:**设置 → 插件更新**、**插件页里的那一行**、
|
|
231
|
-
**插件配置页**、**插件页「版本管理」标签**。关掉的那一处干脆不注册槽位,而不是挂上去再渲染成
|
|
232
|
-
空条目。
|
|
233
|
-
|
|
234
|
-
「挂不挂」是在插件加载时决定的,而那时读不到后端设置,所以选择会在 localStorage 里存一份镜像
|
|
235
|
-
供加载时同步读取;改完开关后插件会**就地重载**一次,新的一组槽位立刻生效,不用重启 DSH。
|
|
236
234
|
|
|
237
235
|
## 安装源与兼容性预检
|
|
238
236
|
|
|
@@ -464,8 +462,10 @@ The row in the plugins page shows a summary and a full page. There is **no Save
|
|
|
464
462
|
every change is persisted as you make it — coalesced into one request over 350 ms, sent
|
|
465
463
|
serially so two requests never write the same settings file at once — and re-schedules
|
|
466
464
|
immediately without a restart. A number field fires per keystroke; that does not become
|
|
467
|
-
one request per character. The same UI
|
|
468
|
-
**Settings → Plugin updates
|
|
465
|
+
one request per character. The same UI lives in **the plugins-page row** and in **the plugin config page**. Since 0.8.3 it is
|
|
466
|
+
no longer its own page under **Settings → Plugin updates**; the extra entry is the **Settings**
|
|
467
|
+
button inside the plugins-page Versions tab. The first time you open the app after upgrading, a
|
|
468
|
+
one-shot notice says where it went.
|
|
469
469
|
|
|
470
470
|
The layout follows the `dsh-cost-meter` settings page: stacked section cards, small section
|
|
471
471
|
headings, one-step-muted secondary text and two button tiers. "Last run" is no longer a run
|
|
@@ -529,15 +529,6 @@ The **Registries** panel lists the three presets, each with its own Test button
|
|
|
529
529
|
root URL are fired together and whichever answers first wins, inside a 5 s budget) and a switch; a
|
|
530
530
|
custom URL can be tested before it is used.
|
|
531
531
|
|
|
532
|
-
## Where it shows
|
|
533
|
-
|
|
534
|
-
A group of switches decides which surfaces this plugin occupies: **Settings → Plugin updates**,
|
|
535
|
-
**the row in the plugins page**, **the plugin config page**, and **the plugins page Versions tab**.
|
|
536
|
-
A disabled surface is not registered at all, rather than registered and rendered empty.
|
|
537
|
-
|
|
538
|
-
Whether a slot is registered is decided at plugin load time, when the backend settings are not
|
|
539
|
-
readable, so the choice is mirrored into localStorage for that synchronous read; changing a switch
|
|
540
|
-
reloads the plugin in place, so the new set of slots takes effect without restarting DSH.
|
|
541
532
|
|
|
542
533
|
## Registry and compatibility pre-check
|
|
543
534
|
|
package/client.js
CHANGED
|
@@ -77,6 +77,7 @@ window.__ModuleLoader__.load({
|
|
|
77
77
|
saving: '保存中…',
|
|
78
78
|
saved: '已保存',
|
|
79
79
|
savedHint: '新设置立即生效,不用重启',
|
|
80
|
+
saveIgnored: '这些没存下来:{keys}(后端没有对应处理)',
|
|
80
81
|
failed: '保存失败',
|
|
81
82
|
runNow: '立刻检查',
|
|
82
83
|
running: '正在检查…',
|
|
@@ -182,12 +183,9 @@ window.__ModuleLoader__.load({
|
|
|
182
183
|
versionsCopyFail: '复制失败',
|
|
183
184
|
versionsDiagnostics: '复制诊断',
|
|
184
185
|
versionsCustomSource: '自定义源',
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
showRow: '插件页里的这一行',
|
|
189
|
-
showBundle: '插件配置页',
|
|
190
|
-
showTab: '插件页「版本管理」标签',
|
|
186
|
+
movedTitle: '设置页搬到插件页了',
|
|
187
|
+
movedBadge: '已搬家',
|
|
188
|
+
movedBody: '「设置 → 插件更新」不再单独占一页:设置就在插件页那张卡里;也可以在插件页顶栏「版本管理」里点「设置」。',
|
|
191
189
|
maxPerCycle: '一轮最多装几个',
|
|
192
190
|
maxPerCycleHint: '0 表示不限。装包会一直占着 pnpm 锁,限一个数就把单次占用封顶,剩下的下一轮接着装',
|
|
193
191
|
sessionIdle: '会话静默(分钟)',
|
|
@@ -284,6 +282,7 @@ window.__ModuleLoader__.load({
|
|
|
284
282
|
saving: 'Saving…',
|
|
285
283
|
saved: 'Saved',
|
|
286
284
|
savedHint: 'Takes effect immediately, no restart',
|
|
285
|
+
saveIgnored: 'Not stored: {keys} (no backend handling)',
|
|
287
286
|
failed: 'Save failed',
|
|
288
287
|
runNow: 'Check now',
|
|
289
288
|
running: 'Checking…',
|
|
@@ -389,12 +388,9 @@ window.__ModuleLoader__.load({
|
|
|
389
388
|
versionsCopyFail: 'Could not copy',
|
|
390
389
|
versionsDiagnostics: 'Copy diagnostics',
|
|
391
390
|
versionsCustomSource: 'Custom registry',
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
showRow: 'The row in the plugins page',
|
|
396
|
-
showBundle: 'Plugin config page',
|
|
397
|
-
showTab: 'Plugins page "Versions" tab',
|
|
391
|
+
movedTitle: 'Settings moved into the plugins page',
|
|
392
|
+
movedBadge: 'Moved',
|
|
393
|
+
movedBody: '"Settings → Plugin updates" is no longer a page of its own: the same controls live in the plugins-page card, and under Versions → Settings.',
|
|
398
394
|
maxPerCycle: 'Installs per cycle',
|
|
399
395
|
maxPerCycleHint: '0 means no limit. pnpm holds a lock for the whole install, so a cap bounds how long the profile stays busy; the rest wait for the next cycle',
|
|
400
396
|
sessionIdle: 'Session quiet window (minutes)',
|
|
@@ -769,41 +765,6 @@ window.__ModuleLoader__.load({
|
|
|
769
765
|
@media (prefers-reduced-motion:reduce){.dsh-au-toast{animation:none}}
|
|
770
766
|
`
|
|
771
767
|
|
|
772
|
-
/* ── 显示位置 ─────────────────────────────────────────────────────────
|
|
773
|
-
*
|
|
774
|
-
* 四个挂载点各自可以被关掉。麻烦在于「挂不挂」是在 apply() 里决定的,
|
|
775
|
-
* 而 apply() 是同步的、拿不到后端的设置——设置要等 /state 回来。
|
|
776
|
-
*
|
|
777
|
-
* 所以把选择在 localStorage 里存一份镜像:设置页每次拿到 /state 就刷一次,
|
|
778
|
-
* apply() 同步读它。改完显示开关后后端会让插件就地重载一次,apply() 重新跑,
|
|
779
|
-
* 读到的就是新值——不需要重启 DSH。
|
|
780
|
-
*
|
|
781
|
-
* 读不到(第一次装、换浏览器)时全部按「显示」,和改造前一致。
|
|
782
|
-
*/
|
|
783
|
-
const DISPLAY_KEY = 'dsh-aupdate:display'
|
|
784
|
-
const DISPLAY_FIELDS = ['showSettingsSection', 'showPluginsRow', 'showPluginsBundle', 'showVersionsTab']
|
|
785
|
-
|
|
786
|
-
function readDisplay() {
|
|
787
|
-
const value = { showSettingsSection: true, showPluginsRow: true, showPluginsBundle: true, showVersionsTab: true }
|
|
788
|
-
try {
|
|
789
|
-
const raw = window.localStorage.getItem(DISPLAY_KEY)
|
|
790
|
-
if (raw === null) return value
|
|
791
|
-
const parsed = JSON.parse(raw)
|
|
792
|
-
for (const key of DISPLAY_FIELDS) {
|
|
793
|
-
if (typeof parsed?.[key] === 'boolean') value[key] = parsed[key]
|
|
794
|
-
}
|
|
795
|
-
} catch {}
|
|
796
|
-
return value
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
function writeDisplay(settings) {
|
|
800
|
-
try {
|
|
801
|
-
const value = {}
|
|
802
|
-
for (const key of DISPLAY_FIELDS) value[key] = settings?.[key] !== false
|
|
803
|
-
window.localStorage.setItem(DISPLAY_KEY, JSON.stringify(value))
|
|
804
|
-
} catch {}
|
|
805
|
-
}
|
|
806
|
-
|
|
807
768
|
/** 只注入一次:id 存在就跳过,重复挂载/热更新都不会叠出第二份样式表。 */
|
|
808
769
|
function installStyles() {
|
|
809
770
|
try {
|
|
@@ -1145,8 +1106,6 @@ window.__ModuleLoader__.load({
|
|
|
1145
1106
|
applyLang(next?.settings?.lang)
|
|
1146
1107
|
setState(next)
|
|
1147
1108
|
setDraft(next.settings)
|
|
1148
|
-
// 把显示选择镜像到 localStorage:apply() 下次重载时同步读它。
|
|
1149
|
-
writeDisplay(next.settings)
|
|
1150
1109
|
setPhase('ready')
|
|
1151
1110
|
} catch {
|
|
1152
1111
|
setPhase('error')
|
|
@@ -1204,7 +1163,14 @@ window.__ModuleLoader__.load({
|
|
|
1204
1163
|
// 只换 state(lastRun、history 这些由服务端算),不回灌草稿:
|
|
1205
1164
|
// 草稿里可能已经有比这份响应更新的输入。
|
|
1206
1165
|
setState(next)
|
|
1207
|
-
|
|
1166
|
+
// 服务端对「不认识 / 校验不过」的键会静默丢掉,接口却仍然回 200。
|
|
1167
|
+
// 拿回来的快照和刚才提交的值比一下:没变的就是没存进去,别报「已保存」。
|
|
1168
|
+
// exclude 由服务端重排过,不比;它的顺序不影响语义。
|
|
1169
|
+
const ignored = Object.keys(batch).filter((key) => key !== 'exclude' &&
|
|
1170
|
+
JSON.stringify(next?.settings?.[key]) !== JSON.stringify(batch[key]))
|
|
1171
|
+
setSaveHint(ignored.length > 0
|
|
1172
|
+
? T.saveIgnored.replace('{keys}', ignored.join(', '))
|
|
1173
|
+
: T.saved + ' · ' + T.savedHint)
|
|
1208
1174
|
} catch {
|
|
1209
1175
|
// 失败的键补回队列,下次改动会一起重试,不静默吞掉用户的设置。
|
|
1210
1176
|
pendingRef.current = { ...batch, ...pendingRef.current }
|
|
@@ -1229,11 +1195,6 @@ window.__ModuleLoader__.load({
|
|
|
1229
1195
|
useEffect(() => () => {
|
|
1230
1196
|
if (timerRef.current !== null) clearTimeout(timerRef.current)
|
|
1231
1197
|
}, [])
|
|
1232
|
-
// 显示开关一改就刷镜像:就地重载是在 1.2 秒后发生的,那时 apply() 读的
|
|
1233
|
-
// 就是这份镜像——不跟着改,切换会看起来「没生效」,要再加载一次才对。
|
|
1234
|
-
useEffect(() => {
|
|
1235
|
-
if (draft !== null) writeDisplay(draft)
|
|
1236
|
-
}, [draft])
|
|
1237
1198
|
|
|
1238
1199
|
|
|
1239
1200
|
/** 把后端进度翻成一行中文/英文;没进度就退回普通「正在检查」。 */
|
|
@@ -1463,16 +1424,6 @@ window.__ModuleLoader__.load({
|
|
|
1463
1424
|
h('span', null, T.registry + ': ' + (state?.registry === '' || !state?.registry ? T.regPnpm : state.registry)),
|
|
1464
1425
|
),
|
|
1465
1426
|
),
|
|
1466
|
-
// 显示位置:四个挂载点各自可以关掉。设置本身存在后端,客户端只是把它镜像
|
|
1467
|
-
// 到 localStorage,供 apply() 在注册槽位时同步判断(见 readDisplay 的注释)。
|
|
1468
|
-
h('div', { className: S.card },
|
|
1469
|
-
h('h3', { className: S.h }, T.displayGroup),
|
|
1470
|
-
h('p', { className: S.note }, T.displayHint),
|
|
1471
|
-
h(SwitchRow, { label: T.showSettings, value: draft.showSettingsSection !== false, onChange: (v) => patch('showSettingsSection', v) }),
|
|
1472
|
-
h(SwitchRow, { label: T.showRow, value: draft.showPluginsRow !== false, onChange: (v) => patch('showPluginsRow', v) }),
|
|
1473
|
-
h(SwitchRow, { label: T.showBundle, value: draft.showPluginsBundle !== false, onChange: (v) => patch('showPluginsBundle', v) }),
|
|
1474
|
-
h(SwitchRow, { label: T.showTab, value: draft.showVersionsTab !== false, onChange: (v) => patch('showVersionsTab', v) }),
|
|
1475
|
-
),
|
|
1476
1427
|
h('div', { className: S.card },
|
|
1477
1428
|
h('h3', { className: S.h }, T.keepTitle),
|
|
1478
1429
|
h('p', { className: S.note }, T.keepHint),
|
|
@@ -1790,14 +1741,20 @@ window.__ModuleLoader__.load({
|
|
|
1790
1741
|
.join('|')
|
|
1791
1742
|
}
|
|
1792
1743
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1744
|
+
/* ── 右下角通知卡 ─────────────────────────────────────────────────────
|
|
1745
|
+
*
|
|
1746
|
+
* 一张卡两种用途:更新提醒,和「设置页搬家」这类一次性告知。结构照
|
|
1747
|
+
* dsh-cost-meter 的峰/谷提醒:圆点徽标 → 标题行(带 ×)→ 一句正文 →
|
|
1748
|
+
* 可选清单 → 主按钮。
|
|
1749
|
+
*
|
|
1750
|
+
* 同一时刻只挂一张:两张叠在右下角会互相挡住,而这两种通知都不紧急。
|
|
1751
|
+
*/
|
|
1752
|
+
function showNotice(options) {
|
|
1795
1753
|
const doc = typeof document === 'undefined' ? null : document
|
|
1796
|
-
if (doc === null || doc.body === null) return
|
|
1797
|
-
|
|
1798
|
-
if (rows.length === 0) return
|
|
1754
|
+
if (doc === null || doc.body === null) return false
|
|
1755
|
+
if (toastOpen) return false
|
|
1799
1756
|
toastOpen = true
|
|
1800
|
-
//
|
|
1757
|
+
// 提醒可能在任何页面弹出来,样式表没装就先补上(幂等)。
|
|
1801
1758
|
installStyles()
|
|
1802
1759
|
const box = doc.createElement('div')
|
|
1803
1760
|
box.setAttribute('data-dsh-aupdate', 'toast')
|
|
@@ -1805,58 +1762,59 @@ window.__ModuleLoader__.load({
|
|
|
1805
1762
|
box.setAttribute('role', 'status')
|
|
1806
1763
|
box.setAttribute('aria-live', 'polite')
|
|
1807
1764
|
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1765
|
+
if (options.badge) {
|
|
1766
|
+
const badge = doc.createElement('div')
|
|
1767
|
+
badge.className = 'dsh-au-toast-badge'
|
|
1768
|
+
badge.textContent = options.badge
|
|
1769
|
+
box.appendChild(badge)
|
|
1770
|
+
}
|
|
1814
1771
|
|
|
1815
1772
|
const head = doc.createElement('div')
|
|
1816
1773
|
head.className = 'dsh-au-toast-head'
|
|
1817
1774
|
const title = doc.createElement('div')
|
|
1818
1775
|
title.className = 'dsh-au-toast-title'
|
|
1819
|
-
|
|
1820
|
-
title.textContent = (applied > 0 ? T.toastTitle : T.toastTitleFound).replace('{n}', String(rows.length))
|
|
1776
|
+
title.textContent = options.title
|
|
1821
1777
|
const xBtn = doc.createElement('button')
|
|
1822
1778
|
xBtn.type = 'button'
|
|
1823
1779
|
xBtn.className = 'dsh-au-toast-x'
|
|
1824
1780
|
xBtn.textContent = '×'
|
|
1825
|
-
xBtn.setAttribute('aria-label',
|
|
1781
|
+
xBtn.setAttribute('aria-label', options.dismissLabel)
|
|
1826
1782
|
head.appendChild(title)
|
|
1827
1783
|
head.appendChild(xBtn)
|
|
1828
1784
|
box.appendChild(head)
|
|
1829
1785
|
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
const list = doc.createElement('div')
|
|
1836
|
-
list.className = 'dsh-au-toast-list'
|
|
1837
|
-
// 超过 12 条就在框内滚动:提醒不该占掉半屏。
|
|
1838
|
-
for (const row of rows.slice(0, 12)) {
|
|
1839
|
-
const line = doc.createElement('div')
|
|
1840
|
-
line.className = 'dsh-au-toast-item'
|
|
1841
|
-
const nameEl = doc.createElement('span')
|
|
1842
|
-
nameEl.className = 'dsh-au-toast-name'
|
|
1843
|
-
nameEl.textContent = row.name
|
|
1844
|
-
// 包名可能很长(@scope/name),压缩它而不是压缩版本。
|
|
1845
|
-
line.appendChild(nameEl)
|
|
1846
|
-
if (row.versions !== '') {
|
|
1847
|
-
const verEl = doc.createElement('span')
|
|
1848
|
-
verEl.className = 'dsh-au-toast-ver'
|
|
1849
|
-
verEl.textContent = row.versions
|
|
1850
|
-
line.appendChild(verEl)
|
|
1851
|
-
}
|
|
1852
|
-
list.appendChild(line)
|
|
1786
|
+
if (options.body) {
|
|
1787
|
+
const body = doc.createElement('div')
|
|
1788
|
+
body.className = 'dsh-au-toast-body'
|
|
1789
|
+
body.textContent = options.body
|
|
1790
|
+
box.appendChild(body)
|
|
1853
1791
|
}
|
|
1854
|
-
box.appendChild(list)
|
|
1855
1792
|
|
|
1856
|
-
|
|
1793
|
+
const rows = Array.isArray(options.rows) ? options.rows : []
|
|
1794
|
+
if (rows.length > 0) {
|
|
1795
|
+
const list = doc.createElement('div')
|
|
1796
|
+
list.className = 'dsh-au-toast-list'
|
|
1797
|
+
for (const row of rows) {
|
|
1798
|
+
const line = doc.createElement('div')
|
|
1799
|
+
line.className = 'dsh-au-toast-item'
|
|
1800
|
+
const nameEl = doc.createElement('span')
|
|
1801
|
+
nameEl.className = 'dsh-au-toast-name'
|
|
1802
|
+
nameEl.textContent = row.name
|
|
1803
|
+
line.appendChild(nameEl)
|
|
1804
|
+
if (row.versions !== '') {
|
|
1805
|
+
const verEl = doc.createElement('span')
|
|
1806
|
+
verEl.className = 'dsh-au-toast-ver'
|
|
1807
|
+
verEl.textContent = row.versions
|
|
1808
|
+
line.appendChild(verEl)
|
|
1809
|
+
}
|
|
1810
|
+
list.appendChild(line)
|
|
1811
|
+
}
|
|
1812
|
+
box.appendChild(list)
|
|
1813
|
+
}
|
|
1814
|
+
if (options.more) {
|
|
1857
1815
|
const more = doc.createElement('div')
|
|
1858
1816
|
more.className = 'dsh-au-toast-more'
|
|
1859
|
-
more.textContent =
|
|
1817
|
+
more.textContent = options.more
|
|
1860
1818
|
box.appendChild(more)
|
|
1861
1819
|
}
|
|
1862
1820
|
|
|
@@ -1865,7 +1823,7 @@ window.__ModuleLoader__.load({
|
|
|
1865
1823
|
const close = doc.createElement('button')
|
|
1866
1824
|
close.type = 'button'
|
|
1867
1825
|
close.className = 'dsh-au-btn dsh-au-primary'
|
|
1868
|
-
close.textContent =
|
|
1826
|
+
close.textContent = options.dismissLabel
|
|
1869
1827
|
foot.appendChild(close)
|
|
1870
1828
|
box.appendChild(foot)
|
|
1871
1829
|
|
|
@@ -1888,8 +1846,49 @@ window.__ModuleLoader__.load({
|
|
|
1888
1846
|
xBtn.addEventListener('click', dismiss)
|
|
1889
1847
|
try { doc.addEventListener('keydown', onKey, true) } catch {}
|
|
1890
1848
|
doc.body.appendChild(box)
|
|
1891
|
-
//
|
|
1892
|
-
setTimeout(dismiss, 15000)
|
|
1849
|
+
// 不点也不会一直挂着:默认 15 秒,搬家的提示留长一点。
|
|
1850
|
+
setTimeout(dismiss, options.ms ?? 15000)
|
|
1851
|
+
return true
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
/** 更新提醒:把这一轮发现的版本做成一张通知卡。 */
|
|
1855
|
+
function showUpdateToast(updates, applied) {
|
|
1856
|
+
const rows = (Array.isArray(updates) ? updates : []).map((item) => describeUpdate(item)).filter((row) => row !== null)
|
|
1857
|
+
if (rows.length === 0) return false
|
|
1858
|
+
return showNotice({
|
|
1859
|
+
badge: applied > 0 ? T.toastBadge : T.toastBadgeFound,
|
|
1860
|
+
// 真的装完了才说「已更新」;只查到、没动手时说「可更新」。
|
|
1861
|
+
title: (applied > 0 ? T.toastTitle : T.toastTitleFound).replace('{n}', String(rows.length)),
|
|
1862
|
+
body: applied > 0 ? T.toastBody : T.toastBodyFound,
|
|
1863
|
+
rows: rows.slice(0, 12),
|
|
1864
|
+
more: rows.length > 12 ? T.toastMore.replace('{n}', String(rows.length - 12)) : '',
|
|
1865
|
+
dismissLabel: T.toastDismiss,
|
|
1866
|
+
ms: 15000,
|
|
1867
|
+
})
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
/* 0.8.3 起「设置 → 插件更新」不再单独占一页:入口搬到插件页那张卡、插件配置页
|
|
1871
|
+
* 和版本管理页的「设置」。这里提示一次就够,记在 localStorage 里,不然每开一次
|
|
1872
|
+
* 页面都会弹。 */
|
|
1873
|
+
const MOVED_KEY = 'dsh-aupdate:settings-moved'
|
|
1874
|
+
|
|
1875
|
+
function movedNoticePending() {
|
|
1876
|
+
try { return window.localStorage.getItem(MOVED_KEY) !== '1' } catch { return false }
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
function markMovedNotice() {
|
|
1880
|
+
try { window.localStorage.setItem(MOVED_KEY, '1') } catch {}
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
function showMovedNotice() {
|
|
1884
|
+
return showNotice({
|
|
1885
|
+
badge: T.movedBadge,
|
|
1886
|
+
title: T.movedTitle,
|
|
1887
|
+
body: T.movedBody,
|
|
1888
|
+
rows: [],
|
|
1889
|
+
dismissLabel: T.toastDismiss,
|
|
1890
|
+
ms: 22000,
|
|
1891
|
+
})
|
|
1893
1892
|
}
|
|
1894
1893
|
|
|
1895
1894
|
function startUpdateNotifier() {
|
|
@@ -1900,13 +1899,20 @@ window.__ModuleLoader__.load({
|
|
|
1900
1899
|
try {
|
|
1901
1900
|
const state = await getState(LANG)
|
|
1902
1901
|
if (state?.settings?.notify !== false) {
|
|
1903
|
-
|
|
1904
|
-
if (
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1902
|
+
// 搬家提示排在前面:它只说一次,而更新提醒下一轮还会再来。
|
|
1903
|
+
if (movedNoticePending() && !toastOpen) {
|
|
1904
|
+
markMovedNotice()
|
|
1905
|
+
showMovedNotice()
|
|
1906
|
+
} else {
|
|
1907
|
+
const updates = Array.isArray(state?.lastRun?.updates) ? state.lastRun.updates : []
|
|
1908
|
+
if (updates.length > 0) {
|
|
1909
|
+
// 签名算的是「包名+版本变化」,旧格式也能算出来,不会重复弹。
|
|
1910
|
+
const sig = updateSignature(updates)
|
|
1911
|
+
// 已经挂着一张卡时不标记:留到下一轮再弹,别把提醒吞掉。
|
|
1912
|
+
if (sig !== notifiedMark() && !toastOpen) {
|
|
1913
|
+
markNotified(sig)
|
|
1914
|
+
showUpdateToast(updates, appliedCount(state?.lastRun))
|
|
1915
|
+
}
|
|
1910
1916
|
}
|
|
1911
1917
|
}
|
|
1912
1918
|
}
|
|
@@ -1958,7 +1964,6 @@ window.__ModuleLoader__.load({
|
|
|
1958
1964
|
try {
|
|
1959
1965
|
const next = await getState(LANG)
|
|
1960
1966
|
setState(next)
|
|
1961
|
-
writeDisplay(next?.settings)
|
|
1962
1967
|
} catch {}
|
|
1963
1968
|
}, [])
|
|
1964
1969
|
|
|
@@ -2300,48 +2305,38 @@ window.__ModuleLoader__.load({
|
|
|
2300
2305
|
installStyles()
|
|
2301
2306
|
// 提醒跟着插件一起上、一起卸:ctx.effect 收的是清理函数。
|
|
2302
2307
|
if (typeof ctx.effect === 'function') ctx.effect(startUpdateNotifier, 'dsh-aupdate: update notices')
|
|
2303
|
-
// 「显示位置」:关掉的那一处干脆不注册槽位,而不是挂上去再渲染成空——
|
|
2304
|
-
// 后者会在标签栏/设置导航里留下一个点进去什么都没有的空条目。
|
|
2305
|
-
const display = readDisplay()
|
|
2306
|
-
|
|
2307
2308
|
// key 的格式是「包名#条目id」:本插件在 cordis.patch.yml 里的条目 id 就是包名本身,
|
|
2308
2309
|
// 和 dsh-ops 的 dsh-ops#dsh-ops 一样。写成 #auto-update 之类是挂不上的。
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2314
|
-
}
|
|
2310
|
+
ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
|
|
2311
|
+
name: 'plugins.row.config',
|
|
2312
|
+
key: NS + '#' + NS,
|
|
2313
|
+
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2315
2314
|
|
|
2316
2315
|
// bundle 级配置页用包名做 key,和 free-search 的写法一致。
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2322
|
-
}
|
|
2316
|
+
ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
|
|
2317
|
+
name: 'plugins.bundle.config',
|
|
2318
|
+
key: NS,
|
|
2319
|
+
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2323
2320
|
|
|
2324
|
-
//
|
|
2325
|
-
// 的「渠道余额」。原来只有插件页里那张卡,想改策略得先去插件页翻它。
|
|
2326
|
-
if (display.showSettingsSection) {
|
|
2327
|
-
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
2328
|
-
name: 'settings.section',
|
|
2329
|
-
id: NS,
|
|
2330
|
-
order: 36,
|
|
2331
|
-
label: () => T.pageLabel,
|
|
2332
|
-
}, () => h(AutoUpdateCard)))
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
// 插件页标签栏多一个「版本管理」:和设置页分工——设置页管「什么时候自动升」,
|
|
2321
|
+
// 插件页标签栏多一个「版本管理」:和插件页那张卡分工——那张管「什么时候自动升」,
|
|
2336
2322
|
// 这一页管「现在就要某一版」。order 2 排在「已安装/发现」(0) 和市场(1) 之后。
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2323
|
+
ctx.slots.inject('plugins.tab', () => ctx.slots.register({
|
|
2324
|
+
name: 'plugins.tab',
|
|
2325
|
+
id: NS,
|
|
2326
|
+
order: 2,
|
|
2327
|
+
label: () => T.versionsTab,
|
|
2328
|
+
}, () => h(VersionsTab)))
|
|
2329
|
+
|
|
2330
|
+
// 注意:这里**故意不再注册** 'settings.section'。
|
|
2331
|
+
// 「设置 → 插件更新」原本是独立的一页,现在设置已经在插件页那张卡、
|
|
2332
|
+
// 插件配置页和版本管理页的「设置」里了,多一个入口只是多一处要维护的地方。
|
|
2333
|
+
// 想把它挂回来,取消下面这段注释即可(order 36 是原来的位置)。
|
|
2334
|
+
// ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
2335
|
+
// name: 'settings.section',
|
|
2336
|
+
// id: NS,
|
|
2337
|
+
// order: 36,
|
|
2338
|
+
// label: () => T.pageLabel,
|
|
2339
|
+
// }, () => h(AutoUpdateCard)))
|
|
2345
2340
|
},
|
|
2346
2341
|
}
|
|
2347
2342
|
},
|
package/index.js
CHANGED
|
@@ -241,6 +241,9 @@ function makeLogTemplates(lang) {
|
|
|
241
241
|
? `${name} 镜像落后:镜像 ${mirror},官方 ${upstream}`
|
|
242
242
|
: `${name} mirror lag: mirror ${mirror}, upstream ${upstream}`),
|
|
243
243
|
registryPicked: (source) => (zh ? `安装源:${source}` : `Registry: ${source}`),
|
|
244
|
+
settingsDropped: (keys) => (zh
|
|
245
|
+
? `这些设置没存下来(没有对应的校验分支):${keys.join(', ')}`
|
|
246
|
+
: `These settings were not stored (no validation branch): ${keys.join(', ')}`),
|
|
244
247
|
switching: (name, from, to) => (zh
|
|
245
248
|
? '切换版本:' + name + ' ' + from + ' → ' + to
|
|
246
249
|
: 'Switching: ' + name + ' ' + from + ' → ' + to),
|
|
@@ -541,8 +544,6 @@ const OVERRIDEABLE = [
|
|
|
541
544
|
'allowMajor', 'allowPrerelease',
|
|
542
545
|
// 安装源与兼容性预检(0.8.0 借自 dsh-plugin-upgrader)。
|
|
543
546
|
'registryMode', 'registryUrl', 'compatCheck',
|
|
544
|
-
// 显示位置(设置页 / 插件行 / 插件配置页 / 版本管理标签)。
|
|
545
|
-
'showSettingsSection', 'showPluginsRow', 'showPluginsBundle', 'showVersionsTab',
|
|
546
547
|
// 调度:四种节奏 + 失败抑制时长。这些键不写进 Config schema,
|
|
547
548
|
// 只活在覆盖层里——Config 的字段类型是宿主校验的,加错一个类型
|
|
548
549
|
// 会在加载期直接抛错,而覆盖层是我们自己的文件,改坏了只影响这一项。
|
|
@@ -653,6 +654,20 @@ function writeOverrides(patch) {
|
|
|
653
654
|
if (LANG_CHOICES.includes(text)) next[key] = text
|
|
654
655
|
continue
|
|
655
656
|
}
|
|
657
|
+
// 安装源。这两个键是字符串,而下面的兜底只认布尔——0.7.5 到 0.8.3 它们就是
|
|
658
|
+
// 这样「保存成功、文件里没有」的:POST 返回 200、日志记了 settingsChanged,
|
|
659
|
+
// 界面上却又弹回默认值。凡是新增字符串键,都必须在这里有一支,没有就被丢掉。
|
|
660
|
+
if (key === 'registryMode') {
|
|
661
|
+
const text = typeof raw === 'string' ? raw.trim().toLowerCase() : ''
|
|
662
|
+
if (REGISTRY_MODES.includes(text)) next[key] = text
|
|
663
|
+
continue
|
|
664
|
+
}
|
|
665
|
+
if (key === 'registryUrl') {
|
|
666
|
+
const text = typeof raw === 'string' ? raw.trim().replace(/\/+$/u, '') : ''
|
|
667
|
+
// 空串是合法值(清空自定义地址并退回跟随 pnpm);非空必须是 http(s)。
|
|
668
|
+
if (text === '' || /^https?:\/\/[^\s]+$/iu.test(text)) next[key] = text
|
|
669
|
+
continue
|
|
670
|
+
}
|
|
656
671
|
const bounds = NUMBER_BOUNDS[key]
|
|
657
672
|
if (bounds !== undefined) {
|
|
658
673
|
const value = typeof raw === 'number' ? raw : Number(raw)
|
|
@@ -663,6 +678,13 @@ function writeOverrides(patch) {
|
|
|
663
678
|
if (typeof raw === 'boolean') next[key] = raw
|
|
664
679
|
else if (raw === 'true' || raw === 'false') next[key] = raw === 'true'
|
|
665
680
|
}
|
|
681
|
+
// 传了、也是可覆盖的键,但一个都没落下来:记一条,别再静默成功。
|
|
682
|
+
// 上面那类「字符串键没有分支」的 bug 只有日志能提前暴露。
|
|
683
|
+
const asked = Object.keys(patch ?? {})
|
|
684
|
+
const landed = asked.filter((key) => OVERRIDEABLE.includes(key) && next[key] !== undefined)
|
|
685
|
+
if (asked.length > 0 && landed.length === 0) {
|
|
686
|
+
writeLog('settingsDropped', [asked])
|
|
687
|
+
}
|
|
666
688
|
const file = settingsPath()
|
|
667
689
|
try {
|
|
668
690
|
mkdirSync(dirname(file), { recursive: true })
|
|
@@ -742,12 +764,6 @@ function settingsOf(config) {
|
|
|
742
764
|
// 兼容性预检:装之前先看目标版本声明的 DSH 范围。默认开——宿主闸门是在
|
|
743
765
|
// bundle 已经卸下之后才拒绝的,等它拒绝就已经晚了。
|
|
744
766
|
compatCheck: booleanSetting(config, 'compatCheck', true),
|
|
745
|
-
// 显示位置:四个界面各自能被关掉。关掉由客户端在注册槽位时跳过,
|
|
746
|
-
// 所以改完要重新加载一次插件(POST /state 会自己安排一次就地重载)。
|
|
747
|
-
showSettingsSection: booleanSetting(config, 'showSettingsSection', true),
|
|
748
|
-
showPluginsRow: booleanSetting(config, 'showPluginsRow', true),
|
|
749
|
-
showPluginsBundle: booleanSetting(config, 'showPluginsBundle', true),
|
|
750
|
-
showVersionsTab: booleanSetting(config, 'showVersionsTab', true),
|
|
751
767
|
intervalMinutes: numberSetting(config, 'intervalMinutes', 1440, 10, 10080),
|
|
752
768
|
firstDelayMinutes: numberSetting(config, 'firstDelayMinutes', 5, 0, 1440),
|
|
753
769
|
exclude: stringList(config?.exclude),
|
|
@@ -2766,20 +2782,12 @@ function registerRoutes(scope, ctxRef) {
|
|
|
2766
2782
|
sendJson(res, 400, { error: 'bad json' })
|
|
2767
2783
|
return
|
|
2768
2784
|
}
|
|
2769
|
-
const before = settingsOf(ctxRef.config)
|
|
2770
2785
|
const result = writeOverrides(body)
|
|
2771
2786
|
if (!result.ok) {
|
|
2772
2787
|
sendJson(res, 500, { error: result.error })
|
|
2773
2788
|
return
|
|
2774
2789
|
}
|
|
2775
2790
|
writeLog('settingsChanged', [Object.keys(body)])
|
|
2776
|
-
// 显示位置是「注册哪些槽位」决定的,改完必须重新加载一次插件才生效。
|
|
2777
|
-
// 这里不重启应用,只让本插件就地重载(和装完包之后做的是同一件事)。
|
|
2778
|
-
const displayChanged = ['showSettingsSection', 'showPluginsRow', 'showPluginsBundle', 'showVersionsTab']
|
|
2779
|
-
.some((key) => before[key] !== settingsOf(ctxRef.config)[key])
|
|
2780
|
-
if (displayChanged && settingsOf(ctxRef.config).hotReload) {
|
|
2781
|
-
setTimeout(() => { void hotApply(ctxRef.ctx, []).catch(() => {}) }, 1200).unref?.()
|
|
2782
|
-
}
|
|
2783
2791
|
// 改完立刻按新设置重排,否则要等下一次触发才换节奏。
|
|
2784
2792
|
try {
|
|
2785
2793
|
if (typeof ctxRef.reschedule === 'function') ctxRef.reschedule()
|
package/package.json
CHANGED