dsh-chat-history-sync 0.12.79 → 0.12.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.en.md +14 -1
- package/README.md +16 -3
- package/client/client.js +257 -57
- package/docs/FEATURE-MATRIX.md +9 -9
- package/docs/FINAL-0.12.80.md +90 -0
- package/docs/PHASE5-VERIFICATION.md +229 -0
- package/docs/PRODUCT-UI-STANDARDS.md +244 -0
- package/docs/RELEASE-CANDIDATE.md +53 -75
- package/docs/RETROSPECTIVE.md +8 -2
- package/docs/REUSABLE-LESSONS.md +238 -0
- package/docs/RUNTIME-CHECKLIST.md +7 -6
- package/docs/UX-HEALTH-CHECK.md +312 -0
- package/docs/VERIFICATION-CHECKLIST.md +164 -0
- package/docs/VERSION_AUDIT.md +20 -2
- package/lib/browser/login-save-cdp.mjs +135 -0
- package/lib/digest.cjs +21 -0
- package/lib/engine/sync-all.cjs +20 -2
- package/lib/import-state.cjs +3 -2
- package/lib/index.js +203 -63
- package/lib/lifecycle.cjs +57 -0
- package/lib/report-format.cjs +19 -1
- package/lib/report-session.cjs +9 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.81
|
|
4
|
+
|
|
5
|
+
- 修复更新用 PowerShell 脚本硬编码作者本机 `D:\Software\nodejs\node.exe` 的问题;改为写入当前运行 Node 的绝对路径并显式校验,PATH 中没有 node 的机器也能完成导入
|
|
6
|
+
|
|
7
|
+
## 0.12.80
|
|
8
|
+
|
|
9
|
+
- 报告写入成功不再被 flush/收尾异常误判为「报告未生成」;成功状态只在报告成功后发布
|
|
10
|
+
- 无变化更新不再追加报告,避免同步报告与更新报告重复
|
|
11
|
+
- 更新报告解析保留「;会话:标题」,无标题时回退旧标题
|
|
12
|
+
- 报告追加失败/成功路径增加兜底,修复成功分支变量作用域导致的 ReferenceError
|
|
13
|
+
- 成功状态保留 30 秒;启动/取消/scheduled 恢复状态统一
|
|
14
|
+
- 增加 install-schedule.lock,防止重复安装/重复重启
|
|
15
|
+
- 归档逻辑改为扫描所有工作区,清理重复的旧报告会话
|
|
16
|
+
- 临时关闭活动回合保护的验证开关已移除,正式恢复活动回复保护
|
|
17
|
+
- 恢复高级设置「导出诊断(不含 token)」按钮,修复公开控件回归
|
|
18
|
+
- 修复 DSH 0.2.2-rc.5 下插件定时器继承 HMR 事务导致 settings.update 报 HMR transactions cannot be nested 的兼容问题
|
|
19
|
+
- 登录改用内置 CDP WebSocket 脚本,不再依赖 puppeteer-core 或工作区 `tools/browser`,新安装的 DSH 也能登录
|
|
20
|
+
- 账号昵称/头像/默认简称会在登录后定时补齐;默认简称不再停在「账号xxxx」
|
|
21
|
+
|
|
22
|
+
|
|
3
23
|
## 0.12.79
|
|
4
24
|
|
|
5
25
|
- 成功文案从「更新成功」改为「聊天记录已同步」,避免误解为更新 DSH 软件
|
|
@@ -865,3 +885,6 @@
|
|
|
865
885
|
- 覆盖 DeepSeek 网页端 + 手机 App 聊天历史
|
|
866
886
|
- profile dependency / bundles / patch / 设置 section id 全部迁移
|
|
867
887
|
- 数据目录迁移到 `.dsh-chat-history-sync`,兼容旧目录复制
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
package/README.en.md
CHANGED
|
@@ -10,7 +10,7 @@ DeepSeek keeps chats in the web app and mobile app, but DSH cannot see them or c
|
|
|
10
10
|
|
|
11
11
|
- Same account, both clients: web and mobile-app history come from the same DeepSeek account; multiple accounts supported
|
|
12
12
|
- Months only: DSH workspaces are monthly, not split by category
|
|
13
|
-
- Report and catalog:
|
|
13
|
+
- Report and catalog: a sync with changes appends to one fixed "DSH Update Log" session; the report lists only changed accounts and session titles. The category index is an optional `history/_raw/分类目录.md` file; no change means no report
|
|
14
14
|
- Append-only: same-title chats with different content are kept; backups before install; DSH-created sessions are never touched
|
|
15
15
|
- Local tokens: encrypted with Windows DPAPI, never shown in the UI, never uploaded
|
|
16
16
|
|
|
@@ -24,6 +24,19 @@ dsh plugin add dsh-chat-history-sync
|
|
|
24
24
|
|
|
25
25
|
Then open **Settings → Chat History Sync → Log in → Sync now**.
|
|
26
26
|
|
|
27
|
+
## Revoke the sync login
|
|
28
|
+
|
|
29
|
+
The plugin login appears as an `Edge / Windows` device in the DeepSeek account's **Login devices** list. To revoke it:
|
|
30
|
+
|
|
31
|
+
**Web:** sign in to the DeepSeek web app → Account settings → Login devices → find the matching `Edge / Windows` entry → Log out.
|
|
32
|
+
|
|
33
|
+
**Mobile:** open the DeepSeek app → Account → Login devices → find the matching `Edge / Windows` entry → Log out.
|
|
34
|
+
|
|
35
|
+
- Prefer logging out only the matching dated Edge entry. Do not use “Log out all devices” unless you also want to sign out this phone.
|
|
36
|
+
- The next sync will then report an invalid login (`API 40003 INVALID_TOKEN` or “partial account failure”).
|
|
37
|
+
- In DSH → Settings → Chat History Sync → click **Log in again** for that account.
|
|
38
|
+
- Revoking the login only stops future syncs; chats already imported into DSH are not deleted.
|
|
39
|
+
|
|
27
40
|
## Data
|
|
28
41
|
|
|
29
42
|
- Chat data stays in the local DSH workspace
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ DeepSeek 的聊天记录散在网页和手机 App 里,DSH 里看不到,也
|
|
|
10
10
|
|
|
11
11
|
- **一个账号,两端记录**:网页端和手机 App 的聊天都从同一个 DeepSeek 账号读取;支持多个账号
|
|
12
12
|
- **只留月份**:DSH 工作区只建月份,不再按分类拆工作区
|
|
13
|
-
- **报告和目录**:有新增/更新时追加到固定「🧠 DSH
|
|
13
|
+
- **报告和目录**:有新增/更新时追加到固定「🧠 DSH 更新记录」;报告只列本次变更(账号、会话标题),不再附全量分类目录;分类索引作为可选文件 `history/_raw/分类目录.md` 保留;无变化不写报告
|
|
14
14
|
- **只增不减**:同名但内容不同的会话保留;更新前备份;不改 DSH 自建会话
|
|
15
15
|
- **免费,不调用模型**:摘要由本地规则生成,零模型费用、零隐私外发;同步本身也不调用模型
|
|
16
16
|
- **本机 token**:token 用 Windows DPAPI 加密,界面不显示,不上传
|
|
@@ -37,6 +37,19 @@ dsh plugin add dsh-chat-history-sync
|
|
|
37
37
|
→ DSH 重启后聊天记录出现在侧栏
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
## 退出同步登录(撤销设备)
|
|
41
|
+
|
|
42
|
+
插件登录会作为一条 `Edge / Windows` 设备出现在 DeepSeek 账号的「登录设备管理」里。需要撤销同步登录时:
|
|
43
|
+
|
|
44
|
+
**网页端**:登录 DeepSeek 网页 → 账号设置 → 登录设备管理 → 找到对应时间和设备的 `Edge / Windows` 记录 → 退出登录。
|
|
45
|
+
|
|
46
|
+
**手机端**:打开 DeepSeek App → 账号管理 → 登录设备管理 → 找到对应 `Edge / Windows` 记录 → 退出登录。
|
|
47
|
+
|
|
48
|
+
- 建议只退出对应日期的那条 Edge 记录;不要点「退出所有设备」,否则当前手机也会一起退出。
|
|
49
|
+
- 退出后,插件下一次同步会提示登录失效(典型为 `API 40003 INVALID_TOKEN` 或「同步完成(部分账号失败)」)。
|
|
50
|
+
- 到 DSH → 设置 → 聊天历史同步 → 对应账号点「重新登录」,完成登录后即可继续同步。
|
|
51
|
+
- 撤销登录只影响后续同步,不会删除已经同步到 DSH 的聊天记录。
|
|
52
|
+
|
|
40
53
|
## 数据说明
|
|
41
54
|
|
|
42
55
|
- 聊天记录只存在本机 DSH 工作区
|
|
@@ -62,8 +75,8 @@ dsh plugin add dsh-chat-history-sync
|
|
|
62
75
|
- **token 加密**:token 用 Windows DPAPI 加密为 `tokenEnc`,`config.json` 不保存明文;`run-config` 用完即删。
|
|
63
76
|
- **每日汇总**:自动同步有变化时,9:00 后只发一条普通通知;可在设置页关闭。
|
|
64
77
|
- **每小时自动同步**:定时检查网页端增量;**只在有新增/更新时**生成分类目录、导出、报告与系统通知,无变化时静默。
|
|
65
|
-
-
|
|
66
|
-
- **同步报告**:固定一个「🧠 DSH
|
|
78
|
+
- **分类目录**:按主题自动分类,生成为可选文件 `history/_raw/分类目录.md`,不再创建分类工作区,也不默认附在每次更新报告里;每类超过 9 条自动拆「(续)」。
|
|
79
|
+
- **同步报告**:固定一个「🧠 DSH 更新记录」会话,后续同步/更新追加,不再每次新建;正文只列本次变更摘要和具体会话标题,不附全量目录;分类目录作为可选文件保留。设置页只展开本次变更摘要,无变化不写报告。
|
|
67
80
|
- **一键同步聊天记录**:主按钮「同步聊天记录」先拉取;有新增/更新时显示「检测到新对话 → 更新聊天记录(会重启一次)/ 稍后」。点一次「更新聊天记录」才重启,不会自动重启;没有新增不会重启。关闭「有新对话时提示更新聊天记录」后只保留状态入口,不弹黄点。
|
|
68
81
|
|
|
69
82
|
## 工作区布局(2026-11-18 迁移后)
|
package/client/client.js
CHANGED
|
@@ -8,6 +8,8 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
const START_KEY = 'ms-sync-started';
|
|
9
9
|
const WINDOW_MS = 180000;
|
|
10
10
|
let clientCtx = null;
|
|
11
|
+
// 侧栏快捷动作:打开 main panel 后由 Card(完整 settings 上下文)执行
|
|
12
|
+
let autoAction = '';
|
|
11
13
|
|
|
12
14
|
// 可编辑文本:输入时不写设置,失焦/回车才提交(避免每敲一字触发 HMR/失焦)
|
|
13
15
|
const EditableField = ({ value, placeholder, disabled, width, bold, label, maxLength, onCommit }) => {
|
|
@@ -53,13 +55,15 @@ window.__ModuleLoader__.load({
|
|
|
53
55
|
});
|
|
54
56
|
|
|
55
57
|
const CSS = `
|
|
58
|
+
.msx{--msx-space-1:4px;--msx-space-2:8px;--msx-space-3:12px;--msx-space-4:16px;--msx-space-5:24px}
|
|
56
59
|
.msx-card{background:var(--dsw-alias-bg-layer-1);border:1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);border-radius:14px;overflow:hidden}
|
|
57
|
-
.msx-row{display:flex;align-items:center;justify-content:space-between;gap:
|
|
60
|
+
.msx-row{display:flex;align-items:center;justify-content:space-between;gap:var(--msx-space-4);padding:14px 16px}
|
|
58
61
|
.msx-row+.msx-row{border-top:1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent)}
|
|
59
62
|
.msx-input{box-sizing:border-box;width:100%;padding:8px 10px;border-radius:9px;border:1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 22%, transparent);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:14px;line-height:20px;outline:none;font-family:inherit}
|
|
60
63
|
.msx-input::placeholder{color:var(--dsw-alias-label-secondary);opacity:.7}
|
|
61
64
|
.msx-input:focus{border-color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-bg-base)}
|
|
62
|
-
.msx-btn{appearance:none;border-radius:9px;padding:7px 14px;font-size:13px;line-height:20px;cursor:pointer;font-family:inherit;white-space:nowrap}
|
|
65
|
+
.msx-btn{appearance:none;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:9px;padding:7px 14px;font-size:13px;line-height:20px;cursor:pointer;font-family:inherit;white-space:nowrap}
|
|
66
|
+
.msx-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2)}
|
|
63
67
|
.msx-btn:disabled{opacity:.45;cursor:default}
|
|
64
68
|
.msx-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-base);border:1px solid transparent;font-weight:600}
|
|
65
69
|
.msx-btn-primary:hover:not(:disabled){opacity:.88}
|
|
@@ -141,36 +145,23 @@ window.__ModuleLoader__.load({
|
|
|
141
145
|
React.useEffect(() => {
|
|
142
146
|
if (!meta.installScheduled && !meta.pending && meta.importPhase !== 'pending') setInstalling(false);
|
|
143
147
|
}, [meta.installScheduled, meta.pending, meta.importPhase]);
|
|
144
|
-
const run = async (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
148
|
+
const run = async () => {
|
|
149
|
+
// 侧栏是快捷动作:把意图交给 main panel 里的 Card 执行。
|
|
150
|
+
// login=登录;sync=立即同步;update/retry=只打开页面让用户确认。
|
|
151
|
+
if (meta.empty || meta.authFailed) autoAction = 'login';
|
|
152
|
+
else if (installReady) autoAction = 'update';
|
|
153
|
+
else if (failed) autoAction = 'retry';
|
|
154
|
+
else if (!running && !restarting && !reporting) autoAction = 'sync';
|
|
155
|
+
else autoAction = '';
|
|
151
156
|
try {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!ns) return;
|
|
157
|
-
let r = await clientCtx.remote.settings.mutate(ns.ns, [{ op: 'set', path: [field], value: true }], ns.revision || 0);
|
|
158
|
-
if (!r || !r.ok) {
|
|
159
|
-
const freshRes = await clientCtx.remote.settings.describe();
|
|
160
|
-
const freshDoc = freshRes && freshRes.ok ? freshRes.value : null;
|
|
161
|
-
const freshList = (freshDoc && freshDoc.namespaces) || [];
|
|
162
|
-
const freshNs = freshList.find((n) => n.ns === NS) || freshList.find((n) => String(n.ns).endsWith(':' + NS) || String(n.ns).endsWith('/' + NS));
|
|
163
|
-
if (freshNs) r = await clientCtx.remote.settings.mutate(freshNs.ns, [{ op: 'set', path: [field], value: true }], freshNs.revision || 0);
|
|
164
|
-
}
|
|
165
|
-
ok = !!(r && r.ok);
|
|
166
|
-
} catch (e) {} finally {
|
|
167
|
-
if (!ok) {
|
|
168
|
-
setInstalling(false);
|
|
169
|
-
setFailed(true);
|
|
170
|
-
setTimeout(() => setFailed(false), 5000);
|
|
157
|
+
const layout = clientCtx.get && clientCtx.get('layout');
|
|
158
|
+
if (layout && typeof layout.selectPanel === 'function') {
|
|
159
|
+
layout.selectPanel('chat-history-sync');
|
|
160
|
+
return;
|
|
171
161
|
}
|
|
172
|
-
|
|
173
|
-
|
|
162
|
+
} catch (e) {}
|
|
163
|
+
autoAction = '';
|
|
164
|
+
setFailed(false);
|
|
174
165
|
};
|
|
175
166
|
const icon = succeeded
|
|
176
167
|
? h('i', { style: { display: 'inline-block', width: 8, height: 8, borderRadius: '50%', background: 'var(--dsw-alias-state-success, #30a46c)', boxShadow: '0 0 0 4px rgba(48,164,108,.18)' } })
|
|
@@ -202,7 +193,7 @@ window.__ModuleLoader__.load({
|
|
|
202
193
|
onClick: restarting ? () => run('installCancel') : run,
|
|
203
194
|
onMouseEnter: () => setHover(true),
|
|
204
195
|
onMouseLeave: () => setHover(false),
|
|
205
|
-
style: { display: 'flex', alignItems: 'center', justifyContent: wide ? 'flex-start' : 'center', gap: 8, width: '100%', padding: '8px 10px', border: 'none', borderRadius: 9, background: hover && !running && !restarting && !succeeded && !reporting ? 'var(--dsw-alias-bg-layer-2)' : 'transparent', color: succeeded ? 'var(--dsw-alias-state-success, #30a46c)' : (restarting ? 'var(--dsw-alias-state-warning, #b86e00)' : 'var(--dsw-alias-label-secondary)'), font: 'inherit', fontSize: 13, fontWeight: succeeded ? 600 : 'normal', cursor: restarting || succeeded || reporting ? 'default' : 'pointer' },
|
|
196
|
+
style: { position: 'relative', zIndex: 3, pointerEvents: 'auto', display: 'flex', alignItems: 'center', justifyContent: wide ? 'flex-start' : 'center', gap: 8, width: '100%', padding: '8px 10px', border: 'none', borderRadius: 9, background: hover && !running && !restarting && !succeeded && !reporting ? 'var(--dsw-alias-bg-layer-2)' : 'transparent', color: succeeded ? 'var(--dsw-alias-state-success, #30a46c)' : (restarting ? 'var(--dsw-alias-state-warning, #b86e00)' : 'var(--dsw-alias-label-secondary)'), font: 'inherit', fontSize: 13, fontWeight: succeeded ? 600 : 'normal', cursor: restarting || succeeded || reporting ? 'default' : 'pointer' },
|
|
206
197
|
}, h('span', { 'aria-hidden': 'true', style: { fontSize: 16, lineHeight: 1, position: 'relative' } }, icon, dot), wide ? h('span', null, succeeded ? '聊天记录已同步' : (restarting ? '取消更新' : (reportFailed ? '重试更新' : (reporting ? '生成报告中' : (installing ? '正在准备更新' : (failed ? '重试' : (installReady ? '更新聊天记录' : (meta.empty ? '登录账号' : (meta.noEnabled ? '先启用' : (authFailed ? '重新登录' : (loginWaits ? '等待登录' : (running ? '正在同步' : '同步聊天记录')))))))))))) : null);
|
|
207
198
|
}
|
|
208
199
|
|
|
@@ -218,7 +209,185 @@ window.__ModuleLoader__.load({
|
|
|
218
209
|
}
|
|
219
210
|
}
|
|
220
211
|
|
|
212
|
+
async function readSyncNs() {
|
|
213
|
+
const res = await clientCtx.remote.settings.describe();
|
|
214
|
+
const doc = res && res.ok ? res.value : null;
|
|
215
|
+
const list = (doc && doc.namespaces) || [];
|
|
216
|
+
return list.find((n) => n.ns === NS) || list.find((n) => String(n.ns).endsWith(':' + NS) || String(n.ns).endsWith('/' + NS)) || null;
|
|
217
|
+
}
|
|
218
|
+
async function mutateSync(path, value) {
|
|
219
|
+
let ns = await readSyncNs();
|
|
220
|
+
if (!ns) return null;
|
|
221
|
+
let r = await clientCtx.remote.settings.mutate(ns.ns, [{ op: 'set', path: [path], value }], ns.revision || 0);
|
|
222
|
+
if (!r || !r.ok) {
|
|
223
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
224
|
+
ns = await readSyncNs();
|
|
225
|
+
if (ns) r = await clientCtx.remote.settings.mutate(ns.ns, [{ op: 'set', path: [path], value }], ns.revision || 0);
|
|
226
|
+
}
|
|
227
|
+
return r;
|
|
228
|
+
}
|
|
229
|
+
function pendingState(v) {
|
|
230
|
+
const accounts = (() => { try { return JSON.parse((v && v.accounts) || '[]'); } catch (e) { return []; } })();
|
|
231
|
+
const enabled = accounts.filter((a) => a && a.enabled !== false);
|
|
232
|
+
const phase = String((v && v.importPhase) || 'idle');
|
|
233
|
+
const statusText = String((v && v.statusText) || '');
|
|
234
|
+
const loginPending = /正在打开登录页|请在弹出的浏览器/.test(String((v && v.loginStatus) || ''));
|
|
235
|
+
const failed = !!(v && (v.status === 'error' || /同步失败|更新失败|更新未完成|更新调度失败/.test(statusText)));
|
|
236
|
+
const restarting = phase === 'scheduled';
|
|
237
|
+
const reporting = phase === 'reporting';
|
|
238
|
+
const running = !!(v && v.status === 'running');
|
|
239
|
+
const pending = !!(v && (v.installPending || v.installDeferred)) && phase !== 'succeeded' && phase !== 'scheduled';
|
|
240
|
+
const deferredByUser = !!(v && v.installDeferredByUser);
|
|
241
|
+
return { accounts, enabled, phase, statusText, loginPending, failed, restarting, reporting, running, pending, deferredByUser };
|
|
242
|
+
}
|
|
243
|
+
function QuickCard({ onManage }) {
|
|
244
|
+
const [snap, setSnap] = React.useState(null);
|
|
245
|
+
const [busy, setBusy] = React.useState(false);
|
|
246
|
+
const [notice, setNotice] = React.useState('');
|
|
247
|
+
React.useEffect(() => {
|
|
248
|
+
let alive = true;
|
|
249
|
+
const tick = async () => {
|
|
250
|
+
if (document.visibilityState === 'hidden') return;
|
|
251
|
+
try { const ns = await readSyncNs(); if (alive && ns) setSnap(ns.value || {}); } catch (e) {}
|
|
252
|
+
};
|
|
253
|
+
void tick();
|
|
254
|
+
const id = setInterval(tick, 3000);
|
|
255
|
+
return () => { alive = false; clearInterval(id); };
|
|
256
|
+
}, []);
|
|
257
|
+
const s = pendingState(snap);
|
|
258
|
+
const doAction = async (path, value = true) => {
|
|
259
|
+
setBusy(true); setNotice('');
|
|
260
|
+
let ok = false;
|
|
261
|
+
try {
|
|
262
|
+
const r = await mutateSync(path, value);
|
|
263
|
+
ok = !!(r && r.ok);
|
|
264
|
+
if (!ok) setNotice('操作没完成,请重试');
|
|
265
|
+
} catch (e) { setNotice('操作没完成:' + (e && e.message)); }
|
|
266
|
+
setBusy(false);
|
|
267
|
+
return ok;
|
|
268
|
+
};
|
|
269
|
+
React.useEffect(() => {
|
|
270
|
+
if (!snap || !autoAction) return;
|
|
271
|
+
const action = autoAction;
|
|
272
|
+
autoAction = '';
|
|
273
|
+
if (action === 'sync') void doAction('runNow', true);
|
|
274
|
+
else if (action === 'login') void doAction('loginRequest', Date.now());
|
|
275
|
+
}, [snap]);
|
|
276
|
+
const label = !snap ? '读取中…' : (!s.enabled.length ? (s.accounts.length ? '先启用' : '登录账号') : s.running ? '正在同步…' : s.restarting ? '即将重启' : s.pending ? '更新聊天记录' : s.failed || s.phase === 'report_failed' ? '重试' : '同步聊天记录');
|
|
277
|
+
const primary = () => {
|
|
278
|
+
if (!s.enabled.length) return doAction('loginRequest', Date.now());
|
|
279
|
+
if (s.running) return doAction('cancelSync', true);
|
|
280
|
+
if (s.restarting) return doAction('installCancel', true);
|
|
281
|
+
if (s.pending || s.failed || s.phase === 'report_failed') return doAction('installNow', true);
|
|
282
|
+
return doAction('runNow', true);
|
|
283
|
+
};
|
|
284
|
+
const deltaRaw = String((snap && snap.deltaText) || '').trim();
|
|
285
|
+
const deltaLines = deltaRaw.split('\n').filter(Boolean);
|
|
286
|
+
const lastSync = snap && snap.lastSyncAt ? new Date(snap.lastSyncAt).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) : '';
|
|
287
|
+
const stateText = !snap ? '读取中…' : (s.running ? '正在同步…' : s.restarting ? '更新已安排' : s.pending ? (s.deferredByUser ? '稍后更新' : '检测到新对话') : s.phase === 'report_failed' ? '报告未生成' : s.failed ? '操作没完成' : '已同步');
|
|
288
|
+
const subText = !snap ? '' : (s.running ? '后台同步中,可离开此页。' : s.restarting ? '约 20 秒后重启;可点取消更新。' : s.pending ? (s.deferredByUser ? '已稍后;点「更新聊天记录」可继续。' : '更新会重启一次;当前输入会丢失。') : s.phase === 'report_failed' ? '更新已写入,但报告未生成。' : s.failed ? '可重试;失败原因见管理页。' : (!s.enabled.length ? (s.accounts.length ? '请先在管理中启用账号。' : '先登录账号,再同步。') : (lastSync ? '上次同步 ' + lastSync : '尚未同步。')));
|
|
289
|
+
let secondary = null;
|
|
290
|
+
if (s.running) secondary = h('button', { className: 'msx-btn', style: { width: '100%' }, disabled: busy, onClick: () => void doAction('cancelSync', true) }, '取消同步');
|
|
291
|
+
else if (s.restarting) secondary = h('button', { className: 'msx-btn', style: { width: '100%' }, disabled: busy, onClick: () => void doAction('installCancel', true) }, '取消更新');
|
|
292
|
+
else if (s.pending && !s.deferredByUser) secondary = h('button', { className: 'msx-btn', style: { width: '100%' }, disabled: busy, onClick: async () => { const ok = await doAction('installCancel', true); if (ok) setNotice('已稍后,可随时更新'); } }, '稍后再说');
|
|
293
|
+
return h('div', { style: { display: 'grid', gap: 14 } },
|
|
294
|
+
h('style', null, CSS),
|
|
295
|
+
h('div', {
|
|
296
|
+
style: { display: 'grid', gap: 10, padding: 14, borderRadius: 12, background: 'color-mix(in srgb, var(--dsw-alias-label-primary) 8%, var(--dsw-alias-bg-layer-1))', border: '1px solid var(--dsw-alias-border-l2)' },
|
|
297
|
+
},
|
|
298
|
+
h('div', { style: { display: 'flex', alignItems: 'baseline', gap: 7, flexWrap: 'wrap' } },
|
|
299
|
+
snap ? h('i', { 'aria-hidden': 'true', style: { width: 8, height: 8, borderRadius: '50%', flex: '0 0 auto', position: 'relative', top: -1, background: s.failed ? 'var(--dsw-alias-state-error)' : (s.pending ? 'var(--dsw-alias-state-warning)' : 'var(--dsw-alias-state-success)') } }) : null,
|
|
300
|
+
h('span', { role: 'status', style: { fontSize: 15, fontWeight: 600, color: s.failed ? 'var(--dsw-alias-state-error)' : 'var(--dsw-alias-label-primary)' } }, stateText),
|
|
301
|
+
subText ? h('span', { className: 'msx-sub', style: { marginTop: 0 } }, subText) : null,
|
|
302
|
+
),
|
|
303
|
+
notice ? h('div', { className: 'msx-sub', style: { color: 'var(--dsw-alias-state-error)' } }, notice) : null,
|
|
304
|
+
snap && !s.running && !s.restarting ? h('div', { style: { display: 'grid', gridTemplateColumns: secondary ? '1fr 1fr' : '1fr', gap: 8, marginTop: 2, alignItems: 'stretch' } },
|
|
305
|
+
secondary,
|
|
306
|
+
h('button', { className: 'msx-btn msx-btn-primary', style: { width: '100%', minWidth: 0 }, disabled: busy, onClick: primary }, label),
|
|
307
|
+
) : null,
|
|
308
|
+
snap && (s.running || s.restarting) ? h('div', { style: { marginTop: 2 } }, secondary) : null,
|
|
309
|
+
),
|
|
310
|
+
snap && !deltaLines.length ? h('div', { style: { borderTop: '1px solid var(--dsw-alias-border-l1)', paddingTop: 10, fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, '本次没有新增或更新') : null,
|
|
311
|
+
snap && deltaLines.length ? h('div', { style: { display: 'grid', gap: 4, borderTop: '1px solid var(--dsw-alias-border-l1)', paddingTop: 10 } },
|
|
312
|
+
...deltaLines.slice(0, 6).map((line, i) => {
|
|
313
|
+
const parts = line.split(';会话:');
|
|
314
|
+
return h('div', { key: i, style: { display: 'flex', alignItems: 'baseline', gap: 8, flexWrap: 'wrap', fontSize: 12, lineHeight: 1.5 } },
|
|
315
|
+
h('span', { style: { flex: '0 0 auto', fontWeight: i === 0 ? 600 : 400, color: 'var(--dsw-alias-label-secondary)' } }, i === 0 ? '本次变更' : ''),
|
|
316
|
+
h('span', { style: { fontWeight: 600 } }, parts[0]),
|
|
317
|
+
parts[1] ? h('span', { style: { color: 'var(--dsw-alias-label-secondary)', whiteSpace: 'pre-wrap' } }, parts[1]) : null,
|
|
318
|
+
);
|
|
319
|
+
}),
|
|
320
|
+
) : null,
|
|
321
|
+
h('div', { style: { display: 'flex', justifyContent: 'flex-end', borderTop: '1px solid var(--dsw-alias-border-l1)', paddingTop: 10 } },
|
|
322
|
+
h('button', { className: 'msx-linkbtn', onClick: onManage }, '打开管理'),
|
|
323
|
+
),
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
221
327
|
function CardSafe() { return h(SlotBoundary, null, h(Card)); }
|
|
328
|
+
function FloatingSyncPanel() {
|
|
329
|
+
const [view, setView] = React.useState('quick');
|
|
330
|
+
const panelRef = React.useRef(null);
|
|
331
|
+
const closeRef = React.useRef(null);
|
|
332
|
+
const close = () => {
|
|
333
|
+
try {
|
|
334
|
+
const layout = clientCtx.get && clientCtx.get('layout');
|
|
335
|
+
if (layout && typeof layout.selectPanel === 'function') layout.selectPanel(null);
|
|
336
|
+
} catch (e) {}
|
|
337
|
+
};
|
|
338
|
+
React.useEffect(() => {
|
|
339
|
+
const previous = document.activeElement;
|
|
340
|
+
const timer = setTimeout(() => { try { closeRef.current && closeRef.current.focus(); } catch (e) {} }, 30);
|
|
341
|
+
const onKey = (e) => {
|
|
342
|
+
if (e.key === 'Escape') { e.preventDefault(); close(); return; }
|
|
343
|
+
if (e.key !== 'Tab' || !panelRef.current) return;
|
|
344
|
+
const nodes = [...panelRef.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter((el) => el.offsetParent !== null);
|
|
345
|
+
if (!nodes.length) return;
|
|
346
|
+
const first = nodes[0];
|
|
347
|
+
const last = nodes[nodes.length - 1];
|
|
348
|
+
if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
|
|
349
|
+
else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
|
|
350
|
+
};
|
|
351
|
+
document.addEventListener('keydown', onKey, true);
|
|
352
|
+
return () => {
|
|
353
|
+
clearTimeout(timer);
|
|
354
|
+
document.removeEventListener('keydown', onKey, true);
|
|
355
|
+
try { if (previous && typeof previous.focus === 'function') previous.focus(); } catch (e) {}
|
|
356
|
+
};
|
|
357
|
+
}, []);
|
|
358
|
+
return h('div', {
|
|
359
|
+
style: { position: 'fixed', inset: 0, zIndex: 80, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'rgba(15,17,21,.32)', padding: 'min(24px, 4vw)' },
|
|
360
|
+
role: 'dialog',
|
|
361
|
+
'aria-modal': 'true',
|
|
362
|
+
'aria-label': '聊天历史同步',
|
|
363
|
+
onClick: (e) => { if (e.target === e.currentTarget) close(); },
|
|
364
|
+
}, h('div', {
|
|
365
|
+
ref: panelRef,
|
|
366
|
+
tabIndex: -1,
|
|
367
|
+
style: { width: view === 'quick' ? 'min(600px, 100%)' : 'min(720px, 100%)', maxHeight: '86vh', overflow: 'auto', background: 'var(--dsw-alias-bg-layer-1)', border: '1px solid var(--dsw-alias-border-l1)', borderRadius: 16, boxShadow: '0 24px 64px rgba(0,0,0,.28)', padding: '14px 20px 14px', position: 'relative', color: 'var(--dsw-alias-label-primary)' },
|
|
368
|
+
},
|
|
369
|
+
h('button', {
|
|
370
|
+
ref: closeRef,
|
|
371
|
+
type: 'button',
|
|
372
|
+
'aria-label': '关闭同步窗口',
|
|
373
|
+
title: '关闭',
|
|
374
|
+
onClick: close,
|
|
375
|
+
style: { position: 'absolute', top: 10, right: 12, zIndex: 2, border: 'none', background: 'var(--dsw-alias-bg-layer-2)', color: 'var(--dsw-alias-label-secondary)', borderRadius: 8, width: 30, height: 30, cursor: 'pointer', fontSize: 18, lineHeight: '28px', padding: 0 },
|
|
376
|
+
}, '×'),
|
|
377
|
+
h('div', { style: { maxWidth: view === 'quick' ? 560 : 640, margin: '0 auto' } },
|
|
378
|
+
view === 'quick' ? h('div', { style: { display: 'grid', gap: 12 } },
|
|
379
|
+
h('div', null,
|
|
380
|
+
h('h2', { id: 'sync-panel-title', style: { margin: 0, fontSize: 18, fontWeight: 600 } }, '聊天历史同步'),
|
|
381
|
+
h('div', { className: 'msx-sub' }, 'DeepSeek 聊天记录 → DSH,按月份归档。'),
|
|
382
|
+
),
|
|
383
|
+
h(QuickCard, { onManage: () => setView('manage') }),
|
|
384
|
+
) : h('div', { style: { display: 'grid', gap: 10 } },
|
|
385
|
+
h('button', { className: 'msx-linkbtn', style: { justifySelf: 'start' }, onClick: () => setView('quick') }, '← 返回快捷同步'),
|
|
386
|
+
h(SlotBoundary, null, h(Card)),
|
|
387
|
+
),
|
|
388
|
+
),
|
|
389
|
+
));
|
|
390
|
+
}
|
|
222
391
|
function FooterSafe(props) { return h(SlotBoundary, null, h(FooterEntry, props)); }
|
|
223
392
|
|
|
224
393
|
function Card() {
|
|
@@ -369,10 +538,19 @@ window.__ModuleLoader__.load({
|
|
|
369
538
|
setNotice('');
|
|
370
539
|
const now = Date.now();
|
|
371
540
|
setStartedAt(now);
|
|
372
|
-
setMsg('
|
|
541
|
+
setMsg('正在同步…');
|
|
373
542
|
try { window.localStorage.setItem(START_KEY, String(now)); } catch (e) {}
|
|
374
543
|
try {
|
|
375
|
-
|
|
544
|
+
let r = await clientCtx.remote.settings.mutate(nsRef.current, [{ op: 'set', path: ['runNow'], value: true }], revision);
|
|
545
|
+
if (!r || !r.ok) {
|
|
546
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
547
|
+
const freshRes = await clientCtx.remote.settings.describe();
|
|
548
|
+
const freshDoc = freshRes && freshRes.ok ? freshRes.value : null;
|
|
549
|
+
const freshList = (freshDoc && freshDoc.namespaces) || [];
|
|
550
|
+
const freshNs = freshList.find((n) => n.ns === NS) || freshList.find((n) => String(n.ns).endsWith(':' + NS) || String(n.ns).endsWith('/' + NS));
|
|
551
|
+
if (freshNs) r = await clientCtx.remote.settings.mutate(freshNs.ns, [{ op: 'set', path: ['runNow'], value: true }], freshNs.revision || 0);
|
|
552
|
+
}
|
|
553
|
+
if (!r || !r.ok) r = await clientCtx.remote.settings.mutate(nsRef.current, [{ op: 'set', path: ['runNow'], value: true }], 0);
|
|
376
554
|
if (!r || !r.ok) {
|
|
377
555
|
flash('触发被拒绝,请重试');
|
|
378
556
|
setStartedAt(0);
|
|
@@ -417,6 +595,14 @@ window.__ModuleLoader__.load({
|
|
|
417
595
|
setBusy(false);
|
|
418
596
|
};
|
|
419
597
|
|
|
598
|
+
React.useEffect(() => {
|
|
599
|
+
if (!value || !autoAction) return;
|
|
600
|
+
const action = autoAction;
|
|
601
|
+
autoAction = '';
|
|
602
|
+
if (action === 'sync') void trigger();
|
|
603
|
+
else if (action === 'login') void login();
|
|
604
|
+
}, [value]);
|
|
605
|
+
|
|
420
606
|
const mode = (value && value.attachmentMode) || 'all';
|
|
421
607
|
const modeText = mode === 'all' ? '保存原件和图片' : (mode === 'images' ? '只保存图片' : '只记录文件名');
|
|
422
608
|
const auto = !!(value && value.autoSync);
|
|
@@ -430,6 +616,9 @@ window.__ModuleLoader__.load({
|
|
|
430
616
|
const installPending = !!(value && value.installPending);
|
|
431
617
|
const installDeferred = !!(value && value.installDeferred);
|
|
432
618
|
const duplicateCount = Number(value && value.duplicateCount) || 0;
|
|
619
|
+
let changedSessions = [];
|
|
620
|
+
try { changedSessions = JSON.parse((value && value.changedSessions) || '[]'); } catch (e) { changedSessions = []; }
|
|
621
|
+
if (!Array.isArray(changedSessions)) changedSessions = [];
|
|
433
622
|
let health = {};
|
|
434
623
|
try { health = JSON.parse((value && value.accountHealth) || '{}'); } catch (e) { health = {}; }
|
|
435
624
|
let attachStats = null;
|
|
@@ -438,7 +627,8 @@ window.__ModuleLoader__.load({
|
|
|
438
627
|
const setAccounts = (next) => { void write('accounts', JSON.stringify(next), !next.length); };
|
|
439
628
|
const hasAccounts = accounts.some((a) => a && a.enabled !== false);
|
|
440
629
|
const hasAnyAccounts = accounts.length > 0;
|
|
441
|
-
const
|
|
630
|
+
const importPhase = String((value && value.importPhase) || '');
|
|
631
|
+
const updateAvailable = hasAccounts && !!(value && (value.installPending || value.installDeferred)) && importPhase !== 'scheduled' && importPhase !== 'succeeded' && importPhase !== 'reporting';
|
|
442
632
|
const patchRow = (i, patch) => { const n = accounts.slice(); n[i] = { ...n[i], ...patch }; setAccounts(n); };
|
|
443
633
|
const loginStatus = value && value.loginStatus;
|
|
444
634
|
const loginPending = /正在打开登录页|请在弹出的浏览器/.test(String(loginStatus || ''));
|
|
@@ -447,14 +637,13 @@ window.__ModuleLoader__.load({
|
|
|
447
637
|
const progressPct = progressMatch && Number(progressMatch[2]) > 0 ? Math.round((Number(progressMatch[1]) / Number(progressMatch[2])) * 100) : 0;
|
|
448
638
|
const progressText = progressMatch ? '正在同步 ' + progressMatch[1] + '/' + progressMatch[2] : '正在同步…';
|
|
449
639
|
const actionVisible = autoInstall && /^(更新完成|更新失败|更新未完成|更新调度失败|已安排更新|已取消本次更新|有会话待更新|同步完成,但报告未生成)/.test(statusText);
|
|
450
|
-
const importPhase = String((value && value.importPhase) || '');
|
|
451
640
|
const reportFailed = importPhase === 'report_failed';
|
|
452
641
|
const installFailed = autoInstall && (importPhase === 'failed' || reportFailed || /^(更新失败|更新未完成|更新调度失败)/.test(statusText));
|
|
453
642
|
const statusLine = value ? (notice || msg || (running ? progressText : (value.status === 'error' ? String(value.statusText || '同步失败') : (actionVisible ? statusText : (value.lastSyncAt ? '已同步' : '尚未同步'))))) : (notice || msg || '读取中…');
|
|
454
643
|
const pendingText = /^同步完成:检测到新对话/.test(String((value && value.statusText) || ''));
|
|
455
644
|
const pendingInstall = (installPending || pendingText) && autoInstall;
|
|
456
645
|
const needInstall = (!installDeferred && pendingInstall) || reportFailed;
|
|
457
|
-
const restarting = importPhase === 'scheduled'
|
|
646
|
+
const restarting = importPhase === 'scheduled';
|
|
458
647
|
const reporting = importPhase === 'reporting';
|
|
459
648
|
const shownStatus = loginPending ? '等待登录…' : (restarting ? '更新已安排 · 即将重启' : (reporting ? '正在生成更新报告…' : (reportFailed ? '更新完成,但报告未生成' : ((!running && pendingText) ? '同步完成 · 待确认更新' : statusLine))));
|
|
460
649
|
const failed = !!(value && (value.status === 'error' || /^同步失败|^自动同步失败|部分账号失败|^更新失败|^更新未完成|^更新调度失败/.test(String(shownStatus || ''))));
|
|
@@ -491,32 +680,39 @@ window.__ModuleLoader__.load({
|
|
|
491
680
|
h('span', { role: 'status', 'aria-live': running ? 'off' : 'polite', style: { fontSize: 14, fontWeight: 600, color: failed ? 'var(--dsw-alias-state-error)' : 'var(--dsw-alias-label-primary)' } }, shownStatus),
|
|
492
681
|
!running ? h('i', { 'aria-hidden': 'true', style: { display: 'inline-block', flex: '0 0 auto', width: 6, height: 6, borderRadius: '50%', background: failed ? 'var(--dsw-alias-state-error, #e5484d)' : (pendingInstall ? 'var(--dsw-alias-state-warning, #f5a623)' : (hasAccounts ? 'var(--dsw-alias-state-success, #30a46c)' : 'var(--dsw-alias-label-tertiary, #8b8f98)')) } }) : null,
|
|
493
682
|
),
|
|
494
|
-
h('div', { className: 'msx-sub' }, !value ? '正在读取同步设置…' : (loginPending ? '请在弹出的浏览器完成登录。' : (restarting ? '约 20 秒后重启 DSH;可在侧栏或设置中点「取消更新」。' : (reporting ? '更新已写入,正在生成可见报告。' : (reportFailed ? '更新已写入,但报告会话未生成;可重试更新。' : (running ? '后台同步中,可离开此页。' : (!hasAccounts ? (hasAnyAccounts ? '先启用账号,再同步。' : '先登录账号,再同步。') : (installFailed ? '可稍后重试更新。' : (needRelogin ? '登录失效,请点「重新登录」。' : (failed ? '可重试,或查看报告。' : '同步时可离开此页。')))))))))),
|
|
683
|
+
h('div', { className: 'msx-sub' }, !value ? '正在读取同步设置…' : (loginPending ? '请在弹出的浏览器完成登录。' : (restarting ? '约 20 秒后重启 DSH;可在侧栏或设置中点「取消更新」。' : (reporting ? '更新已写入,正在生成可见报告。' : (reportFailed ? '更新已写入,但报告会话未生成;可重试更新。' : (running ? '后台同步中,可离开此页。' : (!hasAccounts ? (hasAnyAccounts ? '先启用账号,再同步。' : '先登录账号,再同步。') : (needInstall ? '检测到新对话;更新会重启一次,当前输入会丢失,可稍后再说。' : (installFailed ? '可稍后重试更新。' : (needRelogin ? '登录失效,请点「重新登录」。' : (failed ? '可重试,或查看报告。' : '同步时可离开此页。'))))))))))),
|
|
495
684
|
),
|
|
496
685
|
h('div', { style: { display: 'flex', gap: 8, flexShrink: 0 } },
|
|
497
686
|
loginPending ? h('button', { className: 'msx-btn', disabled: busy, 'aria-label': '取消登录', onClick: () => void write('loginCancel', Date.now()) }, '取消登录') : null,
|
|
498
687
|
running ? h('button', { className: 'msx-btn', disabled: busy, 'aria-label': '取消当前同步', onClick: () => void write('cancelSync', true) }, '取消') : null,
|
|
499
688
|
restarting ? h('button', { className: 'msx-btn', disabled: busy, 'aria-label': '取消本次更新', onClick: () => void write('installCancel', true) }, '取消更新') : null,
|
|
500
689
|
needRelogin ? h('button', { className: 'msx-btn', disabled: busy || running || loginPending, 'aria-label': '重新登录 DeepSeek 账号', onClick: () => void write('loginRequest', Date.now()) }, '重新登录') : null,
|
|
501
|
-
h('button', { className: 'msx-btn
|
|
690
|
+
needInstall && !installFailed && !reportFailed ? h('button', { className: 'msx-btn', disabled: busy, 'aria-label': '稍后再说', onClick: () => void write('installCancel', true) }, '稍后再说') : null,
|
|
691
|
+
!installFailed && !reportFailed ? h('button', { className: 'msx-btn msx-btn-primary', disabled: busy || running || restarting || reporting || !value || loginPending || needRelogin || (hasAnyAccounts && !hasAccounts), 'aria-label': primaryAria, onClick: primaryAction }, primaryLabel) : null,
|
|
502
692
|
),
|
|
503
693
|
),
|
|
504
694
|
running ? h('div', { className: 'msx-kbar', role: 'progressbar', 'aria-busy': 'true', 'aria-valuemin': 0, 'aria-valuemax': 100, 'aria-valuenow': progressMatch ? progressPct : undefined, 'aria-valuetext': progressMatch ? '同步 ' + progressMatch[1] + '/' + progressMatch[2] : '同步进行中' }, h('i', null)) : null,
|
|
505
695
|
(value && (value.lastSyncAt || value.reportText || (installDeferred && autoInstall))) ? h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, borderTop: '1px solid var(--dsw-alias-border-l1)', padding: '9px 16px', flexWrap: 'wrap' } },
|
|
506
696
|
h('span', { className: 'msx-sub', 'aria-label': installDeferred ? '有会话待更新' : (value.lastSyncAt ? '上次同步 ' + fmtTime(value.lastSyncAt) : '还没有同步记录'), title: value && value.lastSyncResult ? String(value.lastSyncResult).slice(0, 300) : undefined, style: { marginTop: 0, color: installDeferred ? 'var(--dsw-alias-state-warning, #b86e00)' : undefined } }, installDeferred ? '有会话待更新' : (value.lastSyncAt ? '上次同步 ' + fmtTime(value.lastSyncAt) : '还没有同步记录')),
|
|
507
697
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, flexShrink: 0 } },
|
|
508
|
-
|
|
509
|
-
(value.reportText) ? h('button', { className: 'msx-linkbtn', style: { flexShrink: 0 }, 'aria-expanded': reportOpen, title: duplicateCount > 0 ? duplicateCount + ' 组同名但内容不同的会话已分别保留,点开报告查看' : undefined, 'aria-label': duplicateCount > 0 ? '查看报告,含 ' + duplicateCount + ' 组同名会话' : '查看报告', onClick: () => setReportOpen(!reportOpen) }, reportOpen ? '收起报告' : (duplicateCount > 0 ? '查看报告 · ' + duplicateCount + ' 组同名' : '查看报告')) : null,
|
|
698
|
+
(value.reportText) ? h('button', { className: 'msx-linkbtn', style: { flexShrink: 0 }, 'aria-expanded': reportOpen, title: duplicateCount > 0 ? duplicateCount + ' 组同名但内容不同的会话已分别保留,点开报告查看' : undefined, 'aria-label': duplicateCount > 0 ? '查看报告,含 ' + duplicateCount + ' 组同名会话' : '查看报告', onClick: () => setReportOpen(!reportOpen) }, reportOpen ? '收起摘要' : '展开摘要') : null,
|
|
510
699
|
),
|
|
511
700
|
) : null,
|
|
512
701
|
(reportOpen && value && value.reportText) ? h('div', { className: 'msx-report' },
|
|
702
|
+
changedSessions.length ? h('div', { style: { display: 'grid', gap: 6, marginBottom: 10 } },
|
|
703
|
+
h('div', { className: 'msx-label', style: { fontSize: 12 } }, '本次变更会话'),
|
|
704
|
+
...changedSessions.map((s, i) => h('div', { key: i, style: { display: 'grid', gap: 1 } },
|
|
705
|
+
h('div', { style: { fontSize: 12, fontWeight: 600 } }, String(s.title || '')),
|
|
706
|
+
h('div', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary)', wordBreak: 'break-all' } }, String(s.link || '')),
|
|
707
|
+
)),
|
|
708
|
+
) : h('div', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)', marginBottom: 8 } }, '本次没有新增或更新'),
|
|
513
709
|
renderReportText(reportFull ? value.reportText : (String(value.reportText).slice(0, 1200) + (String(value.reportText).length > 1200 ? '\n…' : ''))),
|
|
514
710
|
String(value.reportText).length > 1200 ? h('div', { style: { marginTop: 6 } }, h('button', { className: 'msx-linkbtn', onClick: () => setReportFull(!reportFull) }, reportFull ? '收起全文' : '展开全文')) : null,
|
|
515
711
|
) : null,
|
|
516
712
|
),
|
|
517
713
|
|
|
518
|
-
//
|
|
519
|
-
|
|
714
|
+
// 仅失败/报告失败保留独立卡片;普通“检测到新对话”已合并进状态卡
|
|
715
|
+
(installFailed || reportFailed) ? h('div', {
|
|
520
716
|
className: 'msx-card',
|
|
521
717
|
role: installFailed ? 'alert' : undefined,
|
|
522
718
|
style: {
|
|
@@ -606,18 +802,6 @@ window.__ModuleLoader__.load({
|
|
|
606
802
|
h('h3', { className: 'msx-h3' }, '同步设置'),
|
|
607
803
|
h('div', { className: 'msx-sub', style: { margin: '0 0 10px' } }, '登录后点一次同步;有新内容才提示更新,更新会重启一次。其余默认即可。'),
|
|
608
804
|
h('div', { className: 'msx-card' },
|
|
609
|
-
advOpen ? h('div', { className: 'msx-row' },
|
|
610
|
-
h('div', null,
|
|
611
|
-
h('div', { className: 'msx-label' }, '附件下载'),
|
|
612
|
-
h('div', { className: 'msx-sub' }, modeText),
|
|
613
|
-
attachText ? h('div', { className: 'msx-sub' }, attachText) : null,
|
|
614
|
-
),
|
|
615
|
-
h('select', { className: 'msx-select', 'aria-label': '附件下载方式', value: mode, disabled: busy, onChange: (e) => void write('attachmentMode', e.target.value) },
|
|
616
|
-
h('option', { value: 'all' }, '全部保存'),
|
|
617
|
-
h('option', { value: 'images' }, '只保存图片'),
|
|
618
|
-
h('option', { value: 'none' }, '只记录文件名'),
|
|
619
|
-
),
|
|
620
|
-
) : null,
|
|
621
805
|
h('label', { className: 'msx-row', style: { cursor: 'pointer' } },
|
|
622
806
|
h('div', null,
|
|
623
807
|
h('div', { className: 'msx-label' }, '每小时自动同步'),
|
|
@@ -651,10 +835,21 @@ window.__ModuleLoader__.load({
|
|
|
651
835
|
h('input', { type: 'checkbox', checked: digestOn, disabled: busy, 'aria-label': '每日汇总', onChange: (e) => void write('digestEnabled', e.target.checked) }),
|
|
652
836
|
),
|
|
653
837
|
h('div', { className: 'msx-row' },
|
|
654
|
-
h('
|
|
838
|
+
h('div', null,
|
|
839
|
+
h('div', { className: 'msx-label' }, '附件下载'),
|
|
840
|
+
h('div', { className: 'msx-sub' }, modeText),
|
|
841
|
+
attachText ? h('div', { className: 'msx-sub' }, attachText) : null,
|
|
842
|
+
),
|
|
843
|
+
h('select', { className: 'msx-select', 'aria-label': '附件下载方式', value: mode, disabled: busy, onChange: (e) => void write('attachmentMode', e.target.value) },
|
|
844
|
+
h('option', { value: 'all' }, '全部保存'),
|
|
845
|
+
h('option', { value: 'images' }, '只保存图片'),
|
|
846
|
+
h('option', { value: 'none' }, '只记录文件名'),
|
|
847
|
+
),
|
|
655
848
|
),
|
|
656
|
-
h('div', { className: 'msx-row' },
|
|
657
|
-
h('button', { className: 'msx-
|
|
849
|
+
h('div', { className: 'msx-row', style: { display: 'flex', gap: 8, flexWrap: 'wrap', alignItems: 'stretch' } },
|
|
850
|
+
h('button', { className: 'msx-btn', style: { flex: '1 1 150px' }, disabled: busy, title: '只归档插件生成的旧报告,不删除聊天;可在 DSH 归档中恢复', 'aria-label': '整理旧同步报告,只归档插件报告,不删除聊天', onClick: () => void write('archiveOldReports', true) }, '整理旧报告'),
|
|
851
|
+
h('button', { className: 'msx-btn', style: { flex: '1 1 150px' }, disabled: busy, title: '归档当前报告;下次同步创建精简变更日志报告', 'aria-label': '重建报告会话,归档旧报告', onClick: () => void write('resetReport', true) }, '重建报告'),
|
|
852
|
+
h('button', { className: 'msx-btn', style: { flex: '1 1 150px' }, disabled: busy, title: '导出脱敏诊断信息,不含 token', 'aria-label': '导出脱敏诊断信息,不含 token', onClick: () => void write('exportDiagnostics', true) }, '导出诊断(不含 token)'),
|
|
658
853
|
),
|
|
659
854
|
) : null,
|
|
660
855
|
),
|
|
@@ -674,6 +869,10 @@ window.__ModuleLoader__.load({
|
|
|
674
869
|
order: 16,
|
|
675
870
|
label: '聊天历史同步',
|
|
676
871
|
}, CardSafe));
|
|
872
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
873
|
+
name: 'main',
|
|
874
|
+
key: 'chat-history-sync',
|
|
875
|
+
}, FloatingSyncPanel));
|
|
677
876
|
ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register({
|
|
678
877
|
name: 'sidebar.footer.action',
|
|
679
878
|
id: 'chat-history-sync',
|
|
@@ -684,3 +883,4 @@ window.__ModuleLoader__.load({
|
|
|
684
883
|
};
|
|
685
884
|
},
|
|
686
885
|
});
|
|
886
|
+
|