dsh-go-plugin-sync 0.3.6 → 0.4.1
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/CHANGELOG.md +33 -0
- package/lib/client.js +41 -5
- package/lib/index.js +131 -48
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.1 — 2026-12-04
|
|
4
|
+
|
|
5
|
+
### 改进
|
|
6
|
+
- 导入同步码 / 清单文件 / 拉取中转或 SSH 后,只自动选中“双端兼容(kind=both)且本机还没装”的插件,其余保持不选
|
|
7
|
+
- 每个插件的兼容与状态提示缩短,例如「1.2.3 · 可安装」「1.2.3 · npm 安装」
|
|
8
|
+
- 冲突项以本机为准:不再提示更新,更新交给 DSH 本体处理;电脑端与 dsh-go 面板文案同步
|
|
9
|
+
|
|
10
|
+
## 0.4.0 — 2026-12-04
|
|
11
|
+
|
|
12
|
+
0.3.10 之后的功能合并发布(npm 从 0.3.6 直接到本版)。
|
|
13
|
+
|
|
14
|
+
### 新增
|
|
15
|
+
- 电脑端设置页:补回「复制同步码」按钮,把本机插件导出为 `DSHSYNC1` 同步码并写入剪贴板,剪贴板不可用时填入下方文本框
|
|
16
|
+
- 安装成功后提示“新插件需重启 DSH 后才会加载”;底部新增「日志尾部」折叠
|
|
17
|
+
|
|
18
|
+
### dsh-go 面板
|
|
19
|
+
- 任务运行中显示进度:当前项、已处理 x / 总数、失败数、已用时间
|
|
20
|
+
- 默认只列待处理插件,已安装项折叠为“已安装 N 个”,可切「显示全部 / 只看待处理」
|
|
21
|
+
- 新增「清空清单」,清掉导入的清单后可重新导入同步码或拉取中转
|
|
22
|
+
|
|
23
|
+
## 0.3.12 — 2026-12-04
|
|
24
|
+
|
|
25
|
+
### 新增 / 改进
|
|
26
|
+
- dsh-go 面板:任务运行中显示进度(当前项、已处理 x / 总数、失败数、已用时间),点「刷新」即可看最新状态
|
|
27
|
+
- dsh-go 面板:默认只列待处理插件,已安装项折叠为“已安装 N 个”,可切「显示全部 / 只看待处理」
|
|
28
|
+
- dsh-go 面板:新增「清空清单」,清掉导入的清单,可重新导入同步码或拉取中转
|
|
29
|
+
- 电脑端:安装成功后提示“新插件需重启 DSH 后才会加载”;底部新增「日志尾部」折叠,便于排查
|
|
30
|
+
|
|
31
|
+
## 0.3.11 — 2026-12-04
|
|
32
|
+
|
|
33
|
+
### 修复
|
|
34
|
+
- 设置页补回“复制同步码”按钮:把本机插件导出为 `DSHSYNC1` 同步码,优先复制到剪贴板;剪贴板不可用时自动填入下方文本框并全选,按 Ctrl+C 即可复制
|
|
35
|
+
|
|
3
36
|
## 0.3.10 — 2026-12-04
|
|
4
37
|
|
|
5
38
|
### 改进
|
package/lib/client.js
CHANGED
|
@@ -59,6 +59,7 @@ window.__ModuleLoader__.load({
|
|
|
59
59
|
function SyncSettings() {
|
|
60
60
|
const [rows, setRows] = React.useState([])
|
|
61
61
|
const [results, setResults] = React.useState([])
|
|
62
|
+
const [log, setLog] = React.useState([])
|
|
62
63
|
const [picked, setPicked] = React.useState({})
|
|
63
64
|
const [code, setCode] = React.useState('')
|
|
64
65
|
const [config, setConfig] = React.useState(null)
|
|
@@ -71,6 +72,7 @@ window.__ModuleLoader__.load({
|
|
|
71
72
|
const [cleared, setCleared] = React.useState(false)
|
|
72
73
|
const [queue, setQueue] = React.useState(null)
|
|
73
74
|
const wasRunning = React.useRef(false)
|
|
75
|
+
const codeRef = React.useRef(null)
|
|
74
76
|
|
|
75
77
|
const note = (text, kind) => { setStatus(text); setTone(kind || '') }
|
|
76
78
|
|
|
@@ -79,6 +81,7 @@ window.__ModuleLoader__.load({
|
|
|
79
81
|
setRows(snapshot.rows || [])
|
|
80
82
|
setCleared(Boolean(snapshot.cleared))
|
|
81
83
|
setResults(snapshot.results || [])
|
|
84
|
+
setLog(snapshot.log || [])
|
|
82
85
|
setConfig(snapshot.config || null)
|
|
83
86
|
setConfigPath(snapshot.configPath || '')
|
|
84
87
|
const next = {}
|
|
@@ -90,6 +93,7 @@ window.__ModuleLoader__.load({
|
|
|
90
93
|
React.useEffect(() => {
|
|
91
94
|
const tick = () => api('status').then((snapshot) => {
|
|
92
95
|
if (snapshot.results) setResults(snapshot.results)
|
|
96
|
+
if (snapshot.log) setLog(snapshot.log)
|
|
93
97
|
setTask(snapshot.task || null)
|
|
94
98
|
setCurrent(snapshot.current || null)
|
|
95
99
|
if (!snapshot.task) return
|
|
@@ -107,11 +111,11 @@ window.__ModuleLoader__.load({
|
|
|
107
111
|
}, [])
|
|
108
112
|
|
|
109
113
|
const kindLabel = (kind) => kind === 'native'
|
|
110
|
-
? T('
|
|
114
|
+
? T('手机端', 'Phone')
|
|
111
115
|
: kind === 'both'
|
|
112
|
-
? T('
|
|
116
|
+
? T('双端', 'Both')
|
|
113
117
|
: kind === 'bundle'
|
|
114
|
-
? T('
|
|
118
|
+
? T('电脑端', 'Desktop')
|
|
115
119
|
: ''
|
|
116
120
|
const toggle = (name, checked) => setPicked((previous) => ({ ...previous, [name]: checked }))
|
|
117
121
|
const installedRows = rows.filter((row) => row.status === 'same')
|
|
@@ -145,6 +149,28 @@ window.__ModuleLoader__.load({
|
|
|
145
149
|
load()
|
|
146
150
|
}).catch((error) => { setBusy(false); note(String(error && error.message || error), 'bad') })
|
|
147
151
|
}
|
|
152
|
+
const copyCode = () => {
|
|
153
|
+
setBusy(true)
|
|
154
|
+
api('export', {}).then((result) => {
|
|
155
|
+
setBusy(false)
|
|
156
|
+
if (result.error) { note(result.error, 'bad'); return }
|
|
157
|
+
setCode(result.code)
|
|
158
|
+
const summary = T(
|
|
159
|
+
`同步码已生成(${result.count} 个插件${result.withFiles ? ',含文件' : ''})`,
|
|
160
|
+
`Sync code generated (${result.count} plugins${result.withFiles ? ', with files' : ''})`
|
|
161
|
+
)
|
|
162
|
+
const fallback = () => {
|
|
163
|
+
try { codeRef.current?.focus(); codeRef.current?.select() } catch {}
|
|
164
|
+
note(summary + T(',已填入下方文本框,按 Ctrl+C 复制', ' — filled below, press Ctrl+C to copy'), 'good')
|
|
165
|
+
}
|
|
166
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
167
|
+
navigator.clipboard.writeText(result.code).then(
|
|
168
|
+
() => note(summary + T(',已复制到剪贴板', ' — copied to clipboard'), 'good'),
|
|
169
|
+
fallback,
|
|
170
|
+
)
|
|
171
|
+
} else fallback()
|
|
172
|
+
}).catch((error) => { setBusy(false); note(String(error && error.message || error), 'bad') })
|
|
173
|
+
}
|
|
148
174
|
const applySelected = () => {
|
|
149
175
|
const names = rows.filter((row) => row.action && picked[row.name]).map((row) => row.name)
|
|
150
176
|
if (names.length === 0) { note(T('先选择要安装的插件', 'Select plugins to install'), 'bad'); return }
|
|
@@ -235,18 +261,20 @@ window.__ModuleLoader__.load({
|
|
|
235
261
|
|
|
236
262
|
return h('div', { style: { display: 'flex', flexDirection: 'column', gap: '14px', maxWidth: '760px' } },
|
|
237
263
|
h('div', { style: { fontSize: '13px', opacity: 0.7 } },
|
|
238
|
-
T('
|
|
264
|
+
T('从同步码安装缺少的插件;已有版本不动,冲突以本机为准,更新交给 DSH 本体。', 'Install missing plugins from a sync code; conflicts keep the local copy and updates are left to DSH.')),
|
|
239
265
|
|
|
240
266
|
h('div', { style: { display: 'flex', flexDirection: 'column', gap: '8px' } },
|
|
241
267
|
h('div', { style: { fontWeight: 600 } }, T('同步码', 'Sync code')),
|
|
242
268
|
h('textarea', {
|
|
269
|
+
ref: codeRef,
|
|
243
270
|
value: code,
|
|
244
271
|
rows: 4,
|
|
245
272
|
placeholder: 'DSHSYNC1:…',
|
|
246
273
|
onChange: (event) => setCode(event.target.value),
|
|
247
274
|
style: { ...INPUT, fontFamily: 'ui-monospace, monospace', minHeight: '80px', resize: 'vertical' },
|
|
248
275
|
}),
|
|
249
|
-
h('div', { style: { display: 'flex', gap: '8px' } },
|
|
276
|
+
h('div', { style: { display: 'flex', gap: '8px', flexWrap: 'wrap' } },
|
|
277
|
+
h('button', { type: 'button', style: BUTTON, disabled: busy, onClick: copyCode }, T('复制同步码', 'Copy sync code')),
|
|
250
278
|
h('button', { type: 'button', style: PRIMARY, disabled: busy, onClick: importCode }, T('导入同步码', 'Import code')),
|
|
251
279
|
h('button', { type: 'button', style: BUTTON, disabled: busy, onClick: load }, T('刷新', 'Refresh')))),
|
|
252
280
|
|
|
@@ -278,6 +306,14 @@ window.__ModuleLoader__.load({
|
|
|
278
306
|
style: { fontSize: '12px', color: item.ok ? '#2e7d32' : '#c62828', wordBreak: 'break-word' },
|
|
279
307
|
}, `${item.ok ? '✓' : '✗'} ${item.name}${item.message ? ` — ${item.message}` : ''}`))),
|
|
280
308
|
|
|
309
|
+
task && !task.running && task.ok && results.some((item) => item.ok && item.action === 'install') &&
|
|
310
|
+
h('div', { style: { fontSize: '13px', color: '#1565c0' } },
|
|
311
|
+
T('新插件需重启 DSH 后才会加载(完全退出再启动)', 'New plugins load after a full DSH restart.')),
|
|
312
|
+
|
|
313
|
+
log.length > 0 && h('details', { style: { fontSize: '13px' } },
|
|
314
|
+
h('summary', { style: { cursor: 'pointer', opacity: 0.7 } }, T('日志尾部', 'Log tail')),
|
|
315
|
+
h('pre', { style: { fontSize: '11px', opacity: 0.75, whiteSpace: 'pre-wrap', wordBreak: 'break-all', margin: '6px 0 0' } }, log.join('\n'))),
|
|
316
|
+
|
|
281
317
|
h('div', { style: { borderTop: '1px solid rgba(128,128,128,.2)', paddingTop: '12px' } },
|
|
282
318
|
h('div', { style: { fontWeight: 600, marginBottom: '4px' } }, T('Git 中转(可选)', 'Git relay (optional)')),
|
|
283
319
|
h(Field, { label: T('仓库地址', 'Repository'), value: relay.repo, onChange: (value) => setPath('relay.repo', value), placeholder: 'https://gitee.com/you/dsh-plugins.git' }),
|
package/lib/index.js
CHANGED
|
@@ -73,6 +73,7 @@ const taskRunnerPath = () => join(storeDir(), 'task-runner.cjs')
|
|
|
73
73
|
const taskSpecPath = () => join(storeDir(), 'task-spec.json')
|
|
74
74
|
const taskLogPath = () => join(storeDir(), 'task.log')
|
|
75
75
|
const taskStatusPath = () => join(storeDir(), 'task-status.txt')
|
|
76
|
+
const taskTotalPath = () => join(storeDir(), 'task-total.txt')
|
|
76
77
|
|
|
77
78
|
function readJson(path) {
|
|
78
79
|
try { return JSON.parse(readFileSync(path, 'utf8')) } catch { return undefined }
|
|
@@ -266,7 +267,7 @@ function codeFromSubmit(value) {
|
|
|
266
267
|
return ''
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
/** Decode a sync code, materialize files, and preselect
|
|
270
|
+
/** Decode a sync code, materialize files, and preselect double-end plugins missing here. */
|
|
270
271
|
function applySyncCode(scope, text, sourceName, host = {}) {
|
|
271
272
|
const decoded = decodeSyncCode(text)
|
|
272
273
|
if (decoded.error) return { error: decoded.error }
|
|
@@ -275,20 +276,12 @@ function applySyncCode(scope, text, sourceName, host = {}) {
|
|
|
275
276
|
state.manifestSource = { kind: 'code' }
|
|
276
277
|
state.importedAt = new Date().toISOString()
|
|
277
278
|
state.sourceName = sourceName
|
|
279
|
+
state.showAll = false
|
|
278
280
|
persistImported(state)
|
|
279
281
|
resetUiState()
|
|
280
282
|
writeCodeFiles(decoded)
|
|
281
283
|
const rows = diffRows(localPlugins(), state.manifest, state.manifestSource, host)
|
|
282
|
-
const
|
|
283
|
-
state.selected.clear()
|
|
284
|
-
let selected = 0
|
|
285
|
-
for (const row of rows) {
|
|
286
|
-
if (!manifestNames.has(row.name)) continue
|
|
287
|
-
if (!row.action) continue
|
|
288
|
-
if (host.dshGo === true && row.kind === 'bundle') continue
|
|
289
|
-
state.selected.add(row.name)
|
|
290
|
-
selected++
|
|
291
|
-
}
|
|
284
|
+
const selected = preselectRows(state, host)
|
|
292
285
|
return {
|
|
293
286
|
count: decoded.manifest.plugins.length,
|
|
294
287
|
selected,
|
|
@@ -618,6 +611,21 @@ function diffRows(local, manifest, source, host = {}) {
|
|
|
618
611
|
return rows
|
|
619
612
|
}
|
|
620
613
|
|
|
614
|
+
/** Auto-select only double-end plugins (kind=both) that this host does not have yet. */
|
|
615
|
+
function preselectRows(state, host = {}) {
|
|
616
|
+
const rows = diffRows(localPlugins(), state.manifest, state.manifestSource, host)
|
|
617
|
+
const names = new Set((state.manifest?.plugins ?? []).map((plugin) => plugin.name))
|
|
618
|
+
state.selected.clear()
|
|
619
|
+
for (const row of rows) {
|
|
620
|
+
if (!names.has(row.name)) continue
|
|
621
|
+
if (row.kind !== 'both') continue
|
|
622
|
+
if (row.status !== 'installable') continue
|
|
623
|
+
if (!row.action) continue
|
|
624
|
+
state.selected.add(row.name)
|
|
625
|
+
}
|
|
626
|
+
return state.selected.size
|
|
627
|
+
}
|
|
628
|
+
|
|
621
629
|
// ---------------------------------------------------------------- state
|
|
622
630
|
|
|
623
631
|
function stateKey(scope) {
|
|
@@ -634,6 +642,7 @@ function loadImported() {
|
|
|
634
642
|
importedAt: typeof raw?.importedAt === 'string' ? raw.importedAt : null,
|
|
635
643
|
sourceName: typeof raw?.sourceName === 'string' ? raw.sourceName.slice(0, 120) : null,
|
|
636
644
|
selected: new Set(),
|
|
645
|
+
showAll: false,
|
|
637
646
|
lastExportPath: null,
|
|
638
647
|
lastPastedCode: null,
|
|
639
648
|
relayLoadedAt: 0,
|
|
@@ -672,15 +681,16 @@ function loadManifestFrom(path, kind, pluginsDir) {
|
|
|
672
681
|
}
|
|
673
682
|
|
|
674
683
|
/** Refresh the state manifest from relay / ssh results when those files are newer. */
|
|
675
|
-
function refreshManifests(state, cfg) {
|
|
684
|
+
function refreshManifests(state, cfg, host = {}) {
|
|
676
685
|
const relay = loadManifestFrom(relayManifestFile(), 'relay', join(relayWorkDir(), cfg.relay.dir, 'plugins'))
|
|
677
686
|
if (relay?.manifest && relay.manifest.plugins.length > 0 && relay.mtime > state.relayLoadedAt) {
|
|
678
687
|
state.manifest = relay.manifest
|
|
679
688
|
state.manifestSource = relay.source
|
|
680
689
|
state.importedAt = relay.manifest.exportedAt
|
|
681
690
|
state.sourceName = 'Git 中转'
|
|
691
|
+
state.showAll = false
|
|
682
692
|
state.relayLoadedAt = relay.mtime
|
|
683
|
-
state
|
|
693
|
+
preselectRows(state, host)
|
|
684
694
|
}
|
|
685
695
|
const ssh = loadManifestFrom(sshManifestFile(), 'ssh', null)
|
|
686
696
|
if (ssh?.manifest && ssh.manifest.plugins.length > 0 && ssh.mtime > state.sshLoadedAt) {
|
|
@@ -688,8 +698,9 @@ function refreshManifests(state, cfg) {
|
|
|
688
698
|
state.manifestSource = ssh.source
|
|
689
699
|
state.importedAt = ssh.manifest.exportedAt
|
|
690
700
|
state.sourceName = 'SSH 远端'
|
|
701
|
+
state.showAll = false
|
|
691
702
|
state.sshLoadedAt = ssh.mtime
|
|
692
|
-
state
|
|
703
|
+
preselectRows(state, host)
|
|
693
704
|
}
|
|
694
705
|
}
|
|
695
706
|
|
|
@@ -764,6 +775,24 @@ function readTaskResults() {
|
|
|
764
775
|
|
|
765
776
|
// ---------------------------------------------------------------- task runner
|
|
766
777
|
|
|
778
|
+
/** How many items the current/last task planned to process (0 when unknown). */
|
|
779
|
+
function readTaskTotal() {
|
|
780
|
+
try {
|
|
781
|
+
const count = Number(readFileSync(taskTotalPath(), 'utf8').trim())
|
|
782
|
+
return Number.isFinite(count) && count > 0 ? count : 0
|
|
783
|
+
} catch {
|
|
784
|
+
return 0
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/** "12 秒" / "2 分 05 秒" — coarse on purpose; progress refreshes on demand. */
|
|
789
|
+
function elapsedText(seconds, en) {
|
|
790
|
+
if (seconds < 60) return en ? `${seconds}s` : `${seconds} 秒`
|
|
791
|
+
const minutes = Math.floor(seconds / 60)
|
|
792
|
+
const rest = seconds % 60
|
|
793
|
+
return en ? `${minutes}m${rest}s` : `${minutes} 分 ${rest} 秒`
|
|
794
|
+
}
|
|
795
|
+
|
|
767
796
|
function taskRunning() {
|
|
768
797
|
const status = readTaskStatus()
|
|
769
798
|
return Boolean(status?.running && Date.now() - status.startedAt < 15 * 60 * 1000)
|
|
@@ -773,6 +802,7 @@ function taskRunning() {
|
|
|
773
802
|
function startTask(kind, lines, win) {
|
|
774
803
|
if (taskRunning()) return { ok: false, error: '已有任务在运行,等它结束再试' }
|
|
775
804
|
ensureStore()
|
|
805
|
+
try { writeFileSync(taskTotalPath(), '0\n') } catch {}
|
|
776
806
|
if (process.platform === 'win32') return startWindowsTask(kind, win)
|
|
777
807
|
const script = [
|
|
778
808
|
'#!/bin/sh',
|
|
@@ -944,6 +974,7 @@ function startInstallTask(ctx, jobs) {
|
|
|
944
974
|
if (!manager || typeof manager.installBundle !== 'function') return null
|
|
945
975
|
if (taskRunning()) return { ok: false, error: '已有任务在运行,等它结束再试' }
|
|
946
976
|
ensureStore()
|
|
977
|
+
try { writeFileSync(taskTotalPath(), '0\n') } catch {}
|
|
947
978
|
writeFileSync(taskLogPath(), '')
|
|
948
979
|
writeFileSync(taskStatusPath(), `running ${Math.floor(Date.now() / 1000)} apply\n`)
|
|
949
980
|
const installs = jobs.filter((job) => job.action === 'install')
|
|
@@ -999,11 +1030,17 @@ function startInstallTask(ctx, jobs) {
|
|
|
999
1030
|
|
|
1000
1031
|
/** Prefer the plugin manager for pure installs; keep the shell path for SSH push/pull. */
|
|
1001
1032
|
function startApplyTask(ctx, cfg, jobs) {
|
|
1033
|
+
const writeTotal = () => { try { writeFileSync(taskTotalPath(), `${jobs.length}\n`) } catch {} }
|
|
1002
1034
|
if (jobs.every((job) => job.action === 'install')) {
|
|
1003
1035
|
const started = startInstallTask(ctx, jobs)
|
|
1004
|
-
if (started)
|
|
1036
|
+
if (started) {
|
|
1037
|
+
if (started.ok) writeTotal()
|
|
1038
|
+
return started
|
|
1039
|
+
}
|
|
1005
1040
|
}
|
|
1006
|
-
|
|
1041
|
+
const started = startTask('apply', buildApply(cfg, jobs), winTask(jobs))
|
|
1042
|
+
if (started.ok) writeTotal()
|
|
1043
|
+
return started
|
|
1007
1044
|
}
|
|
1008
1045
|
|
|
1009
1046
|
/** One result-reporting item: start marker, commands, ok/fail marker. */
|
|
@@ -1299,20 +1336,20 @@ function enableText(caps) {
|
|
|
1299
1336
|
function statusLine(row, en) {
|
|
1300
1337
|
let text = {
|
|
1301
1338
|
same: en ? 'same' : '一致',
|
|
1302
|
-
conflict: en ? '
|
|
1303
|
-
install: en ? 'not installed
|
|
1304
|
-
installable: en ? '
|
|
1305
|
-
missing: en ? 'files
|
|
1306
|
-
extra: en ? 'not
|
|
1307
|
-
push: en ? '
|
|
1308
|
-
'native-only': en ? 'phone-only
|
|
1309
|
-
'web-only': en ? '
|
|
1339
|
+
conflict: en ? 'local wins' : '本机优先',
|
|
1340
|
+
install: en ? 'not installed' : '未安装',
|
|
1341
|
+
installable: en ? 'ready' : '可安装',
|
|
1342
|
+
missing: en ? 'no files' : '缺文件',
|
|
1343
|
+
extra: en ? 'not listed' : '清单外',
|
|
1344
|
+
push: en ? 'pushable' : '可推送',
|
|
1345
|
+
'native-only': en ? 'phone-only' : '手机专用',
|
|
1346
|
+
'web-only': en ? 'web-only' : '电脑/网页专用',
|
|
1310
1347
|
}[row.status] || row.status
|
|
1311
1348
|
if (row.status !== 'web-only' && row.status !== 'native-only') {
|
|
1312
|
-
if (row.action === 'install' && row.registrySpec) text = en ? '
|
|
1313
|
-
else if (row.action === 'install' && row.localDir) text = en ? '
|
|
1314
|
-
else if (row.action === 'pull') text = en ? '
|
|
1315
|
-
else if (row.action === 'push-npm') text = en ? 'remote
|
|
1349
|
+
if (row.action === 'install' && row.registrySpec) text = en ? 'via npm' : 'npm 安装'
|
|
1350
|
+
else if (row.action === 'install' && row.localDir) text = en ? 'via files' : '文件安装'
|
|
1351
|
+
else if (row.action === 'pull') text = en ? 'from remote' : '远端拉取'
|
|
1352
|
+
else if (row.action === 'push-npm') text = en ? 'remote via npm' : '远端 npm'
|
|
1316
1353
|
}
|
|
1317
1354
|
const version = row.status === 'conflict' && row.remoteVersion && row.remoteVersion !== row.version
|
|
1318
1355
|
? `${row.version} → ${row.remoteVersion}`
|
|
@@ -1343,7 +1380,7 @@ function buildView(scope, caps, ctx) {
|
|
|
1343
1380
|
const en = enableText(caps)
|
|
1344
1381
|
const cfg = loadConfig(ctx, scope)
|
|
1345
1382
|
const state = stateFor(scope)
|
|
1346
|
-
refreshManifests(state, cfg)
|
|
1383
|
+
refreshManifests(state, cfg, { dshGo: true })
|
|
1347
1384
|
const local = localPluginsCached()
|
|
1348
1385
|
const rows = diffRows(local, state.manifest, state.manifestSource, { dshGo: true })
|
|
1349
1386
|
const components = Array.isArray(caps?.components) ? caps.components : []
|
|
@@ -1351,8 +1388,8 @@ function buildView(scope, caps, ctx) {
|
|
|
1351
1388
|
const children = []
|
|
1352
1389
|
|
|
1353
1390
|
children.push({ type: 'text', text: en
|
|
1354
|
-
? 'Copy a sync code (all or selected), or paste one below. Sync only installs missing plugins;
|
|
1355
|
-
: '
|
|
1391
|
+
? 'Copy a sync code (all or selected), or paste one below. Sync only installs missing plugins; conflicts keep the local copy, updates are left to DSH.'
|
|
1392
|
+
: '复制同步码(全部或选中),或在下面粘贴导入。同步只安装缺少的插件,已有版本不动;冲突以本机为准,更新交给 DSH 本体。' })
|
|
1356
1393
|
|
|
1357
1394
|
if (canForm) {
|
|
1358
1395
|
children.push({ type: 'form', submit: 'import-code', submitLabel: en ? 'Import code' : '导入同步码', children: [
|
|
@@ -1386,9 +1423,20 @@ function buildView(scope, caps, ctx) {
|
|
|
1386
1423
|
const task = readTaskStatus()
|
|
1387
1424
|
if (task?.running) {
|
|
1388
1425
|
const stale = Date.now() - task.startedAt > 15 * 60 * 1000
|
|
1426
|
+
const current = readTaskCurrent()
|
|
1427
|
+
const done = readTaskResults().length
|
|
1428
|
+
const failedSoFar = readTaskResults().filter((result) => !result.ok).length
|
|
1429
|
+
const total = readTaskTotal()
|
|
1430
|
+
const elapsed = elapsedText(Math.max(0, Math.floor((Date.now() - task.startedAt) / 1000)), en)
|
|
1431
|
+
const progressText = [
|
|
1432
|
+
current ? (en ? `processing ${current.name}` : `正在处理 ${current.name}`) : '',
|
|
1433
|
+
en ? `done ${done}${total ? ` / ${total}` : ''}` : `已处理 ${done}${total ? ` / ${total}` : ''}`,
|
|
1434
|
+
failedSoFar > 0 ? (en ? `${failedSoFar} failed` : `失败 ${failedSoFar}`) : '',
|
|
1435
|
+
en ? `elapsed ${elapsed}` : `已用 ${elapsed}`,
|
|
1436
|
+
].filter(Boolean).join(' · ')
|
|
1389
1437
|
children.push({ type: 'callout', tone: stale ? 'warn' : 'info', text: stale
|
|
1390
|
-
? (en ?
|
|
1391
|
-
: (en ? `${taskLabel(task.kind, true)} running
|
|
1438
|
+
? (en ? `${taskLabel(task.kind, true)} running too long (${progressText}); check the log.` : `${taskLabel(task.kind, false)}运行太久(${progressText}),看下日志。`)
|
|
1439
|
+
: (en ? `${taskLabel(task.kind, true)} running: ${progressText}` : `${taskLabel(task.kind, false)}中:${progressText}`) })
|
|
1392
1440
|
} else if (task && task.ok === false) {
|
|
1393
1441
|
children.push({ type: 'callout', tone: 'bad', text: en
|
|
1394
1442
|
? `${taskLabel(task.kind, true)} failed (${task.failed}). Check the log.`
|
|
@@ -1443,23 +1491,36 @@ function buildView(scope, caps, ctx) {
|
|
|
1443
1491
|
? `Manifest: ${source || 'imported'}${when ? ` · ${when}` : ''}`
|
|
1444
1492
|
: `清单来源:${source || '已导入'}${when ? ` · ${when}` : ''}` })
|
|
1445
1493
|
|
|
1494
|
+
const pending = rows.filter((row) => row.status !== 'same')
|
|
1495
|
+
const installed = rows.filter((row) => row.status === 'same')
|
|
1496
|
+
const visible = state.showAll ? rows : pending
|
|
1446
1497
|
if (rows.length === 0) {
|
|
1447
1498
|
children.push({ type: 'callout', tone: 'good', text: en ? 'The two hosts match.' : '两边完全一致。' })
|
|
1448
1499
|
} else {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1500
|
+
if (pending.length === 0) {
|
|
1501
|
+
children.push({ type: 'callout', tone: 'good', text: en ? 'Nothing pending; everything is in sync.' : '没有待处理项,已全部一致。' })
|
|
1502
|
+
}
|
|
1503
|
+
const shown = visible.slice(0, 40)
|
|
1504
|
+
if (shown.length > 0) {
|
|
1505
|
+
children.push({ type: 'list', items: shown.map((row) => {
|
|
1506
|
+
const item = {
|
|
1507
|
+
title: row.name,
|
|
1508
|
+
subtitle: statusLine(row, en),
|
|
1509
|
+
trailing: state.selected.has(row.name) ? '✓' : '○',
|
|
1510
|
+
action: { id: 'toggle', args: { name: row.name } },
|
|
1511
|
+
}
|
|
1512
|
+
const tone = statusTone(row.status)
|
|
1513
|
+
if (tone) item.tone = tone
|
|
1514
|
+
return item
|
|
1515
|
+
}) })
|
|
1516
|
+
}
|
|
1517
|
+
if (visible.length > shown.length) {
|
|
1518
|
+
children.push({ type: 'text', text: en ? `…and ${visible.length - shown.length} more` : `…还有 ${visible.length - shown.length} 项` })
|
|
1519
|
+
}
|
|
1520
|
+
if (!state.showAll && installed.length > 0) {
|
|
1521
|
+
children.push({ type: 'text', text: en
|
|
1522
|
+
? `${installed.length} already installed (tap "Show all" to view)`
|
|
1523
|
+
: `已安装 ${installed.length} 个(点「显示全部」查看)` })
|
|
1463
1524
|
}
|
|
1464
1525
|
}
|
|
1465
1526
|
|
|
@@ -1469,6 +1530,7 @@ function buildView(scope, caps, ctx) {
|
|
|
1469
1530
|
{ label: en ? 'Copy code' : '复制同步码', action: 'copy-code' },
|
|
1470
1531
|
{ label: en ? 'Select all' : '全选', action: 'select-all' },
|
|
1471
1532
|
{ label: en ? 'Clear' : '清空', action: 'clear' },
|
|
1533
|
+
{ label: state.showAll ? (en ? 'Pending only' : '只看待处理') : (en ? 'Show all' : '显示全部'), action: 'toggle-show-all' },
|
|
1472
1534
|
{ label: en ? 'Refresh' : '刷新', action: 'refresh' },
|
|
1473
1535
|
]
|
|
1474
1536
|
children.push({ type: 'actions', items: primary })
|
|
@@ -1477,6 +1539,7 @@ function buildView(scope, caps, ctx) {
|
|
|
1477
1539
|
{ label: en ? 'Retry failed' : '重试失败', action: 'retry-failed' },
|
|
1478
1540
|
{ label: en ? 'Export' : '导出清单', action: 'export' },
|
|
1479
1541
|
{ label: en ? 'Read workspace' : '工作区导入', action: 'import-workspace' },
|
|
1542
|
+
{ label: en ? 'Clear list' : '清空清单', action: 'clear-all' },
|
|
1480
1543
|
{ label: en ? 'Guide' : '使用引导', action: 'guide' },
|
|
1481
1544
|
] })
|
|
1482
1545
|
|
|
@@ -1603,7 +1666,7 @@ function webSnapshot(ctx) {
|
|
|
1603
1666
|
const scope = { sessionId: 'web-ui' }
|
|
1604
1667
|
const state = stateFor(scope)
|
|
1605
1668
|
const cfg = loadConfig(ctx, scope)
|
|
1606
|
-
refreshManifests(state, cfg)
|
|
1669
|
+
refreshManifests(state, cfg, { dshGo: Boolean(ctx.get?.('dshGo')) })
|
|
1607
1670
|
const local = localPlugins()
|
|
1608
1671
|
const cleared = uiCleared()
|
|
1609
1672
|
const rows = cleared
|
|
@@ -1630,6 +1693,7 @@ function webSnapshot(ctx) {
|
|
|
1630
1693
|
cleared,
|
|
1631
1694
|
task: readTaskStatus(),
|
|
1632
1695
|
results: readTaskResults(),
|
|
1696
|
+
log: readLogTail(3),
|
|
1633
1697
|
config: cfg,
|
|
1634
1698
|
configPath: configPathFor(ctx, scope),
|
|
1635
1699
|
}
|
|
@@ -1840,6 +1904,23 @@ export function apply(ctx) {
|
|
|
1840
1904
|
'ssh-scan': sshScan,
|
|
1841
1905
|
'retry-failed': retryFailed,
|
|
1842
1906
|
|
|
1907
|
+
'toggle-show-all'(scope) {
|
|
1908
|
+
const state = stateFor(scope)
|
|
1909
|
+
state.showAll = !state.showAll
|
|
1910
|
+
return { refresh: true }
|
|
1911
|
+
},
|
|
1912
|
+
|
|
1913
|
+
'clear-all'(scope) {
|
|
1914
|
+
const state = stateFor(scope)
|
|
1915
|
+
state.manifest = null
|
|
1916
|
+
state.manifestSource = null
|
|
1917
|
+
state.sourceName = null
|
|
1918
|
+
state.importedAt = null
|
|
1919
|
+
state.selected.clear()
|
|
1920
|
+
try { unlinkSync(importFile()) } catch {}
|
|
1921
|
+
return [{ toast: '已清空清单,可重新导入同步码或拉取中转' }, { refresh: true }]
|
|
1922
|
+
},
|
|
1923
|
+
|
|
1843
1924
|
guide() {
|
|
1844
1925
|
return { open: 'panel:guide' }
|
|
1845
1926
|
},
|
|
@@ -1916,9 +1997,11 @@ export function apply(ctx) {
|
|
|
1916
1997
|
state.manifestSource = { kind: kind || 'file' }
|
|
1917
1998
|
state.importedAt = new Date().toISOString()
|
|
1918
1999
|
state.sourceName = typeof sourceName === 'string' ? sourceName : null
|
|
2000
|
+
state.showAll = false
|
|
1919
2001
|
state.selected.clear()
|
|
1920
2002
|
persistImported(state)
|
|
1921
2003
|
resetUiState()
|
|
2004
|
+
preselectRows(state, { dshGo: true })
|
|
1922
2005
|
return [{ toast: `已导入 ${manifest.plugins.length} 个插件` }, { refresh: true }]
|
|
1923
2006
|
}
|
|
1924
2007
|
})
|