dsh-profile-config-sync 0.5.0 → 0.6.40

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/client.js CHANGED
@@ -236,7 +236,10 @@ window.__ModuleLoader__.load({
236
236
  hint ? h('span', { style: { ...S.sectionHint, opacity: 0.75 } }, `· `) : null,
237
237
  hint ? h('div', { style: S.sectionHint }, hint) : null,
238
238
  ),
239
- h('div', { style: S.grid }, list),
239
+ // 用展开而不是把数组直接当 children:数组 children 会被 React 当成列表,
240
+ // 要求每一项都有 key(原来每区都在刷 "Each child in a list should have a unique key",
241
+ // 且报错位置指到 ConfigSyncPanel,很难对上号)。逐项展开就没有这个要求。
242
+ h('div', { style: S.grid }, ...list),
240
243
  )
241
244
  }
242
245
 
@@ -281,7 +284,20 @@ window.__ModuleLoader__.load({
281
284
  if (repo.ahead > 0) return { kind: 'warn', text: M(`本机有 ${repo.ahead} 个提交还没推送`, `${repo.ahead} local commit(s) not pushed yet`) }
282
285
  // git 干净不代表没东西要推:新会话/新资料还躺在 ~\.dsh 里,没 capture 之前仓库是完全干净的
283
286
  const local = data.local || {}
284
- if (local.known && local.pending > 0) {
287
+ // 三件不能混成一件事的:从没同步过 / 扫描没跑完 / 真的没有
288
+ if (local.known === false) return { kind: 'idle', text: M('还没有同步记录:先推送或拉取一次', 'No sync record yet — push or pull once') }
289
+ 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:执行体只抓 profile / 提示 / Skills / 预设,别让「没有待推送」被读成「全都同步了」
291
+ if (Array.isArray(local.engineGroups) && local.pending === 0) {
292
+ return {
293
+ kind: 'idle',
294
+ text: M(
295
+ `已同步(这台机器走跨平台引擎,只处理 ${local.engineGroups.join(' / ')};会话记录、插件数据、额外路径等组要 Windows 版才会同步)`,
296
+ `Up to date (this machine uses the cross-platform engine, which only handles ${local.engineGroups.join(' / ')}; conversations, plugin data and extra paths sync on Windows)`,
297
+ ),
298
+ }
299
+ }
300
+ if (local.pending > 0) {
285
301
  return {
286
302
  kind: 'warn',
287
303
  text: M(
@@ -346,15 +362,15 @@ window.__ModuleLoader__.load({
346
362
  throw new Error(M(`${reason}(已自动重试 3 次)`, `${reason} (retried 3 times)`))
347
363
  }
348
364
 
349
- /** 每个 POST 都带 accept-language:宿主的建议句/错误信息按它出中文或英文。 */
350
- const jsonHeaders = { 'content-type': 'application/json', ...langHeaders() }
365
+ /** 每个 POST 都现读 accept-language:用户切语言后不必重载模块,宿主错误信息也跟着走。 */
366
+ const jsonHeaders = () => ({ 'content-type': 'application/json', ...langHeaders() })
351
367
 
352
368
  async function callPrepare(action, message, backupDir) {
353
369
  const res = await fetch('/config-sync/prepare', {
354
370
  method: 'POST',
355
371
  cache: 'no-store',
356
372
  credentials: 'same-origin',
357
- headers: jsonHeaders,
373
+ headers: jsonHeaders(),
358
374
  body: JSON.stringify({ action, message: message || '', backupDir: backupDir || '' }),
359
375
  })
360
376
  const text = await res.text()
@@ -369,7 +385,7 @@ window.__ModuleLoader__.load({
369
385
  method: 'POST',
370
386
  cache: 'no-store',
371
387
  credentials: 'same-origin',
372
- headers: jsonHeaders,
388
+ headers: jsonHeaders(),
373
389
  body: JSON.stringify(payload),
374
390
  })
375
391
  const text = await res.text()
@@ -379,13 +395,13 @@ window.__ModuleLoader__.load({
379
395
  return body
380
396
  }
381
397
 
382
- /** 自动同步接口:check / pull-now / push-now / cancel。 */
398
+ /** 自动同步接口:check / pull-now / push-now / push-live / cancel。 */
383
399
  async function callAuto(payload) {
384
400
  const res = await fetch('/config-sync/auto', {
385
401
  method: 'POST',
386
402
  cache: 'no-store',
387
403
  credentials: 'same-origin',
388
- headers: jsonHeaders,
404
+ headers: jsonHeaders(),
389
405
  body: JSON.stringify(payload),
390
406
  })
391
407
  const text = await res.text()
@@ -405,7 +421,7 @@ window.__ModuleLoader__.load({
405
421
  method: 'POST',
406
422
  cache: 'no-store',
407
423
  credentials: 'same-origin',
408
- headers: jsonHeaders,
424
+ headers: jsonHeaders(),
409
425
  body: JSON.stringify(payload),
410
426
  }
411
427
  : { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
@@ -426,7 +442,7 @@ window.__ModuleLoader__.load({
426
442
  method: 'POST',
427
443
  cache: 'no-store',
428
444
  credentials: 'same-origin',
429
- headers: jsonHeaders,
445
+ headers: jsonHeaders(),
430
446
  body: JSON.stringify(payload),
431
447
  }
432
448
  : { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
@@ -447,7 +463,7 @@ window.__ModuleLoader__.load({
447
463
  method: 'POST',
448
464
  cache: 'no-store',
449
465
  credentials: 'same-origin',
450
- headers: jsonHeaders,
466
+ headers: jsonHeaders(),
451
467
  body: JSON.stringify(payload),
452
468
  }
453
469
  : { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
@@ -465,7 +481,7 @@ window.__ModuleLoader__.load({
465
481
  method: 'POST',
466
482
  cache: 'no-store',
467
483
  credentials: 'same-origin',
468
- headers: jsonHeaders,
484
+ headers: jsonHeaders(),
469
485
  body: JSON.stringify(payload),
470
486
  }
471
487
  : { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
@@ -483,7 +499,7 @@ window.__ModuleLoader__.load({
483
499
  method: 'POST',
484
500
  cache: 'no-store',
485
501
  credentials: 'same-origin',
486
- headers: jsonHeaders,
502
+ headers: jsonHeaders(),
487
503
  body: JSON.stringify(payload),
488
504
  }
489
505
  : { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
@@ -502,7 +518,7 @@ window.__ModuleLoader__.load({
502
518
  method,
503
519
  cache: 'no-store',
504
520
  credentials: 'same-origin',
505
- headers: payload ? jsonHeaders : langHeaders(),
521
+ headers: payload ? jsonHeaders() : langHeaders(),
506
522
  body: payload ? JSON.stringify(payload) : undefined,
507
523
  })
508
524
  const text = await res.text()
@@ -524,7 +540,7 @@ window.__ModuleLoader__.load({
524
540
  method: 'POST',
525
541
  cache: 'no-store',
526
542
  credentials: 'same-origin',
527
- headers: jsonHeaders,
543
+ headers: jsonHeaders(),
528
544
  body: JSON.stringify(payload),
529
545
  }
530
546
  : { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
@@ -541,18 +557,21 @@ window.__ModuleLoader__.load({
541
557
  const [busy, setBusy] = react.useState(false)
542
558
  const [made, setMade] = react.useState(null)
543
559
 
544
- const refresh = react.useCallback(async (done) => {
545
- setBusy(true)
546
- setErr('')
560
+ const refresh = react.useCallback(async (doneOrOpts, maybeOpts) => {
561
+ const done = typeof doneOrOpts === 'function' ? doneOrOpts : null
562
+ const opts = (typeof doneOrOpts === 'object' && doneOrOpts) ? doneOrOpts : (maybeOpts || {})
563
+ const silent = Boolean(opts && opts.silent)
564
+ if (!silent) setBusy(true)
565
+ if (!silent) setErr('')
547
566
  try {
548
567
  const d = await callStatus()
549
568
  setData(d)
550
- if (typeof done === 'function') done(null, d)
569
+ if (done) done(null, d)
551
570
  } catch (e) {
552
571
  const msg = String((e && e.message) || e)
553
- setErr(msg)
554
- if (typeof done === 'function') done(msg, null)
555
- } finally { setBusy(false) }
572
+ if (!silent) setErr(msg)
573
+ if (done) done(msg, null)
574
+ } finally { if (!silent) setBusy(false) }
556
575
  }, [])
557
576
 
558
577
  react.useEffect(() => {
@@ -678,7 +697,7 @@ window.__ModuleLoader__.load({
678
697
  return (async () => {
679
698
  const res = await fetch('/config-sync/webdav', {
680
699
  method: payload ? 'POST' : 'GET',
681
- headers: payload ? jsonHeaders : langHeaders(),
700
+ headers: payload ? jsonHeaders() : langHeaders(),
682
701
  body: payload ? JSON.stringify(payload) : undefined,
683
702
  })
684
703
  const text = await res.text()
@@ -689,40 +708,118 @@ window.__ModuleLoader__.load({
689
708
  })()
690
709
  }
691
710
 
692
- function WebdavCard(props) {
693
- const [st, setSt] = react.useState(null)
711
+ /**
712
+ * 云端仓库与同步方式卡(合并原「云端仓库」与「同步方式(WebDAV)」):
713
+ * - 先选同步模式:Git 仓库 / WebDAV / 自动(优先 WebDAV)
714
+ * - 按所选模式展开对应字段与操作,避免用 WebDAV 时还一直提示“先填 Git 远端地址”
715
+ */
716
+ function CloudTargetCard(props) {
717
+ const remote = (props.data && props.data.remote) || {}
718
+ const wdStatus = (props.data && props.data.webdav) || {}
719
+ const [wdFetched, setWdFetched] = react.useState(null)
720
+ const st = wdFetched || wdStatus
721
+ const currentMode = st.mode || wdStatus.mode || 'git'
722
+ const currentWdUrl = st.url || ''
723
+ const currentWdUser = st.user || ''
724
+ const currentWdDir = st.dir || ''
725
+ const currentGitUrl = remote.url || ''
726
+ const currentGitKey = remote.sshKey || ''
727
+
694
728
  const [editing, setEditing] = react.useState(false)
695
- const [url, setUrl] = react.useState('')
696
- const [user, setUser] = react.useState('')
697
- const [pass, setPass] = react.useState('')
698
- const [dir, setDir] = react.useState('')
699
- const [mode, setMode] = react.useState('git')
729
+ const [mode, setMode] = react.useState(currentMode)
730
+ const [wdUrl, setWdUrl] = react.useState(currentWdUrl)
731
+ const [wdUser, setWdUser] = react.useState(currentWdUser)
732
+ const [wdPass, setWdPass] = react.useState('')
733
+ const [wdDir, setWdDir] = react.useState(currentWdDir)
734
+ const [gitUrl, setGitUrl] = react.useState(currentGitUrl)
735
+ const [gitKey, setGitKey] = react.useState(currentGitKey)
700
736
  const [busy, setBusy] = react.useState(false)
701
737
  const [err, setErr] = react.useState('')
702
738
  const [msg, setMsg] = react.useState('')
703
739
 
704
- const load = react.useCallback(async () => {
740
+ const loadWebdav = react.useCallback(async () => {
705
741
  try {
706
742
  const r = await callWebdav()
707
- setSt(r)
708
- setUrl(r.url || ''); setUser(r.user || ''); setDir(r.dir || ''); setMode(r.mode || 'git')
709
- setPass('')
710
- } catch (e) { setErr(String((e && e.message) || e)) }
743
+ setWdFetched(r)
744
+ } catch { /* status 已带基础字段;不打断页面 */ }
711
745
  }, [])
712
- react.useEffect(() => { load() }, [])
746
+ react.useEffect(() => { loadWebdav() }, [])
747
+
748
+ react.useEffect(() => {
749
+ if (editing) return
750
+ setMode(currentMode)
751
+ setWdUrl(currentWdUrl)
752
+ setWdUser(currentWdUser)
753
+ setWdDir(currentWdDir)
754
+ setWdPass('')
755
+ setGitUrl(currentGitUrl)
756
+ setGitKey(currentGitKey)
757
+ }, [editing, currentMode, currentWdUrl, currentWdUser, currentWdDir, currentGitUrl, currentGitKey])
758
+
759
+ const activeMode = editing ? mode : currentMode
760
+ const wdConfigured = Boolean(st.configured || st.url)
761
+ const gitConfigured = Boolean(remote.configured || remote.url)
762
+ const missing = Boolean(props.data) && (
763
+ activeMode === 'webdav' ? !wdConfigured
764
+ : (activeMode === 'git' ? !gitConfigured : (!wdConfigured && !gitConfigured))
765
+ )
766
+ const isEditing = editing || (!wdConfigured && !gitConfigured && Boolean(props.data))
767
+
768
+ const sourceLabel = (s) => s === 'settings' ? M('本机设置', 'Machine settings')
769
+ : (s === 'git' ? M('git 配置', 'git config')
770
+ : (s === 'default' ? M('自动探测', 'Auto-detected') : M('未配置', 'Not set')))
771
+
772
+ const startEdit = () => {
773
+ setMode(currentMode)
774
+ setWdUrl(currentWdUrl)
775
+ setWdUser(currentWdUser)
776
+ setWdDir(currentWdDir)
777
+ setWdPass('')
778
+ setGitUrl(currentGitUrl)
779
+ setGitKey(currentGitKey)
780
+ setErr(''); setMsg(''); setEditing(true)
781
+ }
782
+ const cancelEdit = () => {
783
+ setMode(currentMode)
784
+ setWdUrl(currentWdUrl)
785
+ setWdUser(currentWdUser)
786
+ setWdDir(currentWdDir)
787
+ setWdPass('')
788
+ setGitUrl(currentGitUrl)
789
+ setGitKey(currentGitKey)
790
+ setEditing(false); setErr(''); setMsg('')
791
+ }
713
792
 
714
793
  const save = async () => {
715
794
  setBusy(true); setErr(''); setMsg('')
716
795
  try {
717
- // 密码留空 = 不改(避免把已有密码清空)
718
- await callWebdav({ action: 'save', url, user, dir, mode, pass })
719
- setEditing(false); setPass('')
720
- setMsg(M('已保存', 'Saved'))
721
- await load()
796
+ if (mode === 'webdav' && !wdUrl.trim()) {
797
+ throw new Error(M('请填写 WebDAV 地址', 'Enter a WebDAV URL'))
798
+ }
799
+ if (mode === 'git' && !gitUrl.trim()) {
800
+ throw new Error(M('请填写 Git 远端地址', 'Enter a Git remote URL'))
801
+ }
802
+ if (mode === 'auto' && !wdUrl.trim() && !gitUrl.trim()) {
803
+ throw new Error(M('自动模式下请至少填写 WebDAV 地址或 Git 远端地址', 'In Auto mode, provide at least a WebDAV URL or a Git remote URL'))
804
+ }
805
+ await callWebdav({ action: 'save', url: wdUrl, user: wdUser, dir: wdDir, mode, pass: wdPass })
806
+ let gitSet = false
807
+ const gitDirty = gitUrl.trim() !== currentGitUrl.trim() || gitKey.trim() !== currentGitKey.trim()
808
+ if (gitDirty && (gitUrl.trim() || currentGitUrl.trim() || gitKey.trim() || currentGitKey.trim())) {
809
+ const r = await callSettings({ remoteUrl: gitUrl, sshKey: gitKey })
810
+ gitSet = Boolean(r && r.gitRemoteSet)
811
+ }
812
+ setEditing(false); setWdPass('')
813
+ setMsg(M(
814
+ `已保存${gitSet ? ',并已更新本机 git origin' : ''}`,
815
+ `Saved${gitSet ? ' and updated local git origin' : ''}`,
816
+ ))
817
+ await loadWebdav()
722
818
  if (typeof props.onSaved === 'function') props.onSaved()
723
819
  } catch (e) { setErr(String((e && e.message) || e)) } finally { setBusy(false) }
724
820
  }
725
- const run = async (action) => {
821
+
822
+ const runWebdav = async (action) => {
726
823
  setBusy(true); setErr(''); setMsg('')
727
824
  try {
728
825
  const r = await callWebdav({ action })
@@ -738,7 +835,7 @@ window.__ModuleLoader__.load({
738
835
 
739
836
  const field = (label, value, onCh, ph, type) => h('div', { style: S.kvRow },
740
837
  h('div', { style: S.kvKey }, label),
741
- editing
838
+ isEditing
742
839
  ? h('input', {
743
840
  type: type || 'text', style: S.input, value, placeholder: ph, spellCheck: false,
744
841
  onChange: (e) => onCh(e.target.value),
@@ -747,63 +844,104 @@ window.__ModuleLoader__.load({
747
844
  value || M('(未设置)', '(not set)')),
748
845
  )
749
846
 
847
+ const modeText = currentMode === 'webdav'
848
+ ? M('WebDAV', 'WebDAV')
849
+ : (currentMode === 'auto'
850
+ ? (wdStatus.active ? M('自动(当前走 WebDAV)', 'Auto (using WebDAV)') : M('自动(当前走 Git)', 'Auto (using Git)'))
851
+ : M('Git 仓库', 'Git repo'))
852
+ const showWebdav = activeMode === 'webdav' || activeMode === 'auto'
853
+ const showGit = activeMode === 'git' || activeMode === 'auto'
854
+
750
855
  return h('div', { style: S.card },
751
856
  h('div', { style: S.cardHead },
752
- h('div', { style: S.cardTitle }, M('同步方式(WebDAV)', 'Sync via WebDAV')),
753
- editing
857
+ h('div', { style: S.cardTitle }, M('云端仓库与同步方式', 'Cloud repo & transport')),
858
+ isEditing && missing
859
+ ? h('div', { style: { ...S.hint, flex: 1 } }, M('先选择并填好云端目标才能生成推送/拉取', 'Configure the cloud target to enable push/pull'))
860
+ : null,
861
+ isEditing
754
862
  ? h('div', { style: S.actions },
755
- h('button', { type: 'button', style: S.btnPrimary, disabled: busy || !url.trim(), onClick: save }, busy ? M('保存中…', 'Saving…') : M('保存', 'Save')),
756
- h('button', { type: 'button', style: S.btn, disabled: busy, onClick: () => { setEditing(false); setErr(''); setMsg('') } }, M('取消', 'Cancel')),
863
+ h('button', { type: 'button', style: S.btnPrimary, disabled: busy, onClick: save }, busy ? M('保存中…', 'Saving…') : M('保存', 'Save')),
864
+ (!wdConfigured && !gitConfigured) ? null : h('button', { type: 'button', style: S.btn, disabled: busy, onClick: cancelEdit }, M('取消', 'Cancel')),
757
865
  )
758
866
  : h('div', { style: S.actions },
759
- h('button', { type: 'button', style: S.btn, disabled: busy, onClick: () => { setEditing(true); setErr(''); setMsg('') } }, M('修改', 'Edit')),
867
+ h('button', { type: 'button', style: S.btn, disabled: busy || !props.data, onClick: startEdit }, M('修改', 'Edit')),
760
868
  ),
761
869
  ),
762
- field(M('同步模式', 'Mode'), mode === 'webdav' ? M('WebDAV', 'WebDAV') : (mode === 'auto' ? M('自动(配了就用 WebDAV)', 'Auto (WebDAV when set)') : M('git', 'git')),
763
- setMode, ''),
764
- editing
870
+ isEditing
765
871
  ? h('div', { style: S.kvRow },
766
- h('div', { style: S.kvKey }, M('模式', 'Mode')),
872
+ h('div', { style: S.kvKey }, M('同步模式', 'Mode')),
767
873
  h('select', {
768
874
  style: S.input, value: mode,
769
875
  onChange: (e) => setMode(e.target.value),
770
876
  },
771
- h('option', { value: 'git' }, M('git(默认)', 'git (default)')),
877
+ h('option', { value: 'git' }, M('Git 仓库(默认)', 'Git repo (default)')),
772
878
  h('option', { value: 'webdav' }, M('WebDAV', 'WebDAV')),
773
- h('option', { value: 'auto' }, M('自动', 'Auto')),
879
+ h('option', { value: 'auto' }, M('自动(配了 WebDAV 就用,否则用 Git)', 'Auto (WebDAV when set, else Git)')),
774
880
  ))
881
+ : h(Kv, { k: M('同步模式', 'Mode'), v: modeText }),
882
+ showWebdav
883
+ ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px', paddingTop: activeMode === 'auto' ? '6px' : '0px', borderTop: activeMode === 'auto' ? '1px solid var(--dsw-alias-border-l1)' : 'none' } },
884
+ activeMode === 'auto' ? h('div', { style: { ...S.hint, fontWeight: 600 } }, M('WebDAV(优先)', 'WebDAV (primary)')) : null,
885
+ field(M('WebDAV 地址', 'WebDAV URL'), isEditing ? wdUrl : currentWdUrl, setWdUrl, 'https://dav.example.com/remote.php/dav/files/me'),
886
+ field(M('用户名', 'Username'), isEditing ? wdUser : currentWdUser, setWdUser, ''),
887
+ isEditing
888
+ ? h('div', { style: S.kvRow },
889
+ h('div', { style: S.kvKey }, M('密码', 'Password')),
890
+ h('input', {
891
+ type: 'password', style: S.input, value: wdPass,
892
+ placeholder: st.hasPassword ? M('已设置,留空表示不改', 'Set; leave blank to keep') : '',
893
+ spellCheck: false,
894
+ onChange: (e) => setWdPass(e.target.value),
895
+ }))
896
+ : h(Kv, {
897
+ k: M('密码', 'Password'),
898
+ v: st.hasPassword ? M('已设置(不回显)', 'set (not shown)') : M('未设置', 'not set'),
899
+ }),
900
+ field(M('远端目录', 'Remote dir'), isEditing ? wdDir : currentWdDir, setWdDir, 'dsh-config-sync'),
901
+ h(Kv, {
902
+ k: M('传输安全', 'Transport'),
903
+ v: (st.secure === false)
904
+ ? M('http 明文(有密码泄露风险)', 'http (credentials in clear text)')
905
+ : M('https', 'https'),
906
+ }),
907
+ h('div', { style: S.actions },
908
+ h('button', { type: 'button', style: S.btn, disabled: busy || isEditing || !wdConfigured, onClick: () => runWebdav('test') }, M('测试连接', 'Test')),
909
+ h('button', { type: 'button', style: S.btn, disabled: busy || isEditing || !wdConfigured, onClick: () => runWebdav('upload') }, M('立即上传', 'Upload now')),
910
+ h('button', { type: 'button', style: S.btn, disabled: busy || isEditing || !wdConfigured, onClick: () => runWebdav('download') }, M('立即下载', 'Download now')),
911
+ ),
912
+ h('div', { style: S.footnote }, M(
913
+ 'WebDAV 与 git 共用同一份仓库格式,只换传输层:上传不删云端多余文件(开启「同步内容 → 删除云端副本」时除外),下载不删本机多余文件;两边都有且不同时本机那份留底为 .conflict-<时间>。',
914
+ 'WebDAV reuses the same repo format and only swaps the transport: upload keeps extra cloud files (unless "Also delete the cloud copy" is on in Content), download keeps extra local files; when both differ the local copy is kept as .conflict-<time>.',
915
+ )),
916
+ )
917
+ : null,
918
+ showGit
919
+ ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px', paddingTop: activeMode === 'auto' ? '6px' : '0px', borderTop: activeMode === 'auto' ? '1px solid var(--dsw-alias-border-l1)' : 'none' } },
920
+ activeMode === 'auto' ? h('div', { style: { ...S.hint, fontWeight: 600 } }, M('Git 仓库(WebDAV 未配时备用)', 'Git repo (fallback)')) : null,
921
+ field(M('远端地址', 'Remote URL'), isEditing ? gitUrl : currentGitUrl, setGitUrl, 'git@<host>:you/dsh-config.git'),
922
+ field(M('SSH 私钥', 'SSH key'), isEditing ? gitKey : currentGitKey, setGitKey, M('C:\\Users\\你\\.ssh\\id_ed25519', 'C:\\Users\\you\\.ssh\\id_ed25519')),
923
+ h(Kv, {
924
+ k: M('私钥来源', 'Key source'),
925
+ v: `${sourceLabel(remote.sshKeyFrom)}${remote.sshKeyExists ? '' : M('(文件不存在)', ' (file missing)')}`,
926
+ }),
927
+ h(Kv, { k: M('地址来源', 'URL source'), v: sourceLabel(remote.urlSource) }),
928
+ h(Kv, { k: M('设置文件', 'Settings file'), v: remote.settingsPath || M('(未知)', '(unknown)') }),
929
+ h('div', { style: S.footnote }, M(
930
+ '远端地址支持任意 git 托管平台(Gitee / GitHub / GitLab / 自建 Gitea):'
931
+ + 'git@host:owner/repo.git、ssh://、https:// 三种写法都行;'
932
+ + '例:git@gitee.com:you/dsh-config.git、git@github.com:you/dsh-config.git、https://gitlab.com/you/dsh-config.git。'
933
+ + 'SSH 地址用私钥/ssh config 走认证,https 地址用 Git 凭据管理器里的账号或令牌。',
934
+ 'Any git host works (Gitee / GitHub / GitLab / self-hosted Gitea): '
935
+ + 'git@host:owner/repo.git, ssh:// and https:// are all accepted; '
936
+ + 'e.g. git@gitee.com:you/dsh-config.git, git@github.com:you/dsh-config.git, https://gitlab.com/you/dsh-config.git. '
937
+ + 'SSH URLs authenticate with the key or ssh config; https URLs use the account or token in Git Credential Manager.',
938
+ )),
939
+ h('div', { style: S.footnote }, M(
940
+ '只存私钥路径不存内容;保存远端地址会同步更新本机 git origin,git 失败则整套回滚。',
941
+ 'Only the key path is stored; saving also updates the local git origin, rolling everything back if git fails.',
942
+ )),
943
+ )
775
944
  : null,
776
- field(M('WebDAV 地址', 'WebDAV URL'), editing ? url : (st && st.url) || '', setUrl, 'https://dav.example.com/remote.php/dav/files/me'),
777
- field(M('用户名', 'Username'), editing ? user : (st && st.user) || '', setUser, ''),
778
- editing
779
- ? h('div', { style: S.kvRow },
780
- h('div', { style: S.kvKey }, M('密码', 'Password')),
781
- h('input', {
782
- type: 'password', style: S.input, value: pass,
783
- placeholder: (st && st.hasPassword) ? M('已设置,留空表示不改', 'Set; leave blank to keep') : '',
784
- spellCheck: false,
785
- onChange: (e) => setPass(e.target.value),
786
- }))
787
- : h(Kv, {
788
- k: M('密码', 'Password'),
789
- v: (st && st.hasPassword) ? M('已设置(不回显)', 'set (not shown)') : M('未设置', 'not set'),
790
- }),
791
- field(M('远端目录', 'Remote dir'), editing ? dir : (st && st.dir) || '', setDir, 'dsh-config-sync'),
792
- h(Kv, {
793
- k: M('传输安全', 'Transport'),
794
- v: (st && st.secure === false)
795
- ? M('http 明文(有密码泄露风险)', 'http (credentials in clear text)')
796
- : M('https', 'https'),
797
- }),
798
- h('div', { style: S.actions },
799
- h('button', { type: 'button', style: S.btn, disabled: busy || !(st && st.configured), onClick: () => run('test') }, M('测试连接', 'Test')),
800
- h('button', { type: 'button', style: S.btn, disabled: busy || !(st && st.configured), onClick: () => run('upload') }, M('立即上传', 'Upload now')),
801
- h('button', { type: 'button', style: S.btn, disabled: busy || !(st && st.configured), onClick: () => run('download') }, M('立即下载', 'Download now')),
802
- ),
803
- h('div', { style: S.footnote }, M(
804
- 'WebDAV 与 git 共用同一份仓库格式,只换传输层:上传不删云端多余文件,下载不删本机多余文件;两边都有且不同时本机那份留底为 .conflict-<时间>。',
805
- 'WebDAV reuses the same repo format and only swaps the transport: upload never deletes extra cloud files, download never deletes extra local files; when both differ the local copy is kept as .conflict-<time>.',
806
- )),
807
945
  err ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-error-primary)' } }, M(`失败:${err}`, `Failed: ${err}`)) : null,
808
946
  msg ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-success-primary)' } }, msg) : null,
809
947
  )
@@ -817,21 +955,21 @@ window.__ModuleLoader__.load({
817
955
  return { section: 'automation', label: M('前往初始化推送 →', 'Go to initialize push →') }
818
956
  }
819
957
  if (/连不上 WebDAV|Cannot reach WebDAV/i.test(s)) {
820
- return { section: 'platform', label: M('检查 WebDAV →', 'Check WebDAV →') }
958
+ return { section: 'targets', label: M('检查 WebDAV →', 'Check WebDAV →') }
821
959
  }
822
960
  if (/连不上云端|云端仓库地址|Cloud repo is not set|Cannot reach the cloud/i.test(s)) {
823
- return { section: webdavOn ? 'platform' : 'targets', label: webdavOn ? M('检查 WebDAV →', 'Check WebDAV →') : M('去配置云端 →', 'Go to cloud settings →') }
961
+ return { section: 'targets', label: webdavOn ? M('检查 WebDAV →', 'Check WebDAV →') : M('去配置云端 →', 'Go to cloud settings →') }
824
962
  }
825
963
  if (/拉取|run Pull|\bPull\b/i.test(s) && !/只允许拉取|only Pull is allowed/i.test(s)) {
826
964
  return { section: 'automation', label: M('前往立即拉取 →', 'Go to pull →') }
827
965
  }
828
966
  if (/只允许拉取|only Pull is allowed/i.test(s)) {
829
- return { section: webdavOn ? 'platform' : 'targets', label: webdavOn ? M('检查 WebDAV →', 'Check WebDAV →') : M('检查云端配置 →', 'Check cloud config →') }
967
+ return { section: 'targets', label: webdavOn ? M('检查 WebDAV →', 'Check WebDAV →') : M('检查云端配置 →', 'Check cloud config →') }
830
968
  }
831
969
  if (/推送|run Push|\bPush\b/i.test(s)) {
832
970
  return { section: 'automation', label: M('前往立即推送 →', 'Go to push →') }
833
971
  }
834
- if (/仓库路径|本机仓库|Repo path|repo directory is not set|Local repo/i.test(s)) {
972
+ if (/仓库路径|本机仓库|Repo path|repo directory is not set|Local repo|仓库目录|runnable sync script/i.test(s)) {
835
973
  return { section: 'targets', label: M('去设置仓库 →', 'Go to repo settings →') }
836
974
  }
837
975
  if (/客户端根目录|client root/i.test(s)) {
@@ -857,7 +995,7 @@ window.__ModuleLoader__.load({
857
995
  type: 'button',
858
996
  style: S.anchorBtn,
859
997
  title: M('点击直达对应操作区', 'Jump directly to this section'),
860
- onClick: () => onNav(target),
998
+ onClick: () => onNav(target.section, target),
861
999
  }, target.label)
862
1000
  : null,
863
1001
  )
@@ -1029,106 +1167,7 @@ window.__ModuleLoader__.load({
1029
1167
  )
1030
1168
  }
1031
1169
 
1032
- /**
1033
- * 云端仓库卡:远端地址 + SSH 私钥路径。
1034
- * 默认只读展示;点「修改」才变成可编辑,保存走 POST /config-sync/settings,
1035
- * 宿主那边会同时 git remote set-url,失败则回滚设置文件并回显错误。
1036
- */
1037
- function RemoteCard(props) {
1038
- const remote = (props.data && props.data.remote) || {}
1039
- // 没配过云端仓库 = 强制编辑态:不给「取消」,也不许就这么放着去生成推送/拉取
1040
- const missing = Boolean(props.data) && !remote.configured
1041
- const [editing, setEditing] = react.useState(false)
1042
- const [url, setUrl] = react.useState(remote.url || '')
1043
- const [key, setKey] = react.useState(remote.sshKey || '')
1044
- const [busy, setBusy] = react.useState(false)
1045
- const [err, setErr] = react.useState('')
1046
- const [msg, setMsg] = react.useState('')
1047
- const isEditing = editing || missing
1048
- const sourceLabel = (s) => s === 'settings' ? M('本机设置', 'Machine settings')
1049
- : (s === 'git' ? M('git 配置', 'git config')
1050
- : (s === 'default' ? M('自动探测', 'Auto-detected') : M('未配置', 'Not set')))
1051
-
1052
- const startEdit = () => {
1053
- setUrl(remote.url || '')
1054
- setKey(remote.sshKey || '')
1055
- setErr('')
1056
- setMsg('')
1057
- setEditing(true)
1058
- }
1059
- const cancelEdit = () => { setEditing(false); setErr(''); setMsg('') }
1060
- const save = async () => {
1061
- setBusy(true); setErr(''); setMsg('')
1062
- try {
1063
- const r = await callSettings({ remoteUrl: url, sshKey: key })
1064
- setMsg(M(
1065
- `已保存${r.gitRemoteSet ? ',并已更新本机 git origin' : ''}`,
1066
- `Saved${r.gitRemoteSet ? ' and updated the local git origin' : ''}`,
1067
- ))
1068
- setEditing(false)
1069
- if (typeof props.onSaved === 'function') props.onSaved()
1070
- } catch (e) {
1071
- setErr(String((e && e.message) || e))
1072
- } finally { setBusy(false) }
1073
- }
1074
-
1075
- const field = (label, value, onChange, placeholder) => h('div', { style: S.kvRow },
1076
- h('div', { style: S.kvKey }, label),
1077
- isEditing
1078
- ? h('input', {
1079
- type: 'text', style: S.input, value, placeholder, spellCheck: false,
1080
- onChange: (e) => onChange(e.target.value),
1081
- })
1082
- : h('div', { style: { ...S.kvVal, fontFamily: 'Consolas, ui-monospace, monospace' } }, value || M('(未配置)', '(not set)')),
1083
- )
1084
-
1085
- return h('div', { style: S.card },
1086
- h('div', { style: S.cardHead },
1087
- h('div', { style: S.cardTitle }, M('云端仓库', 'Cloud repo')),
1088
- isEditing && missing
1089
- ? h('div', { style: { ...S.hint, flex: 1 } }, M('先填远端地址才能生成推送/拉取', 'Set the remote URL to enable push/pull'))
1090
- : null,
1091
- isEditing
1092
- ? h('div', { style: S.actions },
1093
- h('button', { type: 'button', style: S.btnPrimary, disabled: busy || !url.trim(), onClick: save }, busy ? M('保存中…', 'Saving…') : M('保存', 'Save')),
1094
- missing ? null : h('button', { type: 'button', style: S.btn, disabled: busy, onClick: cancelEdit }, M('取消', 'Cancel')),
1095
- )
1096
- : h('div', { style: S.actions },
1097
- h('button', { type: 'button', style: S.btn, disabled: !props.data, onClick: startEdit }, M('修改', 'Edit')),
1098
- ),
1099
- ),
1100
- field(M('远端地址', 'Remote URL'), isEditing ? url : (remote.url || ''), setUrl, 'git@<host>:you/dsh-config.git'),
1101
- field(M('SSH 私钥', 'SSH key'), isEditing ? key : (remote.sshKey || ''), setKey, M('C:\\Users\\你\\.ssh\\id_ed25519', 'C:\\Users\\you\\.ssh\\id_ed25519')),
1102
- h(Kv, {
1103
- k: M('私钥来源', 'Key source'),
1104
- v: `${sourceLabel(remote.sshKeyFrom)}${remote.sshKeyExists ? '' : M('(文件不存在)', ' (file missing)')}`,
1105
- }),
1106
- h(Kv, { k: M('地址来源', 'URL source'), v: sourceLabel(remote.urlSource) }),
1107
- h(Kv, { k: M('设置文件', 'Settings file'), v: remote.settingsPath || M('(未知)', '(unknown)') }),
1108
- missing && !remote.sshKeyExists
1109
- ? h('div', { style: S.footnote }, M(
1110
- '私钥可留空:认证交给 .ssh\\config 或 Git 默认选择;填了才写进脚本的 GIT_SSH_COMMAND。',
1111
- 'The key is optional — auth falls back to .ssh\\config or Git defaults; fill it only to write GIT_SSH_COMMAND into scripts.',
1112
- ))
1113
- : null,
1114
- err ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-error-primary)' } }, M(`保存失败:${err}`, `Save failed: ${err}`)) : null,
1115
- msg ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-success-primary)' } }, msg) : null,
1116
- h('div', { style: S.footnote }, M(
1117
- '远端地址支持任意 git 托管平台(Gitee / GitHub / GitLab / 自建 Gitea):'
1118
- + 'git@host:owner/repo.git、ssh://、https:// 三种写法都行;'
1119
- + '例:git@gitee.com:you/dsh-config.git、git@github.com:you/dsh-config.git、https://gitlab.com/you/dsh-config.git。'
1120
- + 'SSH 地址用下面的私钥/ssh config 走认证,https 地址用 Git 凭据管理器里的账号或令牌。',
1121
- 'Any git host works (Gitee / GitHub / GitLab / self-hosted Gitea): '
1122
- + 'git@host:owner/repo.git, ssh:// and https:// are all accepted; '
1123
- + 'e.g. git@gitee.com:you/dsh-config.git, git@github.com:you/dsh-config.git, https://gitlab.com/you/dsh-config.git. '
1124
- + 'SSH URLs authenticate with the key or ssh config below; https URLs use the account or token in Git Credential Manager.',
1125
- )),
1126
- h('div', { style: S.footnote }, M(
1127
- '只存私钥路径不存内容;保存远端地址会同步更新本机 git origin,git 失败则整套回滚。',
1128
- 'Only the key path is stored; saving also updates the local git origin, rolling everything back if git fails.',
1129
- )),
1130
- )
1131
- }
1170
+ // RemoteCard 已合并进 CloudTargetCard(同步方式 + 云端目标统一在一张卡里)
1132
1171
 
1133
1172
  /**
1134
1173
  * 「还原备份」卡:先看备份目录在哪(默认 <DshHome>\backups,可改成别的绝对路径),
@@ -1339,7 +1378,7 @@ window.__ModuleLoader__.load({
1339
1378
  `动手前先整份备份当前位置到 ${pv.backupTo || 'backups\\<自动命名>'},不满意还能再退回来。`,
1340
1379
  `The current location is copied to ${pv.backupTo || 'backups\\<auto-named>'} first, so you can undo it.`,
1341
1380
  )),
1342
- h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warning-primary)' } }, M(
1381
+ h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warn-primary, #d97706)' } }, M(
1343
1382
  '确认后:客户端正常退出 → 弹出进度窗口执行 → 完成后自动重启客户端。',
1344
1383
  'After confirming: the client closes normally, a progress window runs it, then the client restarts automatically.',
1345
1384
  )),
@@ -1357,8 +1396,8 @@ window.__ModuleLoader__.load({
1357
1396
  },
1358
1397
  h('div', { style: { ...S.cardTitle, fontSize: '13px' } }, confirmTitle),
1359
1398
  h('div', { style: S.hint }, M(
1360
- `快照时间 ${when(confirm.snap.at)}(${rel(confirm.snap.at)})· ${confirm.snap.files || 0} 个文件 · ${size(confirm.snap.bytes)} · ${confirm.snap.plugins || 0} 个插件`,
1361
- `Snapshot ${when(confirm.snap.at)} (${rel(confirm.snap.at)}) · ${confirm.snap.files || 0} files · ${size(confirm.snap.bytes)} · ${confirm.snap.plugins || 0} plugins`,
1399
+ `快照时间 ${when(confirm.snap.at)}(${rel(confirm.snap.at)})· ${confirm.snap.plugins || 0} 个插件 · ${confirm.snap.bundles || 0} 个 bundle`,
1400
+ `Snapshot ${when(confirm.snap.at)} (${rel(confirm.snap.at)}) · ${confirm.snap.plugins || 0} plugins · ${confirm.snap.bundles || 0} bundles`,
1362
1401
  )),
1363
1402
  listBox(
1364
1403
  M(`将撤走 ${pvRemovePlugins.length} 个快照之后装上的插件`, `Removing ${pvRemovePlugins.length} plugin(s) installed after this snapshot`),
@@ -1380,7 +1419,7 @@ window.__ModuleLoader__.load({
1380
1419
  '动手前会把当前配置整份存到 backups\\manual-<时间戳>;撤走的东西另有 rollback 清单,随时能再还原回来。',
1381
1420
  'The current config is copied to backups\\manual-<timestamp> first, and everything removed is listed in a rollback manifest — both can be restored later.',
1382
1421
  )),
1383
- h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warning-primary)' } }, M(
1422
+ h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warn-primary, #d97706)' } }, M(
1384
1423
  '确认后:客户端正常退出 → 弹出进度窗口执行还原 → 完成后自动重启客户端。',
1385
1424
  'After confirming: the client closes normally, a progress window runs the restore, then the client restarts automatically.',
1386
1425
  )),
@@ -1403,7 +1442,7 @@ window.__ModuleLoader__.load({
1403
1442
  h('div', {
1404
1443
  style: { ...S.hint, fontFamily: 'Consolas, ui-monospace, monospace', wordBreak: 'break-all' },
1405
1444
  }, M(`备份位置:${manual.dir}`, `Backup path: ${manual.dir}`)),
1406
- h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warning-primary)' } }, M(
1445
+ h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warn-primary, #d97706)' } }, M(
1407
1446
  '这份备份认不出类型,自动还原不知道该写回哪,按下面三步手动拷:',
1408
1447
  'This backup cannot be classified, so there is no automatic target. Copy it by hand:',
1409
1448
  )),
@@ -1508,6 +1547,8 @@ window.__ModuleLoader__.load({
1508
1547
  const [busy, setBusy] = react.useState(false)
1509
1548
  const [err, setErr] = react.useState('')
1510
1549
  const [msg, setMsg] = react.useState('')
1550
+ // 「放弃清单」的二次确认态:一次点击就删掉整份清单与已做的逐项选择,太容易被误触
1551
+ const [armDiscard, setArmDiscard] = react.useState(false)
1511
1552
 
1512
1553
  const load = async () => {
1513
1554
  setBusy(true); setErr('')
@@ -1528,6 +1569,9 @@ window.__ModuleLoader__.load({
1528
1569
  h('div', { style: S.hint }, err
1529
1570
  ? M(`读取失败:${err}`, `Read failed: ${err}`)
1530
1571
  : M('正在读取冲突清单…', 'Loading conflicts…')),
1572
+ // 失败后没有重试入口的话,这张卡会一直钉在「读取失败」上:
1573
+ // 父层的「重新检测」只刷 /status,不会重拉这张卡。
1574
+ err ? h('button', { type: 'button', style: S.btn, disabled: busy, onClick: load }, M('重试', 'Retry')) : null,
1531
1575
  )
1532
1576
  }
1533
1577
  if (!state.exists) return null
@@ -1675,7 +1719,12 @@ window.__ModuleLoader__.load({
1675
1719
  h('button', { type: 'button', style: S.btn, disabled: busy, onClick: () => setAll('cloud') }, M('全部用云端', 'All cloud')),
1676
1720
  h('button', { type: 'button', style: S.btn, disabled: busy, onClick: () => setAll('local') }, M('全部用本机', 'All local')),
1677
1721
  h('button', { type: 'button', style: S.btnPrimary, disabled: busy, onClick: save }, busy ? M('保存中…', 'Saving…') : M('保存选择', 'Save')),
1678
- h('button', { type: 'button', style: S.btn, disabled: busy, onClick: discard }, M('放弃清单', 'Discard')),
1722
+ // 两段式:点一下就删掉整份清单(连同逐项选择),和旁边「保存选择」长得很像,
1723
+ // 误点等于白选一遍。第一次点只进入确认态,再点才真的删。
1724
+ h('button', {
1725
+ type: 'button', style: S.btn, disabled: busy,
1726
+ onClick: () => { if (!armDiscard) { setArmDiscard(true); return } setArmDiscard(false); discard() },
1727
+ }, armDiscard ? M('确认放弃?(点此删除清单)', 'Confirm discard (click again)') : M('放弃清单', 'Discard')),
1679
1728
  ),
1680
1729
  err ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-error-primary)' } }, M(`操作失败:${err}`, `Failed: ${err}`)) : null,
1681
1730
  msg ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-success-primary)' } }, msg) : null,
@@ -1794,7 +1843,8 @@ window.__ModuleLoader__.load({
1794
1843
  if (!data || !draft) {
1795
1844
  return h('div', { style: S.card },
1796
1845
  h('div', { style: S.cardTitle }, M('插件数据与额外路径', 'Plugin data & extra paths')),
1797
- h('div', { style: S.hint }, err ? M(`读取失败:${err}`, `Read failed: ${err}`) : M('正在读取规则…', 'Loading rules…')))
1846
+ h('div', { style: S.hint }, err ? M(`读取失败:${err}`, `Read failed: ${err}`) : M('正在读取规则…', 'Loading rules…')),
1847
+ err ? h('button', { type: 'button', style: S.btn, disabled: busy, onClick: load }, M('重试', 'Retry')) : null)
1798
1848
  }
1799
1849
 
1800
1850
  const hardMB = Math.round(data.hardMaxBytes / (1024 * 1024))
@@ -1845,6 +1895,18 @@ window.__ModuleLoader__.load({
1845
1895
  ),
1846
1896
 
1847
1897
  // 排除名单
1898
+ // 安全必需项补齐要让人看见:宿主会把 browser-profiles 这类条目补回生效名单,
1899
+ // 但不静默改用户的口径 —— 这里明确说「你的文件缺这几条,已按内置名单补齐」。
1900
+ (() => {
1901
+ const mm = data && data.config && data.config.pluginData && data.config.pluginData.missingMandatory
1902
+ if (!mm || (!(mm.skipDirs || []).length && !(mm.exclude || []).length)) return null
1903
+ const parts = [...(mm.skipDirs || []), ...(mm.exclude || [])].filter((v, i, a) => a.indexOf(v) === i)
1904
+ return h('div', { style: { ...S.footnote, marginTop: '6px', color: 'var(--dsw-alias-label-warn, #b45309)' } },
1905
+ M(
1906
+ `你的规则文件缺少安全必需项,已按内置名单补齐:${parts.join('、')}(这些是浏览器剖面/凭据库,删掉也不会同步;点保存会写回文件)`,
1907
+ `Your rules file was missing mandatory safety entries; they are restored: ${parts.join(', ')} (browser profiles / credential stores — never synced even if removed; saving writes them back).`,
1908
+ ))
1909
+ })(),
1848
1910
  h('div', { style: { display: 'flex', gap: '8px', alignItems: 'center', marginTop: '6px', flexWrap: 'wrap' } },
1849
1911
  h('div', { style: { fontSize: '12px' } }, M('排除名单(通配,一行一条)', 'Exclusions (wildcards, one per line)')),
1850
1912
  h('button', { type: 'button', style: S.btn, disabled: !editing || busy, onClick: resetExclude }, M('恢复默认', 'Restore defaults')),
@@ -1948,7 +2010,8 @@ window.__ModuleLoader__.load({
1948
2010
  if (!data || !data.available) {
1949
2011
  return h('div', { style: S.card },
1950
2012
  h('div', { style: S.cardTitle }, M('工作区显示状态', 'Workspace visibility')),
1951
- h('div', { style: S.hint }, err ? M('读取失败:' + err, 'Read failed: ' + err) : M('本机还没有工作区数据,DSH 初始化后可用。', 'No workspace data yet — available after DSH initializes.')))
2013
+ h('div', { style: S.hint }, err ? M('读取失败:' + err, 'Read failed: ' + err) : M('本机还没有工作区数据,DSH 初始化后可用。', 'No workspace data yet — available after DSH initializes.')),
2014
+ err ? h('button', { type: 'button', style: S.btn, disabled: busy, onClick: load }, M('重试', 'Retry')) : null)
1952
2015
  }
1953
2016
 
1954
2017
  const wss = data.workspaces || []
@@ -2044,9 +2107,9 @@ window.__ModuleLoader__.load({
2044
2107
  // 编辑态下用带词义的按钮文案(隐藏/显示,颜色区分),不再是一个孤零零的按钮。
2045
2108
  open
2046
2109
  ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px', marginTop: '6px', paddingLeft: '18px' } },
2047
- (w.sessions || []).length === 0
2110
+ (Array.isArray(w.sessions) ? w.sessions : []).length === 0
2048
2111
  ? h('div', { style: S.footnote }, M('这个工作区还没有会话。', 'No sessions in this workspace.'))
2049
- : w.sessions.map(s => h('div', {
2112
+ : (Array.isArray(w.sessions) ? w.sessions : []).map(s => h('div', {
2050
2113
  key: s.id,
2051
2114
  style: {
2052
2115
  display: 'flex', alignItems: 'center', gap: '8px', fontSize: '12px', lineHeight: '18px',
@@ -2156,6 +2219,7 @@ window.__ModuleLoader__.load({
2156
2219
  return h('div', { style: S.card },
2157
2220
  h('div', { style: S.cardTitle }, M('同步内容', 'Sync content')),
2158
2221
  h('div', { style: S.hint }, err ? M(`读取失败:${err}`, `Read failed: ${err}`) : M('正在读取同步范围…', 'Loading sync scope…')),
2222
+ err ? h('button', { type: 'button', style: S.btn, disabled: busy, onClick: load }, M('重试', 'Retry')) : null,
2159
2223
  )
2160
2224
  }
2161
2225
 
@@ -2203,6 +2267,7 @@ window.__ModuleLoader__.load({
2203
2267
  const groupOn = g.enabled !== false
2204
2268
  const canExpand = items.length > 0
2205
2269
  return h('div', {
2270
+ key: g.id,
2206
2271
  style: { borderTop: '1px solid var(--dsw-alias-border-l1)', paddingTop: '6px', paddingBottom: '2px' },
2207
2272
  },
2208
2273
  // 整行可点:点一下展开明细,再点收起(不再单独放「明细」按钮)
@@ -2248,6 +2313,7 @@ window.__ModuleLoader__.load({
2248
2313
  },
2249
2314
  },
2250
2315
  items.map((i) => h('label', {
2316
+ key: i.id,
2251
2317
  style: {
2252
2318
  display: 'flex', gap: '8px', alignItems: 'center', fontSize: '12px',
2253
2319
  cursor: editing ? 'pointer' : 'default', opacity: groupOn ? 1 : 0.6,
@@ -2292,6 +2358,8 @@ window.__ModuleLoader__.load({
2292
2358
  const [busy, setBusy] = react.useState('')
2293
2359
  const [err, setErr] = react.useState('')
2294
2360
  const [msg, setMsg] = react.useState('')
2361
+ const [liveLocal, setLiveLocal] = react.useState(null)
2362
+ const [nowTick, setNowTick] = react.useState(() => Date.now())
2295
2363
 
2296
2364
  const save = async (patch) => {
2297
2365
  setBusy('save'); setErr(''); setMsg('')
@@ -2304,14 +2372,31 @@ window.__ModuleLoader__.load({
2304
2372
 
2305
2373
  const act = async (action, extra) => {
2306
2374
  setBusy(action); setErr(''); setMsg('')
2375
+ if (action === 'push-live') {
2376
+ setLiveLocal({
2377
+ running: true,
2378
+ startedAt: Date.now(),
2379
+ finishedAt: 0,
2380
+ ok: null,
2381
+ phase: 'starting',
2382
+ message: initMode
2383
+ ? M('正在核对云端状态并启动初始化推送…', 'Checking cloud state and starting initialize push…')
2384
+ : M('正在核对云端状态并启动后台推送…', 'Checking cloud state and starting background push…'),
2385
+ recent: [],
2386
+ initPush: initMode,
2387
+ })
2388
+ }
2307
2389
  try {
2308
2390
  const res = await fetch('/config-sync/auto', {
2309
2391
  method: 'POST', cache: 'no-store', credentials: 'same-origin',
2310
- headers: jsonHeaders,
2392
+ headers: jsonHeaders(),
2311
2393
  body: JSON.stringify({ action, ...(extra || {}) }),
2312
2394
  })
2313
2395
  const text = await res.text()
2314
- const body = text ? JSON.parse(text) : null
2396
+ let body
2397
+ // 这一处原来是全文件唯一没有 try 的 JSON.parse:宿主代理回一页 HTML 错误时,
2398
+ // 用户看到的是 "Unexpected token '<'" 这种噪声,而不是「500 返回非 JSON」。
2399
+ try { body = text ? JSON.parse(text) : null } catch { throw badJson(res) }
2315
2400
  if (!res.ok || !body || body.ok !== true) throw new Error((body && body.error) || `${res.status}`)
2316
2401
  if (action === 'check') {
2317
2402
  const d = body.drift
@@ -2319,16 +2404,17 @@ window.__ModuleLoader__.load({
2319
2404
  ? M(`云端:落后 ${d.behind} 个提交,领先 ${d.ahead} 个提交`, `Cloud: ${d.behind} commit(s) behind, ${d.ahead} ahead`)
2320
2405
  : (body.error || M('读不到远端', 'Cannot read the remote')))
2321
2406
  } else if (action === 'push-live') {
2322
- setMsg(body.alreadyRunning
2323
- ? M('后台推送已在运行中,请稍候…', 'Live push is already running…')
2324
- : M('已开始后台推送(不关闭 DSH),进度与结果会在下方实时更新', 'Live push started in background (DSH stays open) — status updates below'))
2407
+ if (body.livePush) setLiveLocal(body.livePush)
2325
2408
  } else {
2326
2409
  setMsg(body.closeRequested
2327
2410
  ? M('已排队:客户端马上关闭,退出后执行;拉取完成后按设置自动重开', 'Queued: the client closes now and the sync runs after exit; it relaunches per your settings when pulling finishes')
2328
2411
  : M('已排队:退出 DSH 后自动执行', 'Queued: runs automatically after DSH exits'))
2329
2412
  }
2330
- if (typeof props.onSaved === 'function') props.onSaved()
2331
- } catch (e) { setErr(String((e && e.message) || e)) } finally { setBusy('') }
2413
+ if (typeof props.onSaved === 'function') props.onSaved(action === 'push-live' ? { silent: true } : undefined)
2414
+ } catch (e) {
2415
+ if (action === 'push-live') setLiveLocal(null)
2416
+ setErr(String((e && e.message) || e))
2417
+ } finally { setBusy('') }
2332
2418
  }
2333
2419
 
2334
2420
  const sw = (patchKey, stateKey, label, hintText) => {
@@ -2363,10 +2449,39 @@ window.__ModuleLoader__.load({
2363
2449
  }
2364
2450
 
2365
2451
  const pending = auto.pending
2366
- const livePush = auto.livePush || null
2452
+ const serverLive = auto.livePush || null
2453
+ const hasServerLive = Boolean(serverLive && (serverLive.running || serverLive.finishedAt))
2454
+ // 后端状态一旦到齐(或已有更新时间戳)就以真实状态为准,避免旧的乐观占位盖住真实进度
2455
+ const livePush = hasServerLive && (!liveLocal || serverLive.startedAt >= (liveLocal.startedAt || 0) - 2000)
2456
+ ? serverLive
2457
+ : (liveLocal || serverLive)
2367
2458
  const liveRunning = Boolean(livePush && livePush.running)
2459
+ react.useEffect(() => {
2460
+ if (!liveRunning) return undefined
2461
+ setNowTick(Date.now())
2462
+ const timer = setInterval(() => setNowTick(Date.now()), 1000)
2463
+ return () => clearInterval(timer)
2464
+ }, [liveRunning])
2465
+ react.useEffect(() => {
2466
+ if (hasServerLive && !serverLive.running && liveLocal) setLiveLocal(null)
2467
+ }, [hasServerLive, serverLive && serverLive.running, serverLive && serverLive.finishedAt])
2368
2468
  // 后台调度拿不到请求语言,宿主把原因中英各存一份,这里按当前界面语言挑
2369
2469
  const pendingReason = pending ? (langIsZh() ? (pending.reasonZh || pending.reason) : (pending.reasonEn || pending.reason)) : ''
2470
+ const liveSteps = (() => {
2471
+ if (!livePush) return []
2472
+ const isWebdav = livePush.transport === 'webdav' || Boolean(props.data && props.data.webdav && props.data.webdav.active)
2473
+ const base = []
2474
+ if (livePush.initPush) base.push({ key: 'init', label: M('初始化仓库', 'Init repo') })
2475
+ base.push({ key: 'capture', label: M('抓取配置', 'Capture') })
2476
+ if (!isWebdav) base.push({ key: 'commit', label: M('提交变更', 'Commit') })
2477
+ base.push({ key: 'upload', label: isWebdav ? M('上传 WebDAV', 'Upload WebDAV') : M('推送远端', 'Push remote') })
2478
+ return base
2479
+ })()
2480
+ const phaseRank = { starting: -1, init: 0, capture: 1, commit: 2, upload: 3, done: 99, error: -2 }
2481
+ const curRank = phaseRank[String((livePush && livePush.phase) || 'starting')] ?? -1
2482
+ const elapsedSec = (livePush && livePush.startedAt)
2483
+ ? Math.max(0, Math.floor(((livePush.finishedAt || nowTick) - livePush.startedAt) / 1000))
2484
+ : 0
2370
2485
  return h('div', { style: S.card },
2371
2486
  h('div', { style: S.cardHead },
2372
2487
  h('div', { style: S.cardTitle }, M('自动同步', 'Auto sync')),
@@ -2410,11 +2525,13 @@ window.__ModuleLoader__.load({
2410
2525
  ? M('不关闭 DSH 直接在后台抓配置并上传(只读本地配置,安全不打断当前对话)', 'Capture and push in background without closing DSH')
2411
2526
  : M('云端已有内容:本机还是空的,先拉取', 'The cloud already has content — pull first'),
2412
2527
  onClick: () => act('push-live'),
2413
- }, liveRunning
2414
- ? M('后台推送中…', 'Pushing in background…')
2415
- : (initMode
2416
- ? M('初始化推送(不关 DSH)', 'Initialize push (keep DSH open)')
2417
- : M('立即推送(不关 DSH)', 'Push now (keep DSH open)'))),
2528
+ }, busy === 'push-live'
2529
+ ? M('准备启动…', 'Starting…')
2530
+ : (liveRunning
2531
+ ? M('后台推送中…', 'Pushing in background…')
2532
+ : (initMode
2533
+ ? M('初始化推送(不关 DSH)', 'Initialize push (keep DSH open)')
2534
+ : M('立即推送(不关 DSH)', 'Push now (keep DSH open)')))),
2418
2535
  h('button', {
2419
2536
  type: 'button',
2420
2537
  style: (pushAllowed && !liveRunning) ? S.btn : { ...S.btn, opacity: 0.5, cursor: 'not-allowed' },
@@ -2431,7 +2548,8 @@ window.__ModuleLoader__.load({
2431
2548
  livePush && (livePush.running || livePush.finishedAt)
2432
2549
  ? h('div', {
2433
2550
  style: {
2434
- padding: '8px 10px', borderRadius: '8px', fontSize: '12px', lineHeight: '18px',
2551
+ padding: '9px 11px', borderRadius: '8px', fontSize: '12px', lineHeight: '18px',
2552
+ display: 'flex', flexDirection: 'column', gap: '6px',
2435
2553
  border: '1px solid ' + (livePush.running
2436
2554
  ? 'var(--dsw-alias-toast-action)'
2437
2555
  : (livePush.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)')),
@@ -2441,15 +2559,56 @@ window.__ModuleLoader__.load({
2441
2559
  : (livePush.ok ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-state-error-primary)'),
2442
2560
  },
2443
2561
  },
2444
- h('div', { style: { fontWeight: 600 } },
2445
- (livePush.running ? '⏳ ' : (livePush.ok ? '✓ ' : '✕ ')) + (livePush.message || '')),
2562
+ h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px', flexWrap: 'wrap' } },
2563
+ h('div', { style: { fontWeight: 600 } },
2564
+ (livePush.running ? '⏳ ' : (livePush.ok ? '✓ ' : '✕ ')) + (livePush.message || '')),
2565
+ h('div', { style: { ...S.footnote, fontFamily: 'Consolas, ui-monospace, monospace' } },
2566
+ livePush.running
2567
+ ? M(`已耗时 ${elapsedSec}s`, `${elapsedSec}s elapsed`)
2568
+ : M(`耗时 ${elapsedSec}s`, `${elapsedSec}s`)),
2569
+ ),
2570
+ liveSteps.length
2571
+ ? h('div', { style: { display: 'flex', gap: '6px', flexWrap: 'wrap', alignItems: 'center' } },
2572
+ liveSteps.map((st, idx) => {
2573
+ const stRank = phaseRank[st.key] ?? idx
2574
+ const done = livePush.phase === 'done' || (curRank > stRank && curRank >= 0)
2575
+ const active = livePush.running && curRank === stRank
2576
+ const failed = !livePush.running && livePush.ok === false && curRank === stRank
2577
+ return h('span', {
2578
+ key: st.key,
2579
+ style: {
2580
+ ...S.chip,
2581
+ border: '1px solid ' + (active
2582
+ ? 'var(--dsw-alias-toast-action)'
2583
+ : (done
2584
+ ? 'var(--dsw-alias-state-success-primary)'
2585
+ : (failed ? 'var(--dsw-alias-state-error-primary)' : 'var(--dsw-alias-border-l1)'))),
2586
+ background: done
2587
+ ? 'var(--dsw-alias-state-success-tertiary)'
2588
+ : (failed ? 'var(--dsw-alias-state-error-tertiary, var(--dsw-alias-file-diff-deleted-bg))' : 'var(--dsw-alias-bg-base)'),
2589
+ color: active
2590
+ ? 'var(--dsw-alias-toast-action)'
2591
+ : (done ? 'var(--dsw-alias-label-primary)' : 'var(--dsw-alias-label-secondary)'),
2592
+ fontWeight: active ? 600 : 500,
2593
+ },
2594
+ }, `${done ? '✓ ' : (active ? '▸ ' : (failed ? '✕ ' : ''))}${idx + 1}. ${st.label}`)
2595
+ }))
2596
+ : null,
2597
+ (livePush.running || livePush.ok === false) && Array.isArray(livePush.recent) && livePush.recent.length
2598
+ ? h('div', {
2599
+ style: {
2600
+ ...S.code, padding: '6px 8px', fontSize: '11px', lineHeight: '16px',
2601
+ maxHeight: '96px', overflowY: 'auto',
2602
+ },
2603
+ }, livePush.recent.join('\n'))
2604
+ : null,
2446
2605
  livePush.finishedAt
2447
- ? h('div', { style: { ...S.footnote, marginTop: '2px' } },
2606
+ ? h('div', { style: S.footnote },
2448
2607
  M(`完成时间:${new Date(livePush.finishedAt).toLocaleTimeString(localeNow(), { hour12: false })}`,
2449
2608
  `Finished at: ${new Date(livePush.finishedAt).toLocaleTimeString(localeNow(), { hour12: false })}`)
2450
2609
  + (livePush.log ? ` · ${livePush.log}` : ''))
2451
2610
  : (livePush.log
2452
- ? h('div', { style: { ...S.footnote, marginTop: '2px' } }, M(`日志:${livePush.log}`, `Log: ${livePush.log}`))
2611
+ ? h('div', { style: S.footnote }, M(`日志:${livePush.log}`, `Log: ${livePush.log}`))
2453
2612
  : null),
2454
2613
  )
2455
2614
  : null,
@@ -2691,12 +2850,24 @@ window.__ModuleLoader__.load({
2691
2850
  setUpdBusy(true)
2692
2851
  setUpdMsg(M('DSH 即将退出,退出后安装并自动重启…', 'DSH will exit; the package is installed afterwards and DSH relaunches…'))
2693
2852
  try {
2694
- await callUpdate({ action: 'install-restart' })
2695
- showToast(M('DSH 即将退出并自动安装、重启…', 'DSH will exit, install, and relaunch…'))
2853
+ const r = await callUpdate({ action: 'install-restart' })
2854
+ // closeRequested=false 说明后端没能让客户端退出(taskkill 被拦 / app.quit 被模态框挡住),
2855
+ // 这时再喊「马上退出」就是骗人:安装要等到真的退出之后才会发生。
2856
+ if (r && r.closeRequested === false) {
2857
+ setUpdMsg(M('已排队:没能让客户端自动退出,请手动完全退出 DSH,退出后会自动安装并重启',
2858
+ 'Queued: the client did not exit automatically. Quit DSH fully; the install and relaunch run afterwards.'))
2859
+ showToast(M('已排队:请手动退出 DSH(窗口 + 托盘),退出后自动安装并重启',
2860
+ 'Queued: quit DSH fully (window and tray); install and relaunch run afterwards.'))
2861
+ } else {
2862
+ showToast(M('DSH 即将退出并自动安装、重启…', 'DSH will exit, install, and relaunch…'))
2863
+ }
2696
2864
  } catch (e) {
2697
2865
  const msg = String((e && e.message) || e)
2698
2866
  setUpdMsg(M('安装失败:', 'Install failed: ') + msg)
2699
2867
  showToast(M('安装失败:', 'Install failed: ') + msg)
2868
+ } finally {
2869
+ // 必须复位:退出没真的发生时(上面 closeRequested=false 就是这种),
2870
+ // 卡上 7 个按钮会全部 disabled 且本会话内没有复位入口。
2700
2871
  setUpdBusy(false)
2701
2872
  }
2702
2873
  }
@@ -2768,7 +2939,9 @@ window.__ModuleLoader__.load({
2768
2939
  await callAuto({ action: 'check' })
2769
2940
  } catch { /* 检查失败不该挡住页面,状态行会显示失败原因 */ }
2770
2941
  if (alive) setChecking(false)
2771
- if (alive && typeof refresh === 'function') refresh()
2942
+ // 静默刷新:这里是每 2 分钟的自动复查。用非静默的 refresh() 会把整页 busy 置真
2943
+ //(按钮周期性变灰),网络抖动时还会把「读取失败」写进页面,而 data 明明是有效的。
2944
+ if (alive && typeof refresh === 'function') refresh({ silent: true })
2772
2945
  }
2773
2946
  run()
2774
2947
  const timer = setInterval(run, 2 * 60 * 1000)
@@ -2777,14 +2950,22 @@ window.__ModuleLoader__.load({
2777
2950
 
2778
2951
  const lastLiveFinishedRef = react.useRef(0)
2779
2952
 
2780
- const jumpToSection = (sid, opts) => {
2953
+ const jumpToSection = (sidOrTarget, opts) => {
2954
+ const sid = (sidOrTarget && typeof sidOrTarget === 'object') ? sidOrTarget.section : sidOrTarget
2955
+ const options = (sidOrTarget && typeof sidOrTarget === 'object') ? sidOrTarget : opts
2781
2956
  if (!sid) return
2782
- if (opts && opts.openRoots && !showRoots) setShowRoots(true)
2957
+ if (options && options.openRoots && !showRoots) setShowRoots(true)
2783
2958
  setActiveSection(sid)
2784
2959
  const scrollNow = () => {
2785
2960
  const el = document.getElementById('sync-section-' + sid)
2786
- if (!el || !el.scrollIntoView) return
2787
- el.scrollIntoView({ behavior: 'smooth', block: 'start' })
2961
+ if (!el) return
2962
+ const body = bodyRef && bodyRef.current
2963
+ if (body && typeof body.scrollTo === 'function') {
2964
+ const top = el.getBoundingClientRect().top - body.getBoundingClientRect().top + body.scrollTop - 8
2965
+ body.scrollTo({ top: Math.max(0, top), behavior: 'smooth' })
2966
+ } else if (typeof el.scrollIntoView === 'function') {
2967
+ el.scrollIntoView({ behavior: 'smooth', block: 'start' })
2968
+ }
2788
2969
  try {
2789
2970
  if (typeof el.animate === 'function') {
2790
2971
  el.animate([
@@ -2794,21 +2975,34 @@ window.__ModuleLoader__.load({
2794
2975
  }
2795
2976
  } catch { }
2796
2977
  }
2797
- if (opts && opts.openRoots && !showRoots) {
2978
+ if (options && options.openRoots && !showRoots) {
2798
2979
  setTimeout(scrollNow, 60)
2799
2980
  } else {
2800
2981
  scrollNow()
2801
2982
  }
2802
2983
  }
2803
2984
 
2804
- // 后台在线推送进行中时,每 1.5s 轮询状态直到结束,并弹出完成/失败提示
2805
2985
  const liveRunning = Boolean(data && data.auto && data.auto.livePush && data.auto.livePush.running)
2986
+ // 后台在线推送进行中时,每 800ms 静默轮询状态直到结束,并弹出完成/失败提示。
2987
+ // 用「自调度 setTimeout + in-flight 门闩」而不是 setInterval:/status 要跑备份枚举与本机待推送统计,
2988
+ // 推送期间经常超过 800ms,setInterval 会让请求不断叠加(失败还要退避重试,越叠越多)。
2806
2989
  react.useEffect(() => {
2807
2990
  if (!liveRunning) return undefined
2808
- const timer = setInterval(() => {
2809
- if (typeof refresh === 'function') refresh()
2810
- }, 1500)
2811
- return () => clearInterval(timer)
2991
+ let alive = true
2992
+ let pending = false
2993
+ let timer = null
2994
+ const tick = async () => {
2995
+ if (!alive) return
2996
+ if (!pending) {
2997
+ pending = true
2998
+ try {
2999
+ if (typeof refresh === 'function') await refresh({ silent: true })
3000
+ } catch { /* 静默轮询失败不影响页面 */ } finally { pending = false }
3001
+ }
3002
+ if (alive) timer = setTimeout(tick, 800)
3003
+ }
3004
+ timer = setTimeout(tick, 800)
3005
+ return () => { alive = false; if (timer) clearTimeout(timer) }
2812
3006
  }, [liveRunning])
2813
3007
 
2814
3008
  react.useEffect(() => {
@@ -2889,9 +3083,11 @@ window.__ModuleLoader__.load({
2889
3083
  const failed = !has && u.ok === false && !restartRequired
2890
3084
  const kind = (restartRequired || preparedReady || has) ? 'warn' : (failed ? 'error' : 'ok')
2891
3085
  const notesText = (u.remote && (langIsZh() ? (u.remote.notes || u.remote.notesEn) : (u.remote.notesEn || u.remote.notes))) || ''
2892
- // 检查失败时把每个源的失败原因摆出来,别只给一句 aborted
3086
+ // 检查失败时仅在 error 尚未带明细时补充 sourceNote,避免把各源报错打印两遍
2893
3087
  const badSources = (Array.isArray(u.sources) ? u.sources : []).filter((x) => x && x.ok === false)
2894
- const sourceNote = badSources.length
3088
+ const errText = String(u.error || '')
3089
+ const alreadyDetailed = badSources.length > 0 && badSources.some((x) => errText.includes(x.host || x.url || ''))
3090
+ const sourceNote = (badSources.length && !alreadyDetailed)
2895
3091
  ? M(
2896
3092
  `(${badSources.map((x) => `${x.host || x.url}: ${x.error || '失败'}`).join(';')})`,
2897
3093
  ` (${badSources.map((x) => `${x.host || x.url}: ${x.error || 'failed'}`).join('; ')})`,
@@ -2966,15 +3162,15 @@ window.__ModuleLoader__.load({
2966
3162
  h('input', {
2967
3163
  type: 'text', style: S.input, value: updToken, spellCheck: false,
2968
3164
  placeholder: cfg.tokenSet
2969
- ? M('已配置;留空表示不改', 'Already set; leave empty to keep it')
2970
- : M('Gitee 私人令牌(私有库必填)', 'Gitee personal token (required for private repos)'),
3165
+ ? M('已配置;留空表示不改(支持 $GITHUB_TOKEN 读取环境变量)', 'Already set; leave empty to keep (or enter $GITHUB_TOKEN for env var)')
3166
+ : M('GitHub / Gitee 令牌,或填 $GITHUB_TOKEN 读取本机环境变量', 'GitHub / Gitee token, or $GITHUB_TOKEN to read from env'),
2971
3167
  onChange: (e) => setUpdToken(e.target.value),
2972
3168
  }),
2973
3169
  ),
2974
3170
  h('div', { style: S.actions },
2975
3171
  h('button', { type: 'button', style: S.btnPrimary, disabled: updBusy, onClick: saveUpdConfig }, updBusy ? M('保存中…', 'Saving…') : M('保存', 'Save')),
2976
3172
  h('button', { type: 'button', style: S.btn, disabled: updBusy, onClick: cancelEditUpd }, M('取消', 'Cancel')),
2977
- cfg.tokenSet
3173
+ cfg.tokenSaved
2978
3174
  ? h('button', { type: 'button', style: S.btn, disabled: updBusy, onClick: clearUpdToken }, M('清除已存令牌', 'Clear stored token'))
2979
3175
  : null,
2980
3176
  ),
@@ -2983,7 +3179,7 @@ window.__ModuleLoader__.load({
2983
3179
  h(Kv, {
2984
3180
  k: M('更新清单', 'Manifest'),
2985
3181
  v: cfg.manifestUrlIsDefault
2986
- ? M('内置默认(jsDelivr → GitHub raw 依次尝试)', 'Built-in default (jsDelivr → GitHub raw in order)')
3182
+ ? M('内置默认(GitHub API / gh-proxy / ghfast / GitHub raw 依次尝试)', 'Built-in default (GitHub API / gh-proxy / ghfast / GitHub raw in order)')
2987
3183
  : (cfg.manifestUrl || '…'),
2988
3184
  }),
2989
3185
  h(Kv, {
@@ -2994,9 +3190,15 @@ window.__ModuleLoader__.load({
2994
3190
  }),
2995
3191
  h(Kv, {
2996
3192
  k: M('更新令牌', 'Token'),
2997
- v: cfg.tokenSet
2998
- ? M('已配置(只存本机)', 'Set (stored on this machine only)')
2999
- : M('未配置(私有库会读不到清单)', 'Not set (private repos cannot be read)'),
3193
+ v: cfg.tokenSource === 'env' && cfg.tokenEnv
3194
+ ? M(`已从环境变量 ${cfg.tokenEnv} 读取(不落盘、绝不推送)`, `From env var ${cfg.tokenEnv} (not stored, never pushed)`)
3195
+ : cfg.tokenSource === 'git-credential'
3196
+ ? M('已从本机 git 凭据自动读取(不落盘、绝不推送)', 'From local git credential (not stored, never pushed)')
3197
+ : cfg.tokenSource === 'gh-cli'
3198
+ ? M('已从 GitHub CLI (gh) 自动读取(不落盘、绝不推送)', 'From GitHub CLI (gh) (not stored, never pushed)')
3199
+ : cfg.tokenSet
3200
+ ? M('已配置(仅存本机,绝不推送)', 'Set (local only, never pushed)')
3201
+ : M('未配置(公开库可不填;私有库可用本机 GitHub 登录、$GITHUB_TOKEN 或填入令牌)', 'Not set (optional for public repos; private repos use local GitHub login, $GITHUB_TOKEN, or a token)'),
3000
3202
  }),
3001
3203
  u.remote && u.remote.npmTgzUrls && u.remote.npmTgzUrls.length
3002
3204
  ? h(Kv, {
@@ -3204,11 +3406,9 @@ window.__ModuleLoader__.load({
3204
3406
  )
3205
3407
 
3206
3408
  const workspaceViewCard = h(WorkspaceViewCard, {})
3207
- const remoteCard = data ? h(RemoteCard, { data, onSaved: refresh }) : null
3409
+ const cloudCard = data ? h(CloudTargetCard, { data, onSaved: refresh }) : null
3208
3410
  const autoCard = data ? h(AutoCard, { data, onSaved: refresh }) : null
3209
- // 0.4.0:跨端状态卡(只读)与 WebDAV 同步方式卡
3210
3411
  const platformCard = h(PlatformCard, { data })
3211
- const webdavCard = h(WebdavCard, { onSaved: refresh })
3212
3412
  // 「还原备份」自己拿 status 里的 backup 段(快照列表),改动后让父层 refresh 重新读
3213
3413
  const restoreCard = data ? h(RestoreCard, { data, onSaved: refresh }) : null
3214
3414
  // 「同步内容」卡自己拉 /config-sync/scope,不依赖 status(status 读的是仓库与本机,跟勾选无关)
@@ -3232,7 +3432,7 @@ window.__ModuleLoader__.load({
3232
3432
  h('div', { ref: headerRef, style: S.pageHeader },
3233
3433
  h('div', { style: S.pageHeaderMain },
3234
3434
  h('div', { style: S.pageTitleRow },
3235
- h('div', { style: S.pageTitle }, M('配置同步', 'Config Sync')),
3435
+ h('div', { style: S.pageTitle }, M('配置备份与同步', 'Config Backup & Sync')),
3236
3436
  h('div', { style: S.badgeGroup },
3237
3437
  h('span', { style: S.badgeKey }, M('本机', 'local')),
3238
3438
  h('span', { style: chipStyle(summary.kind) }, chipLabel(summary.kind)),
@@ -3256,8 +3456,8 @@ window.__ModuleLoader__.load({
3256
3456
  ] : h('span', null, summary.text),
3257
3457
  ),
3258
3458
  h('div', { style: S.pageLead },
3259
- M('配置在本机、仓库、云端之间流转。改完立即生效;写回与还原在退出客户端后执行。',
3260
- 'Configs flow between this machine, the repo and the cloud. Edits apply at once; write-back and restore run after the client quits.')),
3459
+ M('多端配置备份、同步与还原:本机 → 仓库 → 云端 → 另一台机器。改完立即生效;写回与还原在退出客户端后执行。',
3460
+ 'Multi-device backup, sync and restore: this machine → repo → cloud → another machine. Edits apply at once; write-back and restore run after the client quits.')),
3261
3461
  ),
3262
3462
  h('div', { style: S.headerActions },
3263
3463
  // 「本机路径」区唯一的入口:平时普通按钮,只有根外路径/被覆盖这两类告警才变橙并带数字
@@ -3285,7 +3485,7 @@ window.__ModuleLoader__.load({
3285
3485
  ...(conflictCard ? [['conflict', M('同步冲突', 'Sync conflicts')]] : []),
3286
3486
  ...(showRoots ? [['roots', M('本机路径', 'Local paths')]] : []),
3287
3487
  ['targets', M('同步目标', 'Targets')],
3288
- ['platform', M('跨端/传输', 'Platform')],
3488
+ ['platform', M('跨端状态', 'Platform')],
3289
3489
  ['automation', M('自动化', 'Automation')],
3290
3490
  ['actions', M('生成脚本', 'Scripts')],
3291
3491
  ['restore', M('还原备份', 'Restore')],
@@ -3336,9 +3536,8 @@ window.__ModuleLoader__.load({
3336
3536
  ? Section(M('同步冲突', 'Sync conflicts'), M('这些文件挡住了拉取:逐项选完保存,再点「立即拉取」', 'These files block the pull: pick per file, save, then pull'), [conflictCard], 'conflict')
3337
3537
  : null,
3338
3538
  Section(M('本机路径', 'Local paths'), M('每台机器确认一次即可:仓库里用占位符,落地时按这里展开', 'Confirm once per machine: the repo stores placeholders, expanded with these paths'), [rootsCard], 'roots'),
3339
- Section(M('同步目标', 'Sync targets'), M('仓库与远端都是本机设置,改完即生效', 'Repo and remote are local settings, applied at once'), [repoCard, remoteCard].filter(Boolean), 'targets'),
3340
- // 0.4.0:跨端状态与 WebDAV 方式紧随同步目标,便于「先确认平台、再选传输」
3341
- Section(M('跨端与同步方式', 'Platform & transport'), M('本机平台、仓库契约来自哪个平台、是否改用 WebDAV', 'Local platform, which platform the contract came from, and whether to use WebDAV'), [platformCard, webdavCard].filter(Boolean), 'platform'),
3539
+ Section(M('同步目标', 'Sync targets'), M('本机仓库、同步方式(Git / WebDAV)与云端目标统一在这里设置', 'Local repo, sync transport (Git / WebDAV), and cloud target settings'), [repoCard, cloudCard].filter(Boolean), 'targets'),
3540
+ Section(M('跨端状态', 'Cross-platform'), M('本机平台、仓库契约来自哪个平台与已登记机器', 'Local platform, which platform the contract came from, and registered machines'), [platformCard].filter(Boolean), 'platform'),
3342
3541
  Section(M('自动化与插件更新', 'Automation & plugin update'), M('退出后自动做什么、插件自己怎么升级', 'What runs automatically after exit, and how the plugin upgrades'), [autoCard, updCard].filter(Boolean), 'automation'),
3343
3542
  Section(M('退出后执行', 'After exit'), M('生成脚本 → 退出客户端后跑一遍', 'Generate the script → it runs after the client quits'), [actionCard], 'actions'),
3344
3543
  Section(M('还原备份', 'Restore backup'), M('点快照 → 确认差异 → 排队还原(退出客户端后执行)', 'Pick a snapshot → confirm the diff → queued restore (runs after the client quits)'), [restoreCard].filter(Boolean), 'restore'),
@@ -3381,7 +3580,13 @@ window.__ModuleLoader__.load({
3381
3580
  try {
3382
3581
  const r = await callRoots()
3383
3582
  setData(r)
3384
- if (editing) setDraft(snap(r))
3583
+ const next = snap(r)
3584
+ // 两件事一起判:
3585
+ // ① 编辑态下不用服务端值覆盖未保存的草稿(手填的路径会无声消失);
3586
+ // ② 一个根都没探测到(forced:没路径就先填)时也要把空草稿灌进去,
3587
+ // 否则输入框永远不出现、保存按钮恒 disabled,「首次填根」直接成死局。
3588
+ const noRoots = !(next.appRoot || next.dshHome || next.workspaceHome)
3589
+ if (!draft && (editing || noRoots)) setDraft(next)
3385
3590
  } catch (e) {
3386
3591
  setErr(String((e && e.message) || e))
3387
3592
  } finally { setBusy(false) }
@@ -3633,11 +3838,12 @@ window.__ModuleLoader__.load({
3633
3838
  */
3634
3839
  /** 问题反馈:提交即建 GitHub Issue(label feedback),列表读 Issue,点「已解决」就关单。 */
3635
3840
  function FeedbackCard() {
3636
- const empty = { connected: false, repo: '', label: 'feedback', items: [], counts: { open: 0, closed: 0, total: 0 }, outbox: [], error: '', ghFile: '', version: '', owner: '', login: '', canClose: false, readAnon: false, note: '' }
3841
+ const empty = { connected: false, repo: '', defaultRepo: '', label: 'feedback', items: [], counts: { open: 0, closed: 0, total: 0 }, outbox: [], error: '', ghFile: '', version: '', owner: '', login: '', canClose: false, readAnon: false, note: '', tokenPresent: false, tokenSource: 'none', tokenEnv: '', tokenSaved: false, envCandidates: [] }
3637
3842
  const [st, setSt] = react.useState(empty)
3638
3843
  const [title, setTitle] = react.useState('')
3639
3844
  const [text, setText] = react.useState('')
3640
3845
  const [token, setToken] = react.useState('')
3846
+ const [repoInput, setRepoInput] = react.useState('')
3641
3847
  const [askToken, setAskToken] = react.useState(false)
3642
3848
  const [busy, setBusy] = react.useState(false)
3643
3849
  const [msg, setMsg] = react.useState('')
@@ -3646,17 +3852,18 @@ window.__ModuleLoader__.load({
3646
3852
  const [filter, setFilter] = react.useState('open')
3647
3853
  const [kw, setKw] = react.useState('')
3648
3854
 
3649
- const load = async () => {
3855
+ const load = async (forceRefresh = false) => {
3650
3856
  setBusy(true)
3651
3857
  try {
3652
- const r = await callFeedback(null)
3858
+ const r = await callFeedback(null, forceRefresh ? { query: { refresh: '1' } } : undefined)
3653
3859
  setSt({ ...empty, ...r })
3860
+ if (r && r.repo && !askToken) setRepoInput(String(r.repo))
3654
3861
  setErr(String(r.error || ''))
3655
3862
  } catch (e) {
3656
3863
  setErr(String((e && e.message) || e))
3657
3864
  } finally { setBusy(false) }
3658
3865
  }
3659
- react.useEffect(() => { load() }, [])
3866
+ react.useEffect(() => { load(false) }, [])
3660
3867
 
3661
3868
  const submit = async () => {
3662
3869
  setBusy(true); setErr(''); setMsg('')
@@ -3680,14 +3887,29 @@ window.__ModuleLoader__.load({
3680
3887
  } finally { setBusy(false) }
3681
3888
  }
3682
3889
 
3683
- const saveToken = async () => {
3890
+ const saveToken = async (opts = {}) => {
3684
3891
  setBusy(true); setErr(''); setMsg('')
3685
3892
  try {
3686
- await callFeedback({ token }, { query: { action: 'token' } })
3893
+ const body = { repo: (opts.repo || repoInput || st.repo || '').trim() }
3894
+ if (opts.clearToken) {
3895
+ body.clearToken = true
3896
+ body.clearEnv = Boolean(opts.clearEnv)
3897
+ } else if (opts.tokenEnv) {
3898
+ body.tokenEnv = String(opts.tokenEnv).trim()
3899
+ } else if (token.trim()) {
3900
+ body.token = token.trim()
3901
+ }
3902
+ const res = await callFeedback(body, { query: { action: 'token' } })
3687
3903
  setToken('')
3688
3904
  setAskToken(false)
3689
- setMsg(M('令牌已存到本机(不进仓库),连接正常。', 'Token saved locally (never committed); connection works.'))
3690
- await load()
3905
+ if (opts.clearToken) {
3906
+ setMsg(M('已清除本机保存的明文令牌(后续优先读本机环境变量或 git 凭据,绝不推送进同步仓库)。', 'Cleared the stored plaintext token (env vars / git credential will be used instead, never pushed).'))
3907
+ } else if (res && res.tokenSource === 'env') {
3908
+ setMsg(M(`已绑定环境变量 ${res.tokenEnv || ''}(实时读取,不写入明文令牌,绝不推送进同步仓库)。`, `Bound env var ${res.tokenEnv || ''} (read dynamically, no plaintext token saved or pushed).`))
3909
+ } else {
3910
+ setMsg(M('已保存到本机私有配置(绝不推送进同步仓库),连接正常。', 'Saved locally (never committed or pushed); connection works.'))
3911
+ }
3912
+ await load(true)
3691
3913
  } catch (e) {
3692
3914
  setErr(String((e && e.message) || e))
3693
3915
  } finally { setBusy(false) }
@@ -3744,40 +3966,109 @@ window.__ModuleLoader__.load({
3744
3966
  onClick: () => setFilter(key),
3745
3967
  }, label)
3746
3968
 
3969
+ const tokenSourceHint = () => {
3970
+ if (st.note) return st.note
3971
+ if (st.tokenSource === 'env' && st.tokenEnv) {
3972
+ return M(
3973
+ `令牌来源:本机环境变量 ${st.tokenEnv}(实时读取,不落盘、绝不推送进同步仓库);仓库记在 ${st.ghFile || 'config-sync-gh.json'}`,
3974
+ `Token source: local env var ${st.tokenEnv} (read dynamically, never saved or pushed); repo lives in ${st.ghFile || 'config-sync-gh.json'}`,
3975
+ )
3976
+ }
3977
+ if (st.tokenSource === 'git-credential') {
3978
+ return M(
3979
+ `令牌来源:本机 git 凭据(仅内存使用,不落盘、绝不推送进同步仓库);仓库记在 ${st.ghFile || 'config-sync-gh.json'}`,
3980
+ `Token source: local git credential (memory only, never saved or pushed); repo lives in ${st.ghFile || 'config-sync-gh.json'}`,
3981
+ )
3982
+ }
3983
+ if (st.tokenSource === 'gh-cli') {
3984
+ return M(
3985
+ `令牌来源:本机 GitHub CLI(gh auth token,仅内存使用,不落盘、绝不推送进同步仓库);仓库记在 ${st.ghFile || 'config-sync-gh.json'}`,
3986
+ `Token source: local GitHub CLI (gh auth token, memory only, never saved or pushed); repo lives in ${st.ghFile || 'config-sync-gh.json'}`,
3987
+ )
3988
+ }
3989
+ if (st.tokenSaved) {
3990
+ return M(
3991
+ `令牌/仓库记在 ${st.ghFile || 'config-sync-gh.json'}(本机私有,绝不推送进同步仓库;也可改用 $GITHUB_TOKEN)`,
3992
+ `Token and repo live in ${st.ghFile || 'config-sync-gh.json'} (local only, never pushed; or switch to $GITHUB_TOKEN)`,
3993
+ )
3994
+ }
3995
+ return M(
3996
+ `支持读取本机环境变量(DSH_CONFIG_SYNC_GH_TOKEN / GITHUB_TOKEN / GH_TOKEN);只存仓库与变量名于 ${st.ghFile || 'config-sync-gh.json'}(绝不推送令牌)`,
3997
+ `Supports local env vars (DSH_CONFIG_SYNC_GH_TOKEN / GITHUB_TOKEN / GH_TOKEN); only repo/var name live in ${st.ghFile || 'config-sync-gh.json'} (tokens never pushed)`,
3998
+ )
3999
+ }
4000
+
3747
4001
  return h('div', { style: S.card },
3748
4002
  h('div', { style: S.cardHead },
3749
4003
  h('div', { style: S.cardTitle }, M('问题反馈', 'Feedback')),
3750
4004
  h('div', { style: { flex: 1 } }, null),
3751
4005
  h('span', { style: S.chip }, M(`${open} 待处理 / 共 ${total}`, `${open} open / ${total} total`)),
3752
- h('button', { type: 'button', style: S.btn, disabled: busy, onClick: load }, busy ? M('刷新中…', 'Refreshing…') : M('刷新', 'Refresh')),
4006
+ h('button', { type: 'button', style: S.btn, disabled: busy, onClick: () => load(true) }, busy ? M('刷新中…', 'Refreshing…') : M('刷新', 'Refresh')),
3753
4007
  ),
3754
4008
  h('div', { style: S.kvRow },
3755
4009
  h('div', { style: S.kvKey }, M('连接', 'Connect')),
3756
4010
  h('div', { style: S.kvVal },
3757
4011
  h('div', null,
3758
- dot(st.canClose ? 'var(--dsw-alias-state-success-primary, #35a854)' : (st.items.length ? 'var(--dsw-alias-state-warning-primary, #d97706)' : 'var(--dsw-alias-state-error-primary)')),
3759
- st.canClose
4012
+ dot(st.canClose && st.connected ? 'var(--dsw-alias-state-success-primary, #35a854)' : ((st.items.length || st.tokenPresent) ? 'var(--dsw-alias-state-warn-primary, #d97706)' : 'var(--dsw-alias-state-error-primary)')),
4013
+ st.canClose && st.connected
3760
4014
  ? M(`GitHub ${st.repo} · 已用 ${st.login} 登录(可提交、可关单)`, `GitHub ${st.repo} · signed in as ${st.login} (can submit and close)`)
3761
4015
  : st.connected
3762
4016
  ? M(`GitHub ${st.repo} · 令牌属于 ${st.login || '?'},不是仓库所有者,只能读和提交`, `GitHub ${st.repo} · token belongs to ${st.login || '?'}, not the repo owner: read and submit only`)
3763
4017
  : st.readAnon
3764
4018
  ? M(`GitHub ${st.repo} · 匿名读取(公开仓库,不需要令牌;提交走浏览器)`, `GitHub ${st.repo} · anonymous read (public repo, no token; submit via browser)`)
3765
- : M('还没连上 GitHub(令牌没取到或网络不通)', 'Not connected to GitHub (no token or no network)'),
4019
+ : st.tokenPresent
4020
+ ? M(`GitHub ${st.repo || st.defaultRepo || 'huanyu-a/dsh-profile-config-sync'} · 已读取本机令牌${st.login ? `(${st.login})` : ''},但连不上 GitHub API(请检查网络/代理)`, `GitHub ${st.repo || st.defaultRepo || 'huanyu-a/dsh-profile-config-sync'} · local token loaded${st.login ? ` (${st.login})` : ''}, but cannot reach GitHub API (check network/proxy)`)
4021
+ : M('还没连上 GitHub(令牌没取到或网络不通)', 'Not connected to GitHub (no token or no network)'),
3766
4022
  ),
3767
- h('div', { style: S.footnote },
3768
- st.note || (st.ghFile ? M(`令牌/仓库记在 ${st.ghFile}(本机私有,不进仓库)`, `Token and repo live in ${st.ghFile} (local only, never committed)`) : null)),
4023
+ h('div', { style: S.footnote }, tokenSourceHint()),
3769
4024
  ),
3770
4025
  ),
3771
- (askToken || !st.connected)
3772
- ? h('div', { style: S.kvRow },
3773
- h('div', { style: S.kvKey }, M('令牌', 'Token')),
3774
- h('div', { style: { ...S.kvVal, display: 'flex', gap: '8px' } },
3775
- h('input', {
3776
- type: 'password', style: S.input, value: token, spellCheck: false, autoComplete: 'off',
3777
- placeholder: M('粘贴 GitHub 令牌(一次即可;留空则读本机 git 凭据)', 'Paste a GitHub token (once); leave empty to reuse the local git credential'),
3778
- onChange: (e) => setToken(e.target.value),
3779
- }),
3780
- h('button', { type: 'button', style: S.btnPrimary, disabled: busy || !token.trim(), onClick: saveToken }, M('保存', 'Save')),
4026
+ (askToken || (!st.connected && !st.tokenPresent))
4027
+ ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '8px' } },
4028
+ h('div', { style: S.kvRow },
4029
+ h('div', { style: S.kvKey }, M('仓库', 'Repo')),
4030
+ h('div', { style: { ...S.kvVal, display: 'flex', gap: '8px', alignItems: 'center' } },
4031
+ h('input', {
4032
+ type: 'text', style: S.input, value: repoInput, spellCheck: false,
4033
+ placeholder: st.defaultRepo || 'huanyu-a/dsh-profile-config-sync',
4034
+ onChange: (e) => setRepoInput(e.target.value),
4035
+ }),
4036
+ st.defaultRepo && repoInput.trim() !== st.defaultRepo
4037
+ ? h('button', {
4038
+ type: 'button', style: S.btn, disabled: busy,
4039
+ onClick: () => { setRepoInput(st.defaultRepo); saveToken({ repo: st.defaultRepo }) },
4040
+ }, M(`改用 ${st.defaultRepo}`, `Use ${st.defaultRepo}`))
4041
+ : null,
4042
+ ),
4043
+ ),
4044
+ h('div', { style: S.kvRow },
4045
+ h('div', { style: S.kvKey }, M('令牌', 'Token')),
4046
+ h('div', { style: { ...S.kvVal, display: 'flex', flexDirection: 'column', gap: '6px' } },
4047
+ h('div', { style: { display: 'flex', gap: '8px' } },
4048
+ h('input', {
4049
+ type: 'password', style: S.input, value: token, spellCheck: false, autoComplete: 'off',
4050
+ placeholder: M('填 $GITHUB_TOKEN / env:GH_TOKEN 读环境变量,或粘贴令牌(留空也可只改仓库)', 'Enter $GITHUB_TOKEN / env:GH_TOKEN for env var, or paste a token'),
4051
+ onChange: (e) => setToken(e.target.value),
4052
+ }),
4053
+ h('button', {
4054
+ type: 'button', style: S.btnPrimary,
4055
+ disabled: busy || (!token.trim() && repoInput.trim() === String(st.repo || '')),
4056
+ onClick: () => saveToken(),
4057
+ }, M('保存', 'Save')),
4058
+ ),
4059
+ h('div', { style: { display: 'flex', gap: '6px', flexWrap: 'wrap', alignItems: 'center' } },
4060
+ ...(Array.isArray(st.envCandidates) ? st.envCandidates : []).map((envName) => h('button', {
4061
+ key: envName, type: 'button', style: S.btn, disabled: busy,
4062
+ onClick: () => saveToken({ tokenEnv: envName }),
4063
+ }, M(`使用环境变量 ${envName}`, `Use env ${envName}`))),
4064
+ st.tokenSaved
4065
+ ? h('button', {
4066
+ type: 'button', style: S.btn, disabled: busy,
4067
+ onClick: () => saveToken({ clearToken: true }),
4068
+ }, M('清除已存令牌(改用环境变量)', 'Clear saved token (use env)'))
4069
+ : null,
4070
+ ),
4071
+ ),
3781
4072
  ),
3782
4073
  )
3783
4074
  : null,
@@ -3914,7 +4205,7 @@ window.__ModuleLoader__.load({
3914
4205
 
3915
4206
  const head = h('div', { style: S.head },
3916
4207
  h('div', { style: S.headText },
3917
- h('div', { style: S.title }, M('配置同步', 'Config Sync')),
4208
+ h('div', { style: S.title }, M('配置备份与同步', 'Config Backup & Sync')),
3918
4209
  h('div', { style: S.sub }, busy ? M('检测中…', 'Checking…') : summary.text),
3919
4210
  data ? h('div', { style: S.sub }, `app ${data.version.local || '?'} / ${M('契约', 'contract')} ${data.version.contract || '?'}`) : null,
3920
4211
  ),
@@ -4057,7 +4348,7 @@ window.__ModuleLoader__.load({
4057
4348
  method: 'POST',
4058
4349
  cache: 'no-store',
4059
4350
  credentials: 'same-origin',
4060
- headers: jsonHeaders,
4351
+ headers: jsonHeaders(),
4061
4352
  body: JSON.stringify({ action: 'busy', sessionId: sessionId || '' }),
4062
4353
  })
4063
4354
  if (!res.ok) return false
@@ -4108,7 +4399,7 @@ window.__ModuleLoader__.load({
4108
4399
  name: 'sidebar.panellist',
4109
4400
  id: PANEL_ID,
4110
4401
  order: 35,
4111
- label: () => M('配置同步', 'Config Sync'),
4402
+ label: () => M('配置备份与同步', 'Config Backup & Sync'),
4112
4403
  locale: 'config-sync',
4113
4404
  }, SidebarIcon)
4114
4405
  return () => {