dsh-aupdate 0.8.2 → 0.8.3
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 +6 -20
- package/client.js +138 -152
- package/index.js +0 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,7 +136,8 @@ 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
|
|
|
142
143
|
版面按 `dsh-cost-meter` 的设置页组织:一栏一栏的分区卡片、小号分区标题、浅一档的说明
|
|
@@ -225,14 +226,6 @@ stargazers)与「分享」(复制项目地址到剪贴板,任何环境都
|
|
|
225
226
|
「注册表」面板列出三档预设,每行能单独测(`/-/ping` 和根地址同时发,谁先答应用谁,整次 5 秒
|
|
226
227
|
封顶),也能直接切过去;自定义源可以填完先测再切。
|
|
227
228
|
|
|
228
|
-
## 显示位置
|
|
229
|
-
|
|
230
|
-
设置页有一组开关,决定这个插件挂在哪些地方:**设置 → 插件更新**、**插件页里的那一行**、
|
|
231
|
-
**插件配置页**、**插件页「版本管理」标签**。关掉的那一处干脆不注册槽位,而不是挂上去再渲染成
|
|
232
|
-
空条目。
|
|
233
|
-
|
|
234
|
-
「挂不挂」是在插件加载时决定的,而那时读不到后端设置,所以选择会在 localStorage 里存一份镜像
|
|
235
|
-
供加载时同步读取;改完开关后插件会**就地重载**一次,新的一组槽位立刻生效,不用重启 DSH。
|
|
236
229
|
|
|
237
230
|
## 安装源与兼容性预检
|
|
238
231
|
|
|
@@ -464,8 +457,10 @@ The row in the plugins page shows a summary and a full page. There is **no Save
|
|
|
464
457
|
every change is persisted as you make it — coalesced into one request over 350 ms, sent
|
|
465
458
|
serially so two requests never write the same settings file at once — and re-schedules
|
|
466
459
|
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
|
|
460
|
+
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
|
|
461
|
+
no longer its own page under **Settings → Plugin updates**; the extra entry is the **Settings**
|
|
462
|
+
button inside the plugins-page Versions tab. The first time you open the app after upgrading, a
|
|
463
|
+
one-shot notice says where it went.
|
|
469
464
|
|
|
470
465
|
The layout follows the `dsh-cost-meter` settings page: stacked section cards, small section
|
|
471
466
|
headings, one-step-muted secondary text and two button tiers. "Last run" is no longer a run
|
|
@@ -529,15 +524,6 @@ The **Registries** panel lists the three presets, each with its own Test button
|
|
|
529
524
|
root URL are fired together and whichever answers first wins, inside a 5 s budget) and a switch; a
|
|
530
525
|
custom URL can be tested before it is used.
|
|
531
526
|
|
|
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
527
|
|
|
542
528
|
## Registry and compatibility pre-check
|
|
543
529
|
|
package/client.js
CHANGED
|
@@ -182,12 +182,9 @@ window.__ModuleLoader__.load({
|
|
|
182
182
|
versionsCopyFail: '复制失败',
|
|
183
183
|
versionsDiagnostics: '复制诊断',
|
|
184
184
|
versionsCustomSource: '自定义源',
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
showRow: '插件页里的这一行',
|
|
189
|
-
showBundle: '插件配置页',
|
|
190
|
-
showTab: '插件页「版本管理」标签',
|
|
185
|
+
movedTitle: '设置页搬到插件页了',
|
|
186
|
+
movedBadge: '已搬家',
|
|
187
|
+
movedBody: '「设置 → 插件更新」不再单独占一页:设置就在插件页那张卡里;也可以在插件页顶栏「版本管理」里点「设置」。',
|
|
191
188
|
maxPerCycle: '一轮最多装几个',
|
|
192
189
|
maxPerCycleHint: '0 表示不限。装包会一直占着 pnpm 锁,限一个数就把单次占用封顶,剩下的下一轮接着装',
|
|
193
190
|
sessionIdle: '会话静默(分钟)',
|
|
@@ -389,12 +386,9 @@ window.__ModuleLoader__.load({
|
|
|
389
386
|
versionsCopyFail: 'Could not copy',
|
|
390
387
|
versionsDiagnostics: 'Copy diagnostics',
|
|
391
388
|
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',
|
|
389
|
+
movedTitle: 'Settings moved into the plugins page',
|
|
390
|
+
movedBadge: 'Moved',
|
|
391
|
+
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
392
|
maxPerCycle: 'Installs per cycle',
|
|
399
393
|
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
394
|
sessionIdle: 'Session quiet window (minutes)',
|
|
@@ -769,41 +763,6 @@ window.__ModuleLoader__.load({
|
|
|
769
763
|
@media (prefers-reduced-motion:reduce){.dsh-au-toast{animation:none}}
|
|
770
764
|
`
|
|
771
765
|
|
|
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
766
|
/** 只注入一次:id 存在就跳过,重复挂载/热更新都不会叠出第二份样式表。 */
|
|
808
767
|
function installStyles() {
|
|
809
768
|
try {
|
|
@@ -1145,8 +1104,6 @@ window.__ModuleLoader__.load({
|
|
|
1145
1104
|
applyLang(next?.settings?.lang)
|
|
1146
1105
|
setState(next)
|
|
1147
1106
|
setDraft(next.settings)
|
|
1148
|
-
// 把显示选择镜像到 localStorage:apply() 下次重载时同步读它。
|
|
1149
|
-
writeDisplay(next.settings)
|
|
1150
1107
|
setPhase('ready')
|
|
1151
1108
|
} catch {
|
|
1152
1109
|
setPhase('error')
|
|
@@ -1229,11 +1186,6 @@ window.__ModuleLoader__.load({
|
|
|
1229
1186
|
useEffect(() => () => {
|
|
1230
1187
|
if (timerRef.current !== null) clearTimeout(timerRef.current)
|
|
1231
1188
|
}, [])
|
|
1232
|
-
// 显示开关一改就刷镜像:就地重载是在 1.2 秒后发生的,那时 apply() 读的
|
|
1233
|
-
// 就是这份镜像——不跟着改,切换会看起来「没生效」,要再加载一次才对。
|
|
1234
|
-
useEffect(() => {
|
|
1235
|
-
if (draft !== null) writeDisplay(draft)
|
|
1236
|
-
}, [draft])
|
|
1237
1189
|
|
|
1238
1190
|
|
|
1239
1191
|
/** 把后端进度翻成一行中文/英文;没进度就退回普通「正在检查」。 */
|
|
@@ -1463,16 +1415,6 @@ window.__ModuleLoader__.load({
|
|
|
1463
1415
|
h('span', null, T.registry + ': ' + (state?.registry === '' || !state?.registry ? T.regPnpm : state.registry)),
|
|
1464
1416
|
),
|
|
1465
1417
|
),
|
|
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
1418
|
h('div', { className: S.card },
|
|
1477
1419
|
h('h3', { className: S.h }, T.keepTitle),
|
|
1478
1420
|
h('p', { className: S.note }, T.keepHint),
|
|
@@ -1790,14 +1732,20 @@ window.__ModuleLoader__.load({
|
|
|
1790
1732
|
.join('|')
|
|
1791
1733
|
}
|
|
1792
1734
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1735
|
+
/* ── 右下角通知卡 ─────────────────────────────────────────────────────
|
|
1736
|
+
*
|
|
1737
|
+
* 一张卡两种用途:更新提醒,和「设置页搬家」这类一次性告知。结构照
|
|
1738
|
+
* dsh-cost-meter 的峰/谷提醒:圆点徽标 → 标题行(带 ×)→ 一句正文 →
|
|
1739
|
+
* 可选清单 → 主按钮。
|
|
1740
|
+
*
|
|
1741
|
+
* 同一时刻只挂一张:两张叠在右下角会互相挡住,而这两种通知都不紧急。
|
|
1742
|
+
*/
|
|
1743
|
+
function showNotice(options) {
|
|
1795
1744
|
const doc = typeof document === 'undefined' ? null : document
|
|
1796
|
-
if (doc === null || doc.body === null) return
|
|
1797
|
-
|
|
1798
|
-
if (rows.length === 0) return
|
|
1745
|
+
if (doc === null || doc.body === null) return false
|
|
1746
|
+
if (toastOpen) return false
|
|
1799
1747
|
toastOpen = true
|
|
1800
|
-
//
|
|
1748
|
+
// 提醒可能在任何页面弹出来,样式表没装就先补上(幂等)。
|
|
1801
1749
|
installStyles()
|
|
1802
1750
|
const box = doc.createElement('div')
|
|
1803
1751
|
box.setAttribute('data-dsh-aupdate', 'toast')
|
|
@@ -1805,58 +1753,59 @@ window.__ModuleLoader__.load({
|
|
|
1805
1753
|
box.setAttribute('role', 'status')
|
|
1806
1754
|
box.setAttribute('aria-live', 'polite')
|
|
1807
1755
|
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1756
|
+
if (options.badge) {
|
|
1757
|
+
const badge = doc.createElement('div')
|
|
1758
|
+
badge.className = 'dsh-au-toast-badge'
|
|
1759
|
+
badge.textContent = options.badge
|
|
1760
|
+
box.appendChild(badge)
|
|
1761
|
+
}
|
|
1814
1762
|
|
|
1815
1763
|
const head = doc.createElement('div')
|
|
1816
1764
|
head.className = 'dsh-au-toast-head'
|
|
1817
1765
|
const title = doc.createElement('div')
|
|
1818
1766
|
title.className = 'dsh-au-toast-title'
|
|
1819
|
-
|
|
1820
|
-
title.textContent = (applied > 0 ? T.toastTitle : T.toastTitleFound).replace('{n}', String(rows.length))
|
|
1767
|
+
title.textContent = options.title
|
|
1821
1768
|
const xBtn = doc.createElement('button')
|
|
1822
1769
|
xBtn.type = 'button'
|
|
1823
1770
|
xBtn.className = 'dsh-au-toast-x'
|
|
1824
1771
|
xBtn.textContent = '×'
|
|
1825
|
-
xBtn.setAttribute('aria-label',
|
|
1772
|
+
xBtn.setAttribute('aria-label', options.dismissLabel)
|
|
1826
1773
|
head.appendChild(title)
|
|
1827
1774
|
head.appendChild(xBtn)
|
|
1828
1775
|
box.appendChild(head)
|
|
1829
1776
|
|
|
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)
|
|
1777
|
+
if (options.body) {
|
|
1778
|
+
const body = doc.createElement('div')
|
|
1779
|
+
body.className = 'dsh-au-toast-body'
|
|
1780
|
+
body.textContent = options.body
|
|
1781
|
+
box.appendChild(body)
|
|
1853
1782
|
}
|
|
1854
|
-
box.appendChild(list)
|
|
1855
1783
|
|
|
1856
|
-
|
|
1784
|
+
const rows = Array.isArray(options.rows) ? options.rows : []
|
|
1785
|
+
if (rows.length > 0) {
|
|
1786
|
+
const list = doc.createElement('div')
|
|
1787
|
+
list.className = 'dsh-au-toast-list'
|
|
1788
|
+
for (const row of rows) {
|
|
1789
|
+
const line = doc.createElement('div')
|
|
1790
|
+
line.className = 'dsh-au-toast-item'
|
|
1791
|
+
const nameEl = doc.createElement('span')
|
|
1792
|
+
nameEl.className = 'dsh-au-toast-name'
|
|
1793
|
+
nameEl.textContent = row.name
|
|
1794
|
+
line.appendChild(nameEl)
|
|
1795
|
+
if (row.versions !== '') {
|
|
1796
|
+
const verEl = doc.createElement('span')
|
|
1797
|
+
verEl.className = 'dsh-au-toast-ver'
|
|
1798
|
+
verEl.textContent = row.versions
|
|
1799
|
+
line.appendChild(verEl)
|
|
1800
|
+
}
|
|
1801
|
+
list.appendChild(line)
|
|
1802
|
+
}
|
|
1803
|
+
box.appendChild(list)
|
|
1804
|
+
}
|
|
1805
|
+
if (options.more) {
|
|
1857
1806
|
const more = doc.createElement('div')
|
|
1858
1807
|
more.className = 'dsh-au-toast-more'
|
|
1859
|
-
more.textContent =
|
|
1808
|
+
more.textContent = options.more
|
|
1860
1809
|
box.appendChild(more)
|
|
1861
1810
|
}
|
|
1862
1811
|
|
|
@@ -1865,7 +1814,7 @@ window.__ModuleLoader__.load({
|
|
|
1865
1814
|
const close = doc.createElement('button')
|
|
1866
1815
|
close.type = 'button'
|
|
1867
1816
|
close.className = 'dsh-au-btn dsh-au-primary'
|
|
1868
|
-
close.textContent =
|
|
1817
|
+
close.textContent = options.dismissLabel
|
|
1869
1818
|
foot.appendChild(close)
|
|
1870
1819
|
box.appendChild(foot)
|
|
1871
1820
|
|
|
@@ -1888,8 +1837,49 @@ window.__ModuleLoader__.load({
|
|
|
1888
1837
|
xBtn.addEventListener('click', dismiss)
|
|
1889
1838
|
try { doc.addEventListener('keydown', onKey, true) } catch {}
|
|
1890
1839
|
doc.body.appendChild(box)
|
|
1891
|
-
//
|
|
1892
|
-
setTimeout(dismiss, 15000)
|
|
1840
|
+
// 不点也不会一直挂着:默认 15 秒,搬家的提示留长一点。
|
|
1841
|
+
setTimeout(dismiss, options.ms ?? 15000)
|
|
1842
|
+
return true
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
/** 更新提醒:把这一轮发现的版本做成一张通知卡。 */
|
|
1846
|
+
function showUpdateToast(updates, applied) {
|
|
1847
|
+
const rows = (Array.isArray(updates) ? updates : []).map((item) => describeUpdate(item)).filter((row) => row !== null)
|
|
1848
|
+
if (rows.length === 0) return false
|
|
1849
|
+
return showNotice({
|
|
1850
|
+
badge: applied > 0 ? T.toastBadge : T.toastBadgeFound,
|
|
1851
|
+
// 真的装完了才说「已更新」;只查到、没动手时说「可更新」。
|
|
1852
|
+
title: (applied > 0 ? T.toastTitle : T.toastTitleFound).replace('{n}', String(rows.length)),
|
|
1853
|
+
body: applied > 0 ? T.toastBody : T.toastBodyFound,
|
|
1854
|
+
rows: rows.slice(0, 12),
|
|
1855
|
+
more: rows.length > 12 ? T.toastMore.replace('{n}', String(rows.length - 12)) : '',
|
|
1856
|
+
dismissLabel: T.toastDismiss,
|
|
1857
|
+
ms: 15000,
|
|
1858
|
+
})
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/* 0.8.3 起「设置 → 插件更新」不再单独占一页:入口搬到插件页那张卡、插件配置页
|
|
1862
|
+
* 和版本管理页的「设置」。这里提示一次就够,记在 localStorage 里,不然每开一次
|
|
1863
|
+
* 页面都会弹。 */
|
|
1864
|
+
const MOVED_KEY = 'dsh-aupdate:settings-moved'
|
|
1865
|
+
|
|
1866
|
+
function movedNoticePending() {
|
|
1867
|
+
try { return window.localStorage.getItem(MOVED_KEY) !== '1' } catch { return false }
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
function markMovedNotice() {
|
|
1871
|
+
try { window.localStorage.setItem(MOVED_KEY, '1') } catch {}
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
function showMovedNotice() {
|
|
1875
|
+
return showNotice({
|
|
1876
|
+
badge: T.movedBadge,
|
|
1877
|
+
title: T.movedTitle,
|
|
1878
|
+
body: T.movedBody,
|
|
1879
|
+
rows: [],
|
|
1880
|
+
dismissLabel: T.toastDismiss,
|
|
1881
|
+
ms: 22000,
|
|
1882
|
+
})
|
|
1893
1883
|
}
|
|
1894
1884
|
|
|
1895
1885
|
function startUpdateNotifier() {
|
|
@@ -1900,13 +1890,20 @@ window.__ModuleLoader__.load({
|
|
|
1900
1890
|
try {
|
|
1901
1891
|
const state = await getState(LANG)
|
|
1902
1892
|
if (state?.settings?.notify !== false) {
|
|
1903
|
-
|
|
1904
|
-
if (
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1893
|
+
// 搬家提示排在前面:它只说一次,而更新提醒下一轮还会再来。
|
|
1894
|
+
if (movedNoticePending() && !toastOpen) {
|
|
1895
|
+
markMovedNotice()
|
|
1896
|
+
showMovedNotice()
|
|
1897
|
+
} else {
|
|
1898
|
+
const updates = Array.isArray(state?.lastRun?.updates) ? state.lastRun.updates : []
|
|
1899
|
+
if (updates.length > 0) {
|
|
1900
|
+
// 签名算的是「包名+版本变化」,旧格式也能算出来,不会重复弹。
|
|
1901
|
+
const sig = updateSignature(updates)
|
|
1902
|
+
// 已经挂着一张卡时不标记:留到下一轮再弹,别把提醒吞掉。
|
|
1903
|
+
if (sig !== notifiedMark() && !toastOpen) {
|
|
1904
|
+
markNotified(sig)
|
|
1905
|
+
showUpdateToast(updates, appliedCount(state?.lastRun))
|
|
1906
|
+
}
|
|
1910
1907
|
}
|
|
1911
1908
|
}
|
|
1912
1909
|
}
|
|
@@ -1958,7 +1955,6 @@ window.__ModuleLoader__.load({
|
|
|
1958
1955
|
try {
|
|
1959
1956
|
const next = await getState(LANG)
|
|
1960
1957
|
setState(next)
|
|
1961
|
-
writeDisplay(next?.settings)
|
|
1962
1958
|
} catch {}
|
|
1963
1959
|
}, [])
|
|
1964
1960
|
|
|
@@ -2300,48 +2296,38 @@ window.__ModuleLoader__.load({
|
|
|
2300
2296
|
installStyles()
|
|
2301
2297
|
// 提醒跟着插件一起上、一起卸:ctx.effect 收的是清理函数。
|
|
2302
2298
|
if (typeof ctx.effect === 'function') ctx.effect(startUpdateNotifier, 'dsh-aupdate: update notices')
|
|
2303
|
-
// 「显示位置」:关掉的那一处干脆不注册槽位,而不是挂上去再渲染成空——
|
|
2304
|
-
// 后者会在标签栏/设置导航里留下一个点进去什么都没有的空条目。
|
|
2305
|
-
const display = readDisplay()
|
|
2306
|
-
|
|
2307
2299
|
// key 的格式是「包名#条目id」:本插件在 cordis.patch.yml 里的条目 id 就是包名本身,
|
|
2308
2300
|
// 和 dsh-ops 的 dsh-ops#dsh-ops 一样。写成 #auto-update 之类是挂不上的。
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2314
|
-
}
|
|
2301
|
+
ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
|
|
2302
|
+
name: 'plugins.row.config',
|
|
2303
|
+
key: NS + '#' + NS,
|
|
2304
|
+
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2315
2305
|
|
|
2316
2306
|
// bundle 级配置页用包名做 key,和 free-search 的写法一致。
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2322
|
-
}
|
|
2307
|
+
ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
|
|
2308
|
+
name: 'plugins.bundle.config',
|
|
2309
|
+
key: NS,
|
|
2310
|
+
}, (props) => (props && props.view === 'summary' ? h(AutoUpdateSummary) : h(AutoUpdateCard))))
|
|
2323
2311
|
|
|
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
|
-
// 插件页标签栏多一个「版本管理」:和设置页分工——设置页管「什么时候自动升」,
|
|
2312
|
+
// 插件页标签栏多一个「版本管理」:和插件页那张卡分工——那张管「什么时候自动升」,
|
|
2336
2313
|
// 这一页管「现在就要某一版」。order 2 排在「已安装/发现」(0) 和市场(1) 之后。
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2314
|
+
ctx.slots.inject('plugins.tab', () => ctx.slots.register({
|
|
2315
|
+
name: 'plugins.tab',
|
|
2316
|
+
id: NS,
|
|
2317
|
+
order: 2,
|
|
2318
|
+
label: () => T.versionsTab,
|
|
2319
|
+
}, () => h(VersionsTab)))
|
|
2320
|
+
|
|
2321
|
+
// 注意:这里**故意不再注册** 'settings.section'。
|
|
2322
|
+
// 「设置 → 插件更新」原本是独立的一页,现在设置已经在插件页那张卡、
|
|
2323
|
+
// 插件配置页和版本管理页的「设置」里了,多一个入口只是多一处要维护的地方。
|
|
2324
|
+
// 想把它挂回来,取消下面这段注释即可(order 36 是原来的位置)。
|
|
2325
|
+
// ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
2326
|
+
// name: 'settings.section',
|
|
2327
|
+
// id: NS,
|
|
2328
|
+
// order: 36,
|
|
2329
|
+
// label: () => T.pageLabel,
|
|
2330
|
+
// }, () => h(AutoUpdateCard)))
|
|
2345
2331
|
},
|
|
2346
2332
|
}
|
|
2347
2333
|
},
|
package/index.js
CHANGED
|
@@ -541,8 +541,6 @@ const OVERRIDEABLE = [
|
|
|
541
541
|
'allowMajor', 'allowPrerelease',
|
|
542
542
|
// 安装源与兼容性预检(0.8.0 借自 dsh-plugin-upgrader)。
|
|
543
543
|
'registryMode', 'registryUrl', 'compatCheck',
|
|
544
|
-
// 显示位置(设置页 / 插件行 / 插件配置页 / 版本管理标签)。
|
|
545
|
-
'showSettingsSection', 'showPluginsRow', 'showPluginsBundle', 'showVersionsTab',
|
|
546
544
|
// 调度:四种节奏 + 失败抑制时长。这些键不写进 Config schema,
|
|
547
545
|
// 只活在覆盖层里——Config 的字段类型是宿主校验的,加错一个类型
|
|
548
546
|
// 会在加载期直接抛错,而覆盖层是我们自己的文件,改坏了只影响这一项。
|
|
@@ -742,12 +740,6 @@ function settingsOf(config) {
|
|
|
742
740
|
// 兼容性预检:装之前先看目标版本声明的 DSH 范围。默认开——宿主闸门是在
|
|
743
741
|
// bundle 已经卸下之后才拒绝的,等它拒绝就已经晚了。
|
|
744
742
|
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
743
|
intervalMinutes: numberSetting(config, 'intervalMinutes', 1440, 10, 10080),
|
|
752
744
|
firstDelayMinutes: numberSetting(config, 'firstDelayMinutes', 5, 0, 1440),
|
|
753
745
|
exclude: stringList(config?.exclude),
|
|
@@ -2766,20 +2758,12 @@ function registerRoutes(scope, ctxRef) {
|
|
|
2766
2758
|
sendJson(res, 400, { error: 'bad json' })
|
|
2767
2759
|
return
|
|
2768
2760
|
}
|
|
2769
|
-
const before = settingsOf(ctxRef.config)
|
|
2770
2761
|
const result = writeOverrides(body)
|
|
2771
2762
|
if (!result.ok) {
|
|
2772
2763
|
sendJson(res, 500, { error: result.error })
|
|
2773
2764
|
return
|
|
2774
2765
|
}
|
|
2775
2766
|
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
2767
|
// 改完立刻按新设置重排,否则要等下一次触发才换节奏。
|
|
2784
2768
|
try {
|
|
2785
2769
|
if (typeof ctxRef.reschedule === 'function') ctxRef.reschedule()
|
package/package.json
CHANGED