dsh-profile-config-sync 0.6.47 → 0.7.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/README.en.md +43 -2
- package/README.md +52 -5
- package/client.js +226 -38
- package/docs/CHANGELOG.md +1 -0
- package/docs/REFERENCE.md +39 -3
- package/index.js +696 -201
- package/package.json +4 -3
- package/release-notes.json +5 -4
- package/runtime/contract.mjs +10 -3
- package/runtime/conversations.mjs +433 -0
- package/runtime/extra-rules.mjs +238 -0
- package/runtime/install-plugin.mjs +279 -0
- package/runtime/install-plugin.ps1 +5 -6
- package/runtime/platform.mjs +198 -5
- package/runtime/porting.mjs +319 -0
- package/runtime/post-exit.mjs +347 -0
- package/runtime/post-exit.ps1 +7 -7
- package/runtime/settings-sources.mjs +46 -0
- package/runtime/sync-engine.mjs +1190 -52
- package/runtime/webdav.mjs +247 -24
- package/runtime/zip.mjs +156 -0
package/client.js
CHANGED
|
@@ -70,6 +70,11 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
return true
|
|
71
71
|
}
|
|
72
72
|
const M = (zh, en) => (langIsZh() ? zh : en)
|
|
73
|
+
// 0.6.49:本机是不是 Windows 形状(status.platform.local.isWindows)。
|
|
74
|
+
// 面板里凡是「路径示例 / 脚本后缀」都该按它切,别再一律写 D:\ 与 .cmd。
|
|
75
|
+
const isWindowsLike = (data) => Boolean(
|
|
76
|
+
data && data.platform && data.platform.local && data.platform.local.isWindows,
|
|
77
|
+
)
|
|
73
78
|
const localeNow = () => (langIsZh() ? 'zh-CN' : 'en-US')
|
|
74
79
|
const langHeaders = () => ({ 'accept-language': langIsZh() ? 'zh-CN,zh;q=0.9' : 'en-US,en;q=0.9' })
|
|
75
80
|
|
|
@@ -287,14 +292,20 @@ window.__ModuleLoader__.load({
|
|
|
287
292
|
// 三件不能混成一件事的:从没同步过 / 扫描没跑完 / 真的没有
|
|
288
293
|
if (local.known === false) return { kind: 'idle', text: M('还没有同步记录:先推送或拉取一次', 'No sync record yet — push or pull once') }
|
|
289
294
|
if (local.truncated) return { kind: 'warn', text: M('待推送扫描没跑完(文件太多或超时),数字可能偏小', 'Pending scan did not finish (too many files or timeout) — the count may be low') }
|
|
290
|
-
// 非 Windows
|
|
295
|
+
// 非 Windows:别让「没有待推送」被读成「全都同步了」。0.6.49 起引擎覆盖全部 12 组,
|
|
296
|
+
// 这时就直说「都同步」;没覆盖全的平台才列清单并提 Windows。
|
|
291
297
|
if (Array.isArray(local.engineGroups) && local.pending === 0) {
|
|
292
298
|
return {
|
|
293
299
|
kind: 'idle',
|
|
294
|
-
text:
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
text: local.engineAllGroups
|
|
301
|
+
? M(
|
|
302
|
+
`已同步(这台机器走跨平台引擎,${local.engineGroups.length} 组内容都与仓库一致)`,
|
|
303
|
+
`Up to date (this machine uses the cross-platform engine; all ${local.engineGroups.length} groups match the repo)`,
|
|
304
|
+
)
|
|
305
|
+
: M(
|
|
306
|
+
`已同步(这台机器走跨平台引擎,只处理 ${local.engineGroups.join(' / ')};其余组要 Windows 版才会同步)`,
|
|
307
|
+
`Up to date (this machine uses the cross-platform engine, which only handles ${local.engineGroups.join(' / ')}; the rest sync on Windows)`,
|
|
308
|
+
),
|
|
298
309
|
}
|
|
299
310
|
}
|
|
300
311
|
if (local.pending > 0) {
|
|
@@ -395,8 +406,15 @@ window.__ModuleLoader__.load({
|
|
|
395
406
|
return body
|
|
396
407
|
}
|
|
397
408
|
|
|
398
|
-
/**
|
|
399
|
-
|
|
409
|
+
/**
|
|
410
|
+
* 自动同步接口:check / pull-now / push-now / push-live / cancel。
|
|
411
|
+
*
|
|
412
|
+
* 0.6.49:宿主在 macOS 上用 osascript 弹原生确认框(display dialog)。面板点按钮时那个框
|
|
413
|
+
* 可能被应用窗口挡住、甚至根本不出现在前台 —— 请求就这么挂到 12 分钟超时,用户看到的是
|
|
414
|
+
* 「按钮转圈、没反应」。现在改成两段式:宿主第一遍回 needConfirm + 文案,面板自己问
|
|
415
|
+
* (window.confirm),确认后带 confirmed:true 重发同一请求。命令行/curl 调用仍然走原生框。
|
|
416
|
+
*/
|
|
417
|
+
async function autoFetch(payload, depth = 0) {
|
|
400
418
|
const res = await fetch('/config-sync/auto', {
|
|
401
419
|
method: 'POST',
|
|
402
420
|
cache: 'no-store',
|
|
@@ -407,9 +425,17 @@ window.__ModuleLoader__.load({
|
|
|
407
425
|
const text = await res.text()
|
|
408
426
|
let body
|
|
409
427
|
try { body = text ? JSON.parse(text) : null } catch { throw badJson(res) }
|
|
428
|
+
if (body && body.needConfirm && depth < 2) {
|
|
429
|
+
const canAsk = typeof window !== 'undefined' && typeof window.confirm === 'function'
|
|
430
|
+
const ok = canAsk ? window.confirm(String(body.message || body.title || '继续?')) : false
|
|
431
|
+
// 用户点了取消:不抛错(取消不是失败),把决定原样交回调用方
|
|
432
|
+
if (!ok) return { ok: true, action: payload.action, cancelled: true, needConfirm: true }
|
|
433
|
+
return autoFetch({ ...payload, confirmed: true }, depth + 1)
|
|
434
|
+
}
|
|
410
435
|
if (!res.ok || !body || body.ok !== true) throw new Error((body && body.error) || `${res.status}`)
|
|
411
436
|
return body
|
|
412
437
|
}
|
|
438
|
+
async function callAuto(payload) { return autoFetch(payload) }
|
|
413
439
|
|
|
414
440
|
/**
|
|
415
441
|
* 同步内容勾选:GET 取十组内容与当前勾选,POST 落盘 `<DshHome>\config-sync-scope.json`。
|
|
@@ -722,6 +748,8 @@ window.__ModuleLoader__.load({
|
|
|
722
748
|
const currentWdUrl = st.url || ''
|
|
723
749
|
const currentWdUser = st.user || ''
|
|
724
750
|
const currentWdDir = st.dir || ''
|
|
751
|
+
// 0.6.48:自定义 User-Agent(留空 = 不发 User-Agent 头)
|
|
752
|
+
const currentWdUa = st.userAgent || ''
|
|
725
753
|
const currentGitUrl = remote.url || ''
|
|
726
754
|
const currentGitKey = remote.sshKey || ''
|
|
727
755
|
|
|
@@ -731,6 +759,7 @@ window.__ModuleLoader__.load({
|
|
|
731
759
|
const [wdUser, setWdUser] = react.useState(currentWdUser)
|
|
732
760
|
const [wdPass, setWdPass] = react.useState('')
|
|
733
761
|
const [wdDir, setWdDir] = react.useState(currentWdDir)
|
|
762
|
+
const [wdUa, setWdUa] = react.useState(currentWdUa)
|
|
734
763
|
const [gitUrl, setGitUrl] = react.useState(currentGitUrl)
|
|
735
764
|
const [gitKey, setGitKey] = react.useState(currentGitKey)
|
|
736
765
|
const [busy, setBusy] = react.useState(false)
|
|
@@ -751,19 +780,25 @@ window.__ModuleLoader__.load({
|
|
|
751
780
|
setWdUrl(currentWdUrl)
|
|
752
781
|
setWdUser(currentWdUser)
|
|
753
782
|
setWdDir(currentWdDir)
|
|
783
|
+
setWdUa(currentWdUa)
|
|
754
784
|
setWdPass('')
|
|
755
785
|
setGitUrl(currentGitUrl)
|
|
756
786
|
setGitKey(currentGitKey)
|
|
757
|
-
}, [editing, currentMode, currentWdUrl, currentWdUser, currentWdDir, currentGitUrl, currentGitKey])
|
|
787
|
+
}, [editing, currentMode, currentWdUrl, currentWdUser, currentWdDir, currentWdUa, currentGitUrl, currentGitKey])
|
|
758
788
|
|
|
759
|
-
const activeMode = editing ? mode : currentMode
|
|
760
789
|
const wdConfigured = Boolean(st.configured || st.url)
|
|
761
790
|
const gitConfigured = Boolean(remote.configured || remote.url)
|
|
791
|
+
// 0.6.49 修复(用户实测):卡片在「什么云端都还没配」时会**强制**进入编辑态,
|
|
792
|
+
// 但那时 editing 仍是 false。原来 activeMode 取 `editing ? mode : currentMode`,
|
|
793
|
+
// 于是选了 WebDAV 之后字段不跟着切 —— 显示的还是 Git 那套(远端地址 / SSH 私钥),
|
|
794
|
+
// 保存时校验按 webdav 走,报「请填写 WebDAV 地址」,用户根本填不到那个框。
|
|
795
|
+
// 现在由 isEditing 决定,强制编辑态也跟随下拉框。
|
|
796
|
+
const isEditing = editing || (!wdConfigured && !gitConfigured && Boolean(props.data))
|
|
797
|
+
const activeMode = isEditing ? mode : currentMode
|
|
762
798
|
const missing = Boolean(props.data) && (
|
|
763
799
|
activeMode === 'webdav' ? !wdConfigured
|
|
764
800
|
: (activeMode === 'git' ? !gitConfigured : (!wdConfigured && !gitConfigured))
|
|
765
801
|
)
|
|
766
|
-
const isEditing = editing || (!wdConfigured && !gitConfigured && Boolean(props.data))
|
|
767
802
|
|
|
768
803
|
const sourceLabel = (s) => s === 'settings' ? M('本机设置', 'Machine settings')
|
|
769
804
|
: (s === 'git' ? M('git 配置', 'git config')
|
|
@@ -774,6 +809,7 @@ window.__ModuleLoader__.load({
|
|
|
774
809
|
setWdUrl(currentWdUrl)
|
|
775
810
|
setWdUser(currentWdUser)
|
|
776
811
|
setWdDir(currentWdDir)
|
|
812
|
+
setWdUa(currentWdUa)
|
|
777
813
|
setWdPass('')
|
|
778
814
|
setGitUrl(currentGitUrl)
|
|
779
815
|
setGitKey(currentGitKey)
|
|
@@ -784,6 +820,7 @@ window.__ModuleLoader__.load({
|
|
|
784
820
|
setWdUrl(currentWdUrl)
|
|
785
821
|
setWdUser(currentWdUser)
|
|
786
822
|
setWdDir(currentWdDir)
|
|
823
|
+
setWdUa(currentWdUa)
|
|
787
824
|
setWdPass('')
|
|
788
825
|
setGitUrl(currentGitUrl)
|
|
789
826
|
setGitKey(currentGitKey)
|
|
@@ -802,13 +839,19 @@ window.__ModuleLoader__.load({
|
|
|
802
839
|
if (mode === 'auto' && !wdUrl.trim() && !gitUrl.trim()) {
|
|
803
840
|
throw new Error(M('自动模式下请至少填写 WebDAV 地址或 Git 远端地址', 'In Auto mode, provide at least a WebDAV URL or a Git remote URL'))
|
|
804
841
|
}
|
|
805
|
-
await callWebdav({ action: 'save', url: wdUrl, user: wdUser, dir: wdDir, mode, pass: wdPass })
|
|
842
|
+
await callWebdav({ action: 'save', url: wdUrl, user: wdUser, dir: wdDir, mode, pass: wdPass, userAgent: wdUa })
|
|
806
843
|
let gitSet = false
|
|
807
|
-
|
|
844
|
+
// 0.6.49 修复:选了 WebDAV 就不该再动 git 设置。原来这里不看模式,
|
|
845
|
+
// 用户在「远端地址」里先前填过的 DAV 地址会被当成 git 远端存下去,
|
|
846
|
+
// 随后 git remote set-url 失败、整套回滚,报一个跟 WebDAV 毫无关系的错。
|
|
847
|
+
const gitDirty = mode !== 'webdav'
|
|
848
|
+
&& (gitUrl.trim() !== currentGitUrl.trim() || gitKey.trim() !== currentGitKey.trim())
|
|
808
849
|
if (gitDirty && (gitUrl.trim() || currentGitUrl.trim() || gitKey.trim() || currentGitKey.trim())) {
|
|
809
850
|
const r = await callSettings({ remoteUrl: gitUrl, sshKey: gitKey })
|
|
810
851
|
gitSet = Boolean(r && r.gitRemoteSet)
|
|
811
852
|
}
|
|
853
|
+
// 注意:这里**不清空** Git 那两格的本地 state —— 用户可能只是临时切到 WebDAV,
|
|
854
|
+
// 清掉会让「再切回 Git」时私钥路径凭空消失(磁盘上的值还在,但看起来像丢了)。
|
|
812
855
|
setEditing(false); setWdPass('')
|
|
813
856
|
setMsg(M(
|
|
814
857
|
`已保存${gitSet ? ',并已更新本机 git origin' : ''}`,
|
|
@@ -824,7 +867,29 @@ window.__ModuleLoader__.load({
|
|
|
824
867
|
try {
|
|
825
868
|
const r = await callWebdav({ action })
|
|
826
869
|
const res = r.result || r
|
|
827
|
-
if (res.ok === false)
|
|
870
|
+
if (res.ok === false) {
|
|
871
|
+
// 0.6.48:失败时把「该改哪一项」直接摊开(服务端已按状态码给出可执行的文案),
|
|
872
|
+
// 并且顺带报出实际发出去的 UA —— 排查 UA 拦截时这是第一个要确认的事实。
|
|
873
|
+
const parts = [String(res.error || M('操作失败', 'Operation failed'))]
|
|
874
|
+
// 上传/下载的失败原因在 errors 数组里(每条一个文件),
|
|
875
|
+
// 只报一句「操作失败」等于把服务端刚给出的诊断又丢了。
|
|
876
|
+
if (Array.isArray(res.errors) && res.errors.length) {
|
|
877
|
+
parts.push(res.errors.slice(0, 5).join(';'))
|
|
878
|
+
}
|
|
879
|
+
if (action === 'test' && res.userAgent !== undefined) {
|
|
880
|
+
parts.push(M(`本次 User-Agent:${res.userAgent || '(未发送)'}`, `User-Agent sent: ${res.userAgent || '(none)'}`))
|
|
881
|
+
}
|
|
882
|
+
throw new Error(parts.join(' · '))
|
|
883
|
+
}
|
|
884
|
+
if (action === 'test') {
|
|
885
|
+
const n = res.files ?? (res.rootFiles || 0) + (res.rootDirs || 0)
|
|
886
|
+
setMsg(M(
|
|
887
|
+
`连通正常:云端根目录 ${n} 项${res.exists === false ? '(目录还不存在,首次推送会自动创建)' : ''}${res.userAgent ? ` · UA ${res.userAgent}` : ' · 未发送 User-Agent'}`,
|
|
888
|
+
`Connected: ${n} item(s) at the cloud root${res.exists === false ? ' (folder does not exist yet; the first push creates it)' : ''}${res.userAgent ? ` · UA ${res.userAgent}` : ' · no User-Agent sent'}`,
|
|
889
|
+
))
|
|
890
|
+
if (typeof props.onSaved === 'function') props.onSaved()
|
|
891
|
+
return
|
|
892
|
+
}
|
|
828
893
|
setMsg(M(
|
|
829
894
|
`完成:上传 ${res.uploaded || 0} · 下载 ${res.downloaded || 0} · 跳过 ${res.skipped || 0} · 冲突 ${res.conflicts || 0}`,
|
|
830
895
|
`Done: uploaded ${res.uploaded || 0} · downloaded ${res.downloaded || 0} · skipped ${res.skipped || 0} · conflicts ${res.conflicts || 0}`,
|
|
@@ -898,6 +963,12 @@ window.__ModuleLoader__.load({
|
|
|
898
963
|
v: st.hasPassword ? M('已设置(不回显)', 'set (not shown)') : M('未设置', 'not set'),
|
|
899
964
|
}),
|
|
900
965
|
field(M('远端目录', 'Remote dir'), isEditing ? wdDir : currentWdDir, setWdDir, 'dsh-config-sync'),
|
|
966
|
+
// 0.6.48:UA。第三方 DAV 常按客户端名放行/拦截,默认 undici UA 会被 401/403。
|
|
967
|
+
field(M('User-Agent', 'User-Agent'), isEditing ? wdUa : currentWdUa, setWdUa, M('留空 = 不发(默认)', 'blank = do not send')),
|
|
968
|
+
isEditing
|
|
969
|
+
? h('div', { style: { ...S.footnote, marginTop: '-2px' } }, M(
|
|
970
|
+
'部分第三方 WebDAV(群晖 / 坚果云 / 自建 DAV)会按客户端 User-Agent 放行或拦截;连不上且报 403 时,填它要求的客户端名(如 Mozilla/5.0 或 davfs2)。留空则不发 User-Agent。',
|
|
971
|
+
'Some third-party WebDAV servers (Synology / Jianguoyun / self-hosted DAV) allow or block by client User-Agent; if you get 403, put the client name they expect (e.g. Mozilla/5.0 or davfs2). Leave blank to send no User-Agent.')) : null,
|
|
901
972
|
h(Kv, {
|
|
902
973
|
k: M('传输安全', 'Transport'),
|
|
903
974
|
v: (st.secure === false)
|
|
@@ -1104,7 +1175,11 @@ window.__ModuleLoader__.load({
|
|
|
1104
1175
|
isEditing
|
|
1105
1176
|
? h('input', {
|
|
1106
1177
|
type: 'text', style: S.input, value: path, spellCheck: false,
|
|
1107
|
-
|
|
1178
|
+
// 0.6.49:占位符随平台走 —— 原来一律是 D:\dsh-config,
|
|
1179
|
+
// macOS 用户照着填会在本机建出一个叫 `D:\dsh-config` 的目录(实测踩过)。
|
|
1180
|
+
placeholder: isWindowsLike(props.data)
|
|
1181
|
+
? M('D:\\dsh-config(那台机器上装仓库的目录)', 'D:\\dsh-config (directory holding the repo on this machine)')
|
|
1182
|
+
: M('/Users/你/dsh-config(那台机器上装仓库的目录)', '/Users/you/dsh-config (directory holding the repo on this machine)'),
|
|
1108
1183
|
onChange: (e) => setPath(e.target.value),
|
|
1109
1184
|
})
|
|
1110
1185
|
: h('div', { style: { ...S.kvVal, fontFamily: 'Consolas, ui-monospace, monospace' } }, repo.path || M('(未配置)', '(not set)')),
|
|
@@ -1167,8 +1242,8 @@ window.__ModuleLoader__.load({
|
|
|
1167
1242
|
))
|
|
1168
1243
|
: null,
|
|
1169
1244
|
h('div', { style: S.footnote }, M(
|
|
1170
|
-
'
|
|
1171
|
-
'The path lives only in the local settings file (
|
|
1245
|
+
'路径只存本机设置文件(~/.dsh/dsh-config-sync.json),不进仓库,各机器各配各的。',
|
|
1246
|
+
'The path lives only in the local settings file (~/.dsh/dsh-config-sync.json), never in the repo.',
|
|
1172
1247
|
)),
|
|
1173
1248
|
forced
|
|
1174
1249
|
? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-error-primary)' } },
|
|
@@ -2280,6 +2355,9 @@ window.__ModuleLoader__.load({
|
|
|
2280
2355
|
const excluded = items.filter((i) => i.enabled === false).length
|
|
2281
2356
|
const expanded = open[g.id] === true
|
|
2282
2357
|
const groupOn = g.enabled !== false
|
|
2358
|
+
// 0.6.49:宿主会按平台告诉这一组「本机引擎到底会不会同步」(非 Windows 只有四组)。
|
|
2359
|
+
// 不支持的组一律禁用勾选并标注原因 —— 让人勾着却永远不生效是最糟的那种"看起来能用"。
|
|
2360
|
+
const supported = g.supported !== false
|
|
2283
2361
|
const canExpand = items.length > 0
|
|
2284
2362
|
return h('div', {
|
|
2285
2363
|
key: g.id,
|
|
@@ -2296,10 +2374,13 @@ window.__ModuleLoader__.load({
|
|
|
2296
2374
|
}, expanded ? '▾' : '▸')
|
|
2297
2375
|
: h('span', { style: { flexShrink: 0, width: '10px' } }),
|
|
2298
2376
|
h('input', {
|
|
2299
|
-
type: 'checkbox', checked: groupOn,
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2377
|
+
type: 'checkbox', checked: groupOn,
|
|
2378
|
+
disabled: busy || !editing || g.required === true || !supported,
|
|
2379
|
+
title: !supported
|
|
2380
|
+
? M('此平台暂不支持:要 Windows 版才会同步这一组', 'Not supported on this platform yet — this group syncs on Windows')
|
|
2381
|
+
: (g.required === true
|
|
2382
|
+
? M('必需内容:取消会让另一台机器拉取时直接报错', 'Required: unchecking it makes the other machine fail on pull')
|
|
2383
|
+
: (editing ? '' : M('只读:先点「修改」', 'Read-only: click Edit first'))),
|
|
2303
2384
|
onClick: (e) => e.stopPropagation(), // 勾选别当成"点行展开"
|
|
2304
2385
|
onChange: () => toggleGroup(g.id), style: { flexShrink: 0 },
|
|
2305
2386
|
}),
|
|
@@ -2310,7 +2391,9 @@ window.__ModuleLoader__.load({
|
|
|
2310
2391
|
color: groupOn ? 'var(--dsw-alias-label-primary)' : 'var(--dsw-alias-label-tertiary)',
|
|
2311
2392
|
textDecoration: groupOn ? 'none' : 'line-through',
|
|
2312
2393
|
},
|
|
2313
|
-
}, g.required === true
|
|
2394
|
+
}, g.required === true
|
|
2395
|
+
? `${g.title} · ${M('必需', 'required')}`
|
|
2396
|
+
: (supported ? g.title : `${g.title} · ${M('此平台暂不支持', 'not on this platform')}`)),
|
|
2314
2397
|
g.desc
|
|
2315
2398
|
? h('div', { style: S.footnote },
|
|
2316
2399
|
g.required === true
|
|
@@ -2402,17 +2485,9 @@ window.__ModuleLoader__.load({
|
|
|
2402
2485
|
})
|
|
2403
2486
|
}
|
|
2404
2487
|
try {
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
body: JSON.stringify({ action, ...(extra || {}) }),
|
|
2409
|
-
})
|
|
2410
|
-
const text = await res.text()
|
|
2411
|
-
let body
|
|
2412
|
-
// 这一处原来是全文件唯一没有 try 的 JSON.parse:宿主代理回一页 HTML 错误时,
|
|
2413
|
-
// 用户看到的是 "Unexpected token '<'" 这种噪声,而不是「500 返回非 JSON」。
|
|
2414
|
-
try { body = text ? JSON.parse(text) : null } catch { throw badJson(res) }
|
|
2415
|
-
if (!res.ok || !body || body.ok !== true) throw new Error((body && body.error) || `${res.status}`)
|
|
2488
|
+
// 0.6.49:走 autoFetch —— 需要确认时在面板里问,不再依赖宿主弹的原生框
|
|
2489
|
+
const body = await autoFetch({ action, ...(extra || {}) })
|
|
2490
|
+
if (body && body.cancelled) { setBusy(''); setMsg(M('已取消', 'Cancelled')); return }
|
|
2416
2491
|
if (action === 'check') {
|
|
2417
2492
|
const d = body.drift
|
|
2418
2493
|
setMsg(d
|
|
@@ -2519,10 +2594,21 @@ window.__ModuleLoader__.load({
|
|
|
2519
2594
|
+ `${pendingReason ? `, reason: ${pendingReason}` : ''})`,
|
|
2520
2595
|
))
|
|
2521
2596
|
: null,
|
|
2597
|
+
// 0.6.49:后台自动拉取在 macOS 上不再弹原生框(启动时的对话框常被窗口挡住,
|
|
2598
|
+
// 用户看不见就等于永不发生)。宿主把提示挂进 status.auto.pullPrompt,这里明说一句,
|
|
2599
|
+
// 让用户知道「该点下面那个按钮」——而不是以为自动同步在工作。
|
|
2600
|
+
auto.pullPrompt && !pending
|
|
2601
|
+
? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
2602
|
+
M(
|
|
2603
|
+
`云端领先 ${auto.pullPrompt.behind} 个提交:自动拉取需要你点一下「立即拉取」(退出后才会执行)`,
|
|
2604
|
+
`The cloud is ${auto.pullPrompt.behind} commit(s) ahead — click "Pull now" to sync (it runs after DSH exits)`,
|
|
2605
|
+
))
|
|
2606
|
+
: null,
|
|
2522
2607
|
!auto.script
|
|
2523
2608
|
? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
2524
|
-
|
|
2525
|
-
|
|
2609
|
+
// 0.6.49:执行体名随平台(Windows post-exit.ps1 / macOS、Linux post-exit.mjs)
|
|
2610
|
+
M(`找不到 ${isWindowsLike(data) ? 'post-exit.ps1' : 'post-exit.mjs'}:自动同步排不了队,重装插件即可`,
|
|
2611
|
+
`${isWindowsLike(data) ? 'post-exit.ps1' : 'post-exit.mjs'} is missing from both the plugin and the repo, so auto sync cannot queue — reinstall the plugin (the current package ships runtime/)`))
|
|
2526
2612
|
: null,
|
|
2527
2613
|
h('div', { style: S.actions },
|
|
2528
2614
|
h('button', {
|
|
@@ -3787,10 +3873,62 @@ window.__ModuleLoader__.load({
|
|
|
3787
3873
|
const [busy, setBusy] = react.useState(false)
|
|
3788
3874
|
const [msg, setMsg] = react.useState('')
|
|
3789
3875
|
const [err, setErr] = react.useState('')
|
|
3876
|
+
// 0.6.48(issue #9):附件(图片 / 视频 / 日志)。选文件后读成 base64 跟着提交走,
|
|
3877
|
+
// 服务端传到仓库的 release assets,正文引用 —— 不借道第三方图床。
|
|
3878
|
+
const [files, setFiles] = react.useState([])
|
|
3790
3879
|
// 筛选:状态走本地过滤(一次拉全量、计数才准),关键词也本地过,输入即筛,不打接口
|
|
3791
3880
|
const [filter, setFilter] = react.useState('open')
|
|
3792
3881
|
const [kw, setKw] = react.useState('')
|
|
3793
3882
|
|
|
3883
|
+
const MAX_ATTACH = 4
|
|
3884
|
+
const MAX_ATTACH_MB = 20
|
|
3885
|
+
const ATTACH_OK = /\.(png|jpe?g|gif|webp|bmp|svg|mp4|mov|webm|log|txt|md|json)$/i
|
|
3886
|
+
|
|
3887
|
+
/** 读一个 File 成 base64(去掉 data: 前缀)。FileReader 在面板进程里可用。 */
|
|
3888
|
+
const readAsBase64 = (file) => new Promise((resolve, reject) => {
|
|
3889
|
+
try {
|
|
3890
|
+
const fr = new FileReader()
|
|
3891
|
+
fr.onload = () => {
|
|
3892
|
+
const s = String(fr.result || '')
|
|
3893
|
+
const comma = s.indexOf(',')
|
|
3894
|
+
resolve(comma >= 0 ? s.slice(comma + 1) : '')
|
|
3895
|
+
}
|
|
3896
|
+
fr.onerror = () => reject(new Error(String((fr.error && fr.error.message) || 'read failed')))
|
|
3897
|
+
fr.readAsDataURL(file)
|
|
3898
|
+
} catch (e) { reject(e) }
|
|
3899
|
+
})
|
|
3900
|
+
|
|
3901
|
+
const addFiles = async (list) => {
|
|
3902
|
+
const picked = Array.from(list || [])
|
|
3903
|
+
if (!picked.length) return
|
|
3904
|
+
setErr(''); setMsg('')
|
|
3905
|
+
const next = [...files]
|
|
3906
|
+
const problems = []
|
|
3907
|
+
for (const f of picked) {
|
|
3908
|
+
if (next.length >= MAX_ATTACH) { problems.push(M(`附件最多 ${MAX_ATTACH} 个`, `At most ${MAX_ATTACH} attachments`)); break }
|
|
3909
|
+
if (!ATTACH_OK.test(f.name || '')) {
|
|
3910
|
+
problems.push(M(`${f.name}:不支持的类型(只收图片 / 视频 / 日志)`, `${f.name}: unsupported type (images, videos, logs only)`))
|
|
3911
|
+
continue
|
|
3912
|
+
}
|
|
3913
|
+
if ((f.size || 0) > MAX_ATTACH_MB * 1024 * 1024) {
|
|
3914
|
+
problems.push(M(`${f.name}:超过 ${MAX_ATTACH_MB} MB`, `${f.name}: larger than ${MAX_ATTACH_MB} MB`))
|
|
3915
|
+
continue
|
|
3916
|
+
}
|
|
3917
|
+
try {
|
|
3918
|
+
const data = await readAsBase64(f)
|
|
3919
|
+
if (!data) { problems.push(M(`${f.name}:读不出内容`, `${f.name}: cannot read content`)); continue }
|
|
3920
|
+
next.push({ name: f.name || 'attachment', size: f.size || 0, type: f.type || '', data })
|
|
3921
|
+
} catch (e) {
|
|
3922
|
+
problems.push(M(`${f.name}:${String((e && e.message) || e)}`, `${f.name}: ${String((e && e.message) || e)}`))
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
setFiles(next)
|
|
3926
|
+
if (problems.length) setErr(problems.join(';'))
|
|
3927
|
+
else if (next.length > files.length) setMsg(M(`已加 ${next.length - files.length} 个附件(点「提交到 GitHub」一起发)`, `Added ${next.length - files.length} attachment(s) — they go with the report`))
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
const removeFile = (idx) => { setFiles(files.filter((_, i) => i !== idx)); setErr(''); setMsg('') }
|
|
3931
|
+
|
|
3794
3932
|
const load = async (forceRefresh = false) => {
|
|
3795
3933
|
setBusy(true)
|
|
3796
3934
|
try {
|
|
@@ -3807,18 +3945,37 @@ window.__ModuleLoader__.load({
|
|
|
3807
3945
|
const submit = async () => {
|
|
3808
3946
|
setBusy(true); setErr(''); setMsg('')
|
|
3809
3947
|
try {
|
|
3810
|
-
|
|
3948
|
+
// 只把 { name, type, data } 发出去:size 是本机展示用的,服务端不需要
|
|
3949
|
+
const attachments = files.map((f) => ({ name: f.name, type: f.type, data: f.data }))
|
|
3950
|
+
const r = await callFeedback({ title, body: text, attachments })
|
|
3951
|
+
const attachNote = (r && Array.isArray(r.attachmentErrors) && r.attachmentErrors.length)
|
|
3952
|
+
? M(`;有附件没传上去:${r.attachmentErrors.join('、')}`, `; some attachments failed: ${r.attachmentErrors.join(', ')}`)
|
|
3953
|
+
: ''
|
|
3811
3954
|
if (r && r.needToken && r.fallbackUrl) {
|
|
3812
3955
|
// 没有令牌:把这单交给浏览器——预填好标题/正文/环境块,登录状态下点一下就建好了
|
|
3813
3956
|
try { window.open(r.fallbackUrl, '_blank', 'noopener') } catch { }
|
|
3814
|
-
|
|
3957
|
+
const pending = (r.pendingAttachments || []).length
|
|
3958
|
+
? M(
|
|
3959
|
+
`;附件(${(r.pendingAttachments || []).join('、')})没能上传,请在页面里手动拖进正文`,
|
|
3960
|
+
`; attachments (${(r.pendingAttachments || []).join(', ')}) were not uploaded — drag them into the body`,
|
|
3961
|
+
)
|
|
3962
|
+
: ''
|
|
3963
|
+
setMsg(M('没有令牌,已打开浏览器里的新建 issue 页面(标题和正文都填好了),点一下提交即可。', 'No token: opened the prefilled new-issue page in the browser - press submit there.') + pending + attachNote)
|
|
3964
|
+
setFiles([])
|
|
3815
3965
|
} else if (r && r.number) {
|
|
3816
|
-
|
|
3966
|
+
const n = (r.attachments || []).length
|
|
3967
|
+
setMsg(M(
|
|
3968
|
+
`已建 Issue #${r.number},列表里能看到,网页上也点得开。${n ? `(带了 ${n} 个附件)` : ''}`,
|
|
3969
|
+
`Issue #${r.number} created; it shows in the list and opens in the browser.${n ? ` (${n} attachment(s))` : ''}`,
|
|
3970
|
+
) + attachNote)
|
|
3817
3971
|
setTitle('')
|
|
3818
3972
|
setText('')
|
|
3973
|
+
setFiles([])
|
|
3819
3974
|
} else {
|
|
3975
|
+
const kept = (r && (r.attachments || []).length) ? M('(附件已上传,补发时会自动引用)', '(attachments uploaded; Flush will reference them)') : ''
|
|
3820
3976
|
setMsg(M(`没连上 GitHub(${(r && r.error) || '网络不通'}),已存进本机待发队列(${r ? r.remaining : 0} 条),联网后点「补发」。`,
|
|
3821
|
-
`Could not reach GitHub (${(r && r.error) || 'network'}). Saved to the local queue (${r ? r.remaining : 0} item(s)); press Flush when online.`))
|
|
3977
|
+
`Could not reach GitHub (${(r && r.error) || 'network'}). Saved to the local queue (${r ? r.remaining : 0} item(s)); press Flush when online.`) + kept + attachNote)
|
|
3978
|
+
if (!(r && (r.attachments || []).length)) setFiles([])
|
|
3822
3979
|
}
|
|
3823
3980
|
await load()
|
|
3824
3981
|
} catch (e) {
|
|
@@ -4028,6 +4185,37 @@ window.__ModuleLoader__.load({
|
|
|
4028
4185
|
onChange: (e) => setText(e.target.value),
|
|
4029
4186
|
}),
|
|
4030
4187
|
),
|
|
4188
|
+
// 0.6.48(issue #9):附件。截图 / 录屏是「界面不对」「同步报错」这类反馈里最关键的证据,
|
|
4189
|
+
// 以前只能靠打字描述。选完文件后读成 base64 跟提交一起发,服务端传到仓库资产、正文引用。
|
|
4190
|
+
h('div', { style: S.kvRow },
|
|
4191
|
+
h('div', { style: S.kvKey }, M('附件', 'Attachments')),
|
|
4192
|
+
h('div', { style: { ...S.kvVal, display: 'flex', flexDirection: 'column', gap: '6px' } },
|
|
4193
|
+
h('div', { style: { display: 'flex', gap: '8px', alignItems: 'center', flexWrap: 'wrap' } },
|
|
4194
|
+
h('input', {
|
|
4195
|
+
key: 'file', type: 'file', multiple: true, disabled: busy,
|
|
4196
|
+
accept: '.png,.jpg,.jpeg,.gif,.webp,.bmp,.svg,.mp4,.mov,.webm,.log,.txt,.md,.json',
|
|
4197
|
+
style: { fontSize: '12px' },
|
|
4198
|
+
onChange: (e) => { addFiles(e.target.files); try { e.target.value = '' } catch { } },
|
|
4199
|
+
}),
|
|
4200
|
+
h('span', { style: S.footnote }, M(
|
|
4201
|
+
`图片 / 视频 / 日志,最多 ${MAX_ATTACH} 个、每个 ${MAX_ATTACH_MB} MB`,
|
|
4202
|
+
`Images / videos / logs, up to ${MAX_ATTACH} files, ${MAX_ATTACH_MB} MB each`,
|
|
4203
|
+
)),
|
|
4204
|
+
),
|
|
4205
|
+
files.length
|
|
4206
|
+
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px' } },
|
|
4207
|
+
files.map((f, i) => h('div', { key: `${f.name}-${i}`, style: { display: 'flex', gap: '8px', alignItems: 'center', fontSize: '12px' } },
|
|
4208
|
+
h('span', { style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, f.name),
|
|
4209
|
+
h('span', { style: S.footnote }, `${Math.max(1, Math.round((f.size || 0) / 1024))} KB`),
|
|
4210
|
+
h('button', { type: 'button', style: S.btn, disabled: busy, onClick: () => removeFile(i) }, M('移除', 'Remove')),
|
|
4211
|
+
)))
|
|
4212
|
+
: null,
|
|
4213
|
+
h('div', { style: S.footnote }, M(
|
|
4214
|
+
'附件会作为 GitHub 资产上传到本反馈仓库,Issue 正文引用它:换机器、别人看都能打开,不依赖你本机的文件还在。没有令牌时附件传不上去,会提示手动拖进网页。',
|
|
4215
|
+
'Attachments are uploaded as assets of the feedback repo and referenced from the issue body: readable from any machine, no dependency on your local file. Without a token they cannot be uploaded, and you are told to drag them into the page.',
|
|
4216
|
+
)),
|
|
4217
|
+
),
|
|
4218
|
+
),
|
|
4031
4219
|
h('div', { style: S.actions },
|
|
4032
4220
|
h('button', { type: 'button', style: S.btnPrimary, disabled: busy || !title.trim(), onClick: submit },
|
|
4033
4221
|
busy ? M('提交中…', 'Submitting…') : M('提交到 GitHub', 'Submit to GitHub')),
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| 日期 | 版本 | 要点 |
|
|
6
6
|
|---|---|---|
|
|
7
|
+
| 2026-11-28 | 0.6.48 | **修 issue #7 / #8(第三方 WebDAV 连不上)与 #9(反馈带不了截图)**:① WebDAV 卡新增 **User-Agent** 输入项(#8)——部分第三方 DAV 按客户端名放行或拦截,没有这一项只能看到「连不上」。UA 留空 = **完全不发这个头**(实测 Node 的 `fetch` 永远自带 `node` 这个 UA、无法表达「不发」,所以传输层从 `fetch` 换成 `node:http`/`node:https`,自己处理重定向与 `Content-Length`;Windows PowerShell 与 macOS/Linux Node 引擎走同一个 `webdav.mjs`,行为一致)。UA 只接受单行可见 ASCII(≤ 200 字符、不含换行 / 中文 / 制表符),非法值保存时直接报错,不静默存成空。② 连不上时**按状态码分开说原因**(#7)——原来一律是「连不上或认证失败(PROPFIND 无响应)」;现在 401 / 403 / 404 / 405 / 重定向 / 超时 / 证书各有一句话并指出该改哪一项,「测试连接」还报出**实际发出去的 UA**。③ **问题反馈支持图片 / 视频 / 日志附件**(#9)——走 GitHub 的 release asset 接口传成反馈仓库自己的资产,正文引用(图片内联、视频与日志给链接),不借道第三方图床;asset 接口只有 release 有(Issue 没有),附件挂在草稿 release(tag `feedback-assets`)上;上限 4 个 / 单个 20 MB、类型白名单;不合格的逐条报错,**没有令牌时明确告知「附件没上传、请手动拖进网页」而不是静默丢弃**;建 Issue 失败时已上传的附件 URL 存进待发队列,补发时直接引用不重复上传。④ 顺带把 README 里「宿主挂 7 条路由」的陈旧数字改成实际的 13 条。验收:`tools/selftest.mjs` 374 条断言全绿(含 40 条新增)、`tools/clientcheck.mjs` 全绿;另有 6 条与本次改动无关的既有失败(需要真实远端与真实客户端安装目录的用例)改动前后完全一致。 |
|
|
7
8
|
| 2026-11-27 | 0.6.47 | **更新只查 npm + 在线安装**:更新检查整体换成 npm registry(dist-tags 定版本、单版本文档取 tarball/integrity、说明取包内 version.json),GitHub 四条清单源与「清单/令牌」设置退休;市场索引 source.type 改 npm;修「pnpm sha256 校验 npm 包必然失败」与「市场索引 publishTimestamp 用了毫秒导致 DSH 拒整个索引」两个真 bug。 |
|
|
8
9
|
| 2026-11-27 | 0.6.46 | **徽章数字接回计数**:不再手写「64 套 · 1065 条」,改由 finalize 从 `last-count.json` 生成(64 套 · 1061 条,与验收声明同口径)。 |
|
|
9
10
|
| 2026-11-27 | 0.6.45 | **文档对齐现实**:去掉「npm 上只到 0.4.1」的陈旧说法;发布命令块修掉版本号与包名自相矛盾;写清 `version.json` 不在 npm 包里。 |
|
package/docs/REFERENCE.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
| `index.js` | 宿主半身:`/config-sync/status`、`prepare`、`settings`、`auto`、`update`、`scope`、`extra-config`、`conflict` 路由 |
|
|
13
13
|
| `client.js` | 浏览器半身:侧栏行、面板、设置摘要行 |
|
|
14
14
|
| `cordis.patch.yml` | bundle 补丁层(`id: config-sync`) |
|
|
15
|
-
| `runtime/` | 执行体:7 个 PowerShell 脚本(`capture` / `apply` / `sync` / `restore` / `post-exit` / `common` / 自更新)+ Node 引擎 `sync-engine.mjs`(macOS/Linux)+ `webdav.mjs`(WebDAV
|
|
15
|
+
| `runtime/` | 执行体:7 个 PowerShell 脚本(`capture` / `apply` / `sync` / `restore` / `post-exit` / `common` / 自更新)+ Node 引擎 `sync-engine.mjs`(macOS/Linux)+ `conversations.mjs`(会话记录组)+ `webdav.mjs`(WebDAV 传输)+ `extra-rules.mjs`(插件数据 / 额外路径的规则,面板与引擎共用一份)+ `tools/`(会话 seq 护栏、cwd 修正等,随包发布) |
|
|
16
16
|
| `tools/` | `selftest.mjs`、`clientcheck.mjs`、`pack-plugin.ps1`(**只在源码仓库**,不进安装包) |
|
|
17
17
|
| `version.json` / `releases/` | 自更新清单与安装包(同样只在仓库) |
|
|
18
18
|
|
|
@@ -123,14 +123,16 @@ conversations/session-index.json conversations/session_projcache/s1.json
|
|
|
123
123
|
|
|
124
124
|
| 接口 | 说明 |
|
|
125
125
|
|---|---|
|
|
126
|
-
| `GET /config-sync/status` | 体检 JSON(`repo.*`(`source/configured/phase/empty/remoteHeads/remoteFiles/pushAllowed/pullAllowed`)、`remote.*`、`backup.*`、`local.{lastSyncAt,pending}`、`auto.lastResult`、`conflicts`、`localPaths`) |
|
|
126
|
+
| `GET /config-sync/status` | 体检 JSON(`repo.*`(`source/configured/phase/empty/remoteHeads/remoteFiles/pushAllowed/pullAllowed`)、`remote.*`、`backup.*`、`local.{lastSyncAt,pending}`、`auto.lastResult`、`auto.pullPrompt`、`auto.livePush`、`conflicts`、`localPaths`) |
|
|
127
127
|
| `POST /config-sync/prepare` | `{action:'push'\|'pull'\|'restore'\|'restore-backup'\|'all', message?, backupDir?}`;空目录上按云端文件数分流 |
|
|
128
128
|
| `POST /config-sync/settings` | 校验 → 写设置 →(地址变了才动 git),失败回滚并 400 |
|
|
129
|
-
| `POST /config-sync/auto` | `{action:'check'\|'pull-now'\|'push-now'\|'restore-preview'\|'restore-now'\|'cancel'}`,都不带 `/F`
|
|
129
|
+
| `POST /config-sync/auto` | `{action:'check'\|'pull-now'\|'push-now'\|'push-live'\|'restore-preview'\|'restore-now'\|'cancel'}`,都不带 `/F` 关闭客户端(走正常退出,配置能存下来)。`push-live` 是**不关闭 DSH** 的后台推送,进度走 `status.auto.livePush`(`phase` / `message` / `recent[]` / `log`);可选 `{confirmed:true}` 跳过宿主侧的确认框(只有面板会带,宿主对非面板调用仍走原生确认) |
|
|
130
130
|
| `GET/POST /config-sync/update` | `{action:'check'\|'install-live'\|'restart'\|'apply'}` |
|
|
131
131
|
| `GET/POST /config-sync/scope` | 十二组同步范围读写 |
|
|
132
132
|
| `GET/POST /config-sync/extra-config` | 规则读写(`{config:{pluginData:{enabled,maxFileBytes,exclude,skipDirs},extra:{enabled,paths[]}}}`,id 去重、路径必须绝对、上限按 100 MB 压;GET 另带 `defaults` 供「恢复默认」) |
|
|
133
133
|
| `GET/POST /config-sync/conflict` | GET 读清单(每项带 `localSaved`/`cloudSaved`);POST `{items:[{path,choice}]}` 存选择、`{action:'restore',path,side}` 单项还原、`{action:'reset'}` 放弃清单。还原按清单记录的 `repo` 路径写,改过 `repoPath` 也不会写错仓库 |
|
|
134
|
+
| `GET/POST /config-sync/webdav` | GET 回显当前配置(`url`/`user`/`dir`/`userAgent`/`mode`/`hasPassword`/`secure`)与连通性探测结果(`probe`,含 `error`、`status`、`userAgent`);POST `{action:'save'\|'test'\|'upload'\|'download', url?, user?, pass?, dir?, mode?, userAgent?}`。`userAgent` 非法(换行 / 非 ASCII / 超 200 字符)直接 400,不静默存成空 |
|
|
135
|
+
| `GET/POST/PATCH /config-sync/feedback` | GET 读 Issue 列表与连接状态;POST 提交(`{title, body, attachments?}`,附件为 `{name, type, data(base64)}`)、存令牌(`?action=token`)、补发队列(`?action=flush`);PATCH 改状态(`?number=`)。附件先传成仓库 release assets,再把 URL 引进正文 |
|
|
134
136
|
|
|
135
137
|
跨站请求 403。客户端只 `fetch` 这几条,不 import 任何 `@deepseek-ai/dsh-client-*`,样式只用 `--dsw-alias-*` token。
|
|
136
138
|
|
|
@@ -149,6 +151,29 @@ conversations/session-index.json conversations/session_projcache/s1.json
|
|
|
149
151
|
7. **断网不丢**:建 Issue 失败进 `config-sync-feedback-outbox.json`,联网后点「补发」逐条建,成功自动出队。
|
|
150
152
|
8. 列表头「未解决 / 已解决 / 全部」+ 搜索框(编号、标题、作者、正文、环境块都参与),筛选全在本地做,不占匿名限额。
|
|
151
153
|
|
|
154
|
+
## `dsh-config-sync.json` 里的 WebDAV 字段
|
|
155
|
+
|
|
156
|
+
本机私有设置文件 `~\.dsh\dsh-config-sync.json`(不进仓库,POSIX 上 0600):
|
|
157
|
+
|
|
158
|
+
| 字段 | 说明 |
|
|
159
|
+
|---|---|
|
|
160
|
+
| `syncMode` | `git`(默认)/ `webdav` / `auto`(配了 WebDAV 就用它) |
|
|
161
|
+
| `webdavUrl` | WebDAV 根地址(如 `https://dav.example.com/dav`) |
|
|
162
|
+
| `webdavUser` / `webdavPass` | Basic 认证账号与密码(密码永不明文回显到面板) |
|
|
163
|
+
| `webdavDir` | 远端子目录(相对根,默认 `dsh-config-sync`) |
|
|
164
|
+
| `webdavUserAgent` | **0.6.48 新增**:自定义 User-Agent。留空 = 完全不发这个头。只接受单行可见 ASCII(≤ 200 字符,不含换行 / 中文 / 制表符),非法值在保存时直接 400 |
|
|
165
|
+
|
|
166
|
+
Windows 的 PowerShell 与 macOS/Linux 的 Node 引擎都读这一份文件、都把整份传给 `runtime/webdav.mjs`,所以 UA 在两条路径上行为一致。
|
|
167
|
+
|
|
168
|
+
## 反馈附件的机制(0.6.48)
|
|
169
|
+
1. 面板选文件(图片 / 视频 / 日志,最多 4 个、单个 ≤ 20 MB),读成 base64 随提交一起发(该路由的请求体上限单独放宽到 160 MB,其余路由仍是 64 KB)。
|
|
170
|
+
2. 服务端先校验(类型白名单 / 体积 / 可读性),不合格的**逐条报错**,不静默丢弃。
|
|
171
|
+
3. GitHub 只有 **release** 有 asset 接口(Issue 没有),所以先按 tag `feedback-assets` 找 release;没有就建一个**草稿** release(`draft: true`,不出现在 Releases 页面、不会被搜索引擎收录,但知道链接的人打得开 —— 反馈附件本来就不该公开发布)。该 release 的 id 与 `upload_url` 在进程内缓存,一次反馈不会反复查。
|
|
172
|
+
4. 往 `upload_url` POST 原始字节:`{?name,label}` 整段被替换成 `?name=<文件名>`,`Content-Type` 给真实类型,`Content-Length` 给实际字节数。
|
|
173
|
+
5. 拿到的 `browser_download_url` 引进正文:图片用 ``,其它用 `- [name](url)`;环境块仍在最后一段。
|
|
174
|
+
6. **没有令牌时附件传不上去**:面板明确告知「附件没能上传,请手动拖进网页」,并在响应里带 `pendingAttachments`。
|
|
175
|
+
7. 建 Issue 失败但附件已传上去时,附件 URL 存进待发队列;「补发」直接引用,不重复上传(重复上传会在仓库里留下垃圾资产)。
|
|
176
|
+
|
|
152
177
|
## 卸载残留清理
|
|
153
178
|
|
|
154
179
|
宿主卸载插件时**不删 `profile\node_modules` 里那条 junction**。`apply.ps1` 每次落地巡检一遍,只删**三条同时成立**的链接:①`LinkType` 是 Junction/SymbolicLink;②所有 Target 都不存在;③不在 `package.json` 的 `dependencies` 里。用 `Directory.Delete` 只删链接本身、不顺着链接动目标。
|
|
@@ -162,6 +187,17 @@ conversations/session-index.json conversations/session_projcache/s1.json
|
|
|
162
187
|
|
|
163
188
|
## 自动同步的进程细节
|
|
164
189
|
|
|
190
|
+
**macOS / Linux(0.6.49 起)**:执行体是 `runtime/post-exit.mjs`(Node,替代 `post-exit.ps1`),安装是 `runtime/install-plugin.mjs`。
|
|
191
|
+
- 「客户端是否还在运行」按**可执行文件路径**匹配(`platform.mjs` 的 `listClientProcesses` / `clientProcessPattern`),
|
|
192
|
+
不按进程名 —— 执行体自己的命令行里就带着 `DeepSeek Harness.app/...` 路径,按名字会把等待进程和自己一起算进去。
|
|
193
|
+
- 重启客户端:macOS 用 `open -a <AppRoot>`,Linux 起解包目录里的可执行文件(`clientExecutable`)。
|
|
194
|
+
- 关闭客户端:先 `app.quit()`;不行再 `osascript -e 'tell application "DeepSeek Harness" to quit'`;6 秒后仍在才 `pkill -f <exe 路径>`。
|
|
195
|
+
- **启动时的自动拉取不再弹原生框**(osascript 的 `display dialog` 常被窗口挡住 → 用户看不见就等于永不发生):
|
|
196
|
+
只写 `status.auto.pullPrompt` 与 `~/.dsh/logs/auto-sync-pull-prompt.log`,由面板的「立即拉取」接手。
|
|
197
|
+
- 仓库路径会先 `realpath` 再和 `git rev-parse --show-toplevel` 比:`/var`、`/tmp` 指向 `/private/...`,只比字面量会把正常路径判成「不是仓库根」。
|
|
198
|
+
|
|
199
|
+
**Windows**:
|
|
200
|
+
|
|
165
201
|
- 动手由插件拉起 `runtime\post-exit.ps1 -Phase wait`(**隐藏**)盯退出;真退了才用 `-WindowStyle Normal` 起 `-Phase run` 的**可见**窗口,标题「DSH 配置备份与同步 · 拉取/推送」。**排队期间不弹窗**。
|
|
166
202
|
- 仓库还没就位(含空目录)时首检直接跳过,且不记成「检查失败」。
|
|
167
203
|
- **拉起方式**:`detached: true` 起 powershell 在 Windows 上会当场退出(日志一行都没有),改成短命 powershell 用 `Start-Process -PassThru` 起独立进程;`spawn()` 失败是异步的,所以要等 launcher 退出码、拿不到 pid 就如实失败,并写 `~\.dsh\logs\auto-sync-launch.log`。
|