@kangyishuai/dsh-session-delete 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -25
- package/README.zh-CN.md +25 -17
- package/lib/agent-tool.js +39 -3
- package/lib/audit.js +1 -1
- package/lib/client.js +1061 -153
- package/lib/operations.js +496 -147
- package/lib/recovery.js +477 -0
- package/lib/refs.js +217 -6
- package/lib/restore.js +187 -0
- package/lib/service.js +105 -0
- package/lib/trash.js +157 -14
- package/lib/workspace-state.js +63 -0
- package/locale/en.json +23 -2
- package/locale/zh.json +23 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -89,9 +89,22 @@ window.__ModuleLoader__.load({
|
|
|
89
89
|
"panel.size": "{size}",
|
|
90
90
|
"panel.trashedAt": "{time}",
|
|
91
91
|
"panel.unknown": "{n} 个无法识别的目录已保留",
|
|
92
|
-
"panel.pending": "{n}
|
|
92
|
+
"panel.pending": "{n} 个未完成的操作(重启后自动对账;仍未处理需人工核对)",
|
|
93
93
|
"panel.readOnly": "只读模式:当前 DSH 版本缺少依赖接口,删除功能已禁用。",
|
|
94
94
|
"panel.close": "关闭",
|
|
95
|
+
"receipt.refs": "引用",
|
|
96
|
+
"receipt.removed": "已清理的引用",
|
|
97
|
+
"receipt.checks": "校验",
|
|
98
|
+
"receipt.summary.ok": "全部通过",
|
|
99
|
+
"receipt.summary.partial": "{n} 处未通过",
|
|
100
|
+
"restore.detail.title": "未通过的引用与校验",
|
|
101
|
+
"restore.detail.retry": "重试未通过的引用",
|
|
102
|
+
"restore.detail.retrying": "正在重试…",
|
|
103
|
+
"restore.detail.retried": "已自动重试一次",
|
|
104
|
+
"restore.retry.ok": "重检通过:引用与校验全部恢复",
|
|
105
|
+
"restore.retry.partial": "重检后仍有 {n} 处未通过",
|
|
106
|
+
"restore.busyHint":
|
|
107
|
+
"若发送被拒(提示 session/agent-busy),说明宿主还把这个会话标记为忙碌:重启 DSH,或新建会话继续。",
|
|
95
108
|
"trash.selectAll": "全选",
|
|
96
109
|
"trash.selectCount": "已选 {n}/{total}",
|
|
97
110
|
"trash.restoreMany": "恢复({n})",
|
|
@@ -101,7 +114,14 @@ window.__ModuleLoader__.load({
|
|
|
101
114
|
"batch.stop": "停止",
|
|
102
115
|
"batch.done": "完成:{ok}/{total} 成功",
|
|
103
116
|
"batch.failed": "{n} 个失败,已保留选中",
|
|
117
|
+
"batch.partial": "其中 {n} 条引用未还原",
|
|
104
118
|
"toast.failed": "操作失败:{message}",
|
|
119
|
+
"toast.trashPartial": "已移入回收站,但收尾未完成:{message}(会话可在回收站恢复)",
|
|
120
|
+
"toast.restorePartial": "会话已恢复,但 {n} 处引用/校验未通过(详见操作回执)",
|
|
121
|
+
"toast.undoFailed": "撤销失败:{message}",
|
|
122
|
+
"toast.trashedCurrent": "已移入回收站,可在回收站恢复",
|
|
123
|
+
"toast.restored": "会话已恢复,正在重新打开",
|
|
124
|
+
"toast.restoredMany": "已恢复 {n} 个会话,正在刷新列表",
|
|
105
125
|
"settings.nav": "会话回收站",
|
|
106
126
|
"settings.group.delete": "删除偏好",
|
|
107
127
|
"settings.cascade.title": "记住「同时删除子会话」",
|
|
@@ -113,8 +133,10 @@ window.__ModuleLoader__.load({
|
|
|
113
133
|
"settings.trash.open": "打开回收站",
|
|
114
134
|
"settings.group.maintenance": "维护",
|
|
115
135
|
"settings.health.title": "体检",
|
|
116
|
-
"settings.health.desc": "
|
|
136
|
+
"settings.health.desc": "检查指向已不存在会话的登记条目(只读;需要时手动运行)。",
|
|
117
137
|
"settings.health.ok": "未发现失效引用。",
|
|
138
|
+
"settings.health.idle": "尚未体检。点「运行体检」会扫描全库会话(只读)。",
|
|
139
|
+
"settings.health.run": "运行体检",
|
|
118
140
|
"settings.health.items": "{n} 条待清理",
|
|
119
141
|
"settings.health.unavailable": "无法体检:{reason}",
|
|
120
142
|
"settings.health.clean": "清理 {n} 条",
|
|
@@ -175,10 +197,24 @@ window.__ModuleLoader__.load({
|
|
|
175
197
|
"panel.size": "{size}",
|
|
176
198
|
"panel.trashedAt": "{time}",
|
|
177
199
|
"panel.unknown": "{n} unrecognized director(ies) kept",
|
|
178
|
-
"panel.pending":
|
|
200
|
+
"panel.pending":
|
|
201
|
+
"{n} unfinished operation(s) (reconciled on next start; leftovers need review)",
|
|
179
202
|
"panel.readOnly":
|
|
180
203
|
"Read-only: this DSH version is missing required APIs; deletion is disabled.",
|
|
181
204
|
"panel.close": "Close",
|
|
205
|
+
"receipt.refs": "References",
|
|
206
|
+
"receipt.removed": "References cleaned",
|
|
207
|
+
"receipt.checks": "Checks",
|
|
208
|
+
"receipt.summary.ok": "all passed",
|
|
209
|
+
"receipt.summary.partial": "{n} did not pass",
|
|
210
|
+
"restore.detail.title": "References and checks that did not pass",
|
|
211
|
+
"restore.detail.retry": "Retry the failed references",
|
|
212
|
+
"restore.detail.retrying": "Retrying…",
|
|
213
|
+
"restore.detail.retried": "retried once automatically",
|
|
214
|
+
"restore.retry.ok": "Re-check passed: every reference and check recovered",
|
|
215
|
+
"restore.retry.partial": "{n} still did not pass after the re-check",
|
|
216
|
+
"restore.busyHint":
|
|
217
|
+
"If sending is rejected (session/agent-busy), the host still marks this session busy: restart DSH, or continue in a new session.",
|
|
182
218
|
"trash.selectAll": "Select all",
|
|
183
219
|
"trash.selectCount": "{n}/{total} selected",
|
|
184
220
|
"trash.restoreMany": "Restore ({n})",
|
|
@@ -188,7 +224,16 @@ window.__ModuleLoader__.load({
|
|
|
188
224
|
"batch.stop": "Stop",
|
|
189
225
|
"batch.done": "Done: {ok}/{total} succeeded",
|
|
190
226
|
"batch.failed": "{n} failed; kept selected",
|
|
227
|
+
"batch.partial": "{n} restored with incomplete references",
|
|
191
228
|
"toast.failed": "Operation failed: {message}",
|
|
229
|
+
"toast.trashPartial":
|
|
230
|
+
"Moved to the trash, but cleanup did not finish: {message} (the session is restorable)",
|
|
231
|
+
"toast.restorePartial":
|
|
232
|
+
"Session restored, but {n} reference/check(s) did not pass (see the receipt)",
|
|
233
|
+
"toast.undoFailed": "Undo failed: {message}",
|
|
234
|
+
"toast.trashedCurrent": "Moved to the trash — restore it from there",
|
|
235
|
+
"toast.restored": "Session restored — reopening it",
|
|
236
|
+
"toast.restoredMany": "Restored {n} session(s); refreshing the list",
|
|
192
237
|
"settings.nav": "Session trash",
|
|
193
238
|
"settings.group.delete": "Deletion preferences",
|
|
194
239
|
"settings.cascade.title": 'Remember "also delete child sessions"',
|
|
@@ -201,8 +246,10 @@ window.__ModuleLoader__.load({
|
|
|
201
246
|
"settings.group.maintenance": "Maintenance",
|
|
202
247
|
"settings.health.title": "Health",
|
|
203
248
|
"settings.health.desc":
|
|
204
|
-
"Checks bookkeeping that points at sessions that no longer exist (read-only).",
|
|
249
|
+
"Checks bookkeeping that points at sessions that no longer exist (read-only; run it on demand).",
|
|
205
250
|
"settings.health.ok": "No dangling references found.",
|
|
251
|
+
"settings.health.idle": "No check yet. Run it to scan the whole library (read-only).",
|
|
252
|
+
"settings.health.run": "Run check",
|
|
206
253
|
"settings.health.items": "{n} to clean",
|
|
207
254
|
"settings.health.unavailable": "Cannot run the check: {reason}",
|
|
208
255
|
"settings.health.clean": "Clean {n}",
|
|
@@ -268,6 +315,8 @@ window.__ModuleLoader__.load({
|
|
|
268
315
|
title: props.title,
|
|
269
316
|
"aria-label": props.ariaLabel,
|
|
270
317
|
"data-modal-autofocus": props.modalAutofocus ? "" : undefined,
|
|
318
|
+
// 稳定的动作锚点:冒烟/桌面回归按它定位,不再依赖 CSS class 或文案。
|
|
319
|
+
"data-session-delete-action": props.action,
|
|
271
320
|
onClick: props.onClick,
|
|
272
321
|
className: `dsh-sdel-btn${variant}${quiet}${props.tight ? " dsh-sdel-btn--tight" : ""}`,
|
|
273
322
|
style: {
|
|
@@ -341,7 +390,10 @@ window.__ModuleLoader__.load({
|
|
|
341
390
|
function SettingRow(/** @type {any} */ props) {
|
|
342
391
|
return h(
|
|
343
392
|
"div",
|
|
344
|
-
{
|
|
393
|
+
{
|
|
394
|
+
className: "dsh-sdel-setting-row",
|
|
395
|
+
"data-session-delete-setting-row": props.anchor,
|
|
396
|
+
},
|
|
345
397
|
h(
|
|
346
398
|
"div",
|
|
347
399
|
{ className: "dsh-sdel-setting-text" },
|
|
@@ -368,6 +420,7 @@ window.__ModuleLoader__.load({
|
|
|
368
420
|
{
|
|
369
421
|
type: "button",
|
|
370
422
|
className: "dsh-sdel-disclosure",
|
|
423
|
+
"data-session-delete-disclosure": props.anchor,
|
|
371
424
|
"aria-expanded": open ? "true" : "false",
|
|
372
425
|
onClick: () => setOpen(!open),
|
|
373
426
|
},
|
|
@@ -593,6 +646,137 @@ window.__ModuleLoader__.load({
|
|
|
593
646
|
return String(error);
|
|
594
647
|
}
|
|
595
648
|
|
|
649
|
+
/**
|
|
650
|
+
* 「会话已进回收站、只是收尾没做完」(AUD-SD-03)。
|
|
651
|
+
* RPC 的 RemoteError 会保留 details;同时容忍 partial 直接挂在错误上。
|
|
652
|
+
* @param {any} reason
|
|
653
|
+
*/
|
|
654
|
+
function isPartialFailure(reason) {
|
|
655
|
+
if (!reason || typeof reason !== "object") return false;
|
|
656
|
+
if (reason.code === "session-delete/partial") return true;
|
|
657
|
+
if (reason.partial === true) return true;
|
|
658
|
+
return reason.details?.partial === true;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* 删除失败要按磁盘事实说话:已进回收站但收尾失败 ≠ 删除失败。
|
|
663
|
+
* @param {any} reason
|
|
664
|
+
* @param {(key: string, values?: any) => string} t
|
|
665
|
+
*/
|
|
666
|
+
function trashFailureText(reason, t) {
|
|
667
|
+
if (isPartialFailure(reason)) return t("toast.trashPartial", { message: errorText(reason) });
|
|
668
|
+
return errorText(reason);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* 恢复的收尾提示:引用/校验没全过时返回一句「哪里不完整」,全过时返回 null。
|
|
673
|
+
* @param {any} result
|
|
674
|
+
* @param {(key: string, values?: any) => string} t
|
|
675
|
+
* @returns {string | null}
|
|
676
|
+
*/
|
|
677
|
+
function restoreNotice(result, t) {
|
|
678
|
+
var failedRefs = Array.isArray(result?.refs)
|
|
679
|
+
? result.refs.filter((/** @type {any} */ item) => item.status === "failed").length
|
|
680
|
+
: 0;
|
|
681
|
+
var failedChecks = Array.isArray(result?.checks)
|
|
682
|
+
? result.checks.filter((/** @type {any} */ item) => item.status === "failed").length
|
|
683
|
+
: 0;
|
|
684
|
+
var count = failedRefs + failedChecks;
|
|
685
|
+
if (result?.partial === true && count === 0) count = 1;
|
|
686
|
+
if (count === 0) return null;
|
|
687
|
+
return t("toast.restorePartial", { n: count });
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* 恢复结果里「没通过」的逐项清单(USIM-U3-05):引用在前、校验在后。
|
|
692
|
+
* 新宿主直接给 `failures`(带 label/detail);老宿主只有 refs/checks,
|
|
693
|
+
* 这里按同一形状兜底,界面不用关心宿主版本。
|
|
694
|
+
* @param {any} result
|
|
695
|
+
* @returns {{ id: string, label: string, detail: string, kind: "ref" | "check" }[]}
|
|
696
|
+
*/
|
|
697
|
+
function restoreFailures(result) {
|
|
698
|
+
/** @type {{ id: string, label: string, detail: string, kind: "ref" | "check" }[]} */
|
|
699
|
+
var out = [];
|
|
700
|
+
var failures = Array.isArray(result?.failures) ? result.failures : null;
|
|
701
|
+
/** @type {any} */
|
|
702
|
+
var item;
|
|
703
|
+
/** @type {any} */
|
|
704
|
+
var group;
|
|
705
|
+
/** @type {any} */
|
|
706
|
+
var entry;
|
|
707
|
+
if (failures) {
|
|
708
|
+
for (let index = 0; index < failures.length; index += 1) {
|
|
709
|
+
item = failures[index] || {};
|
|
710
|
+
out.push({
|
|
711
|
+
id: String(item.id || ""),
|
|
712
|
+
label: String(item.label || item.id || ""),
|
|
713
|
+
detail: String(item.detail || ""),
|
|
714
|
+
kind: "ref",
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
return out;
|
|
718
|
+
}
|
|
719
|
+
/** @type {{ list: any[] | undefined, kind: "ref" | "check" }[]} */
|
|
720
|
+
var groups = [
|
|
721
|
+
{ list: result?.refs, kind: "ref" },
|
|
722
|
+
{ list: result?.checks, kind: "check" },
|
|
723
|
+
];
|
|
724
|
+
for (let groupIndex = 0; groupIndex < groups.length; groupIndex += 1) {
|
|
725
|
+
group = groups[groupIndex];
|
|
726
|
+
if (!Array.isArray(group.list)) continue;
|
|
727
|
+
for (let itemIndex = 0; itemIndex < group.list.length; itemIndex += 1) {
|
|
728
|
+
entry = group.list[itemIndex] || {};
|
|
729
|
+
if (entry.status !== "failed") continue;
|
|
730
|
+
out.push({
|
|
731
|
+
id: String(entry.id || ""),
|
|
732
|
+
label: String(entry.label || entry.id || ""),
|
|
733
|
+
detail: String(entry.detail || ""),
|
|
734
|
+
kind: group.kind,
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return out;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* 恢复失败时给界面看的多行文本:哪一处没通过 + 下一步做什么。
|
|
743
|
+
* @param {{ label: string, detail: string }[]} failures
|
|
744
|
+
* @returns {string | null}
|
|
745
|
+
*/
|
|
746
|
+
function restoreDetailText(failures) {
|
|
747
|
+
if (!Array.isArray(failures) || failures.length === 0) return null;
|
|
748
|
+
var lines = [];
|
|
749
|
+
/** @type {any} */
|
|
750
|
+
var item;
|
|
751
|
+
for (let index = 0; index < failures.length; index += 1) {
|
|
752
|
+
item = failures[index];
|
|
753
|
+
lines.push(item.label ? `${item.label}:${item.detail}` : item.detail);
|
|
754
|
+
}
|
|
755
|
+
return lines.join("\n");
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* 删除当前正在看的会话后该去哪(USIM-U2-05):优先下一个可用会话,没有就回新会话页。
|
|
760
|
+
* 纯函数,便于单测钉住「不要把人留在已删除的会话上」。
|
|
761
|
+
* @param {{ deletedId?: string | null, currentId?: string | null, candidates?: string[] }} input
|
|
762
|
+
* @returns {{ navigate: boolean, target: "session" | "home" | "none", id?: string }}
|
|
763
|
+
*/
|
|
764
|
+
function afterTrashNavigation(input) {
|
|
765
|
+
var deletedId = typeof input?.deletedId === "string" ? input.deletedId : "";
|
|
766
|
+
var currentId = typeof input?.currentId === "string" ? input.currentId : "";
|
|
767
|
+
if (!deletedId || currentId !== deletedId) return { navigate: false, target: "none" };
|
|
768
|
+
var candidates = Array.isArray(input?.candidates) ? input.candidates : [];
|
|
769
|
+
/** @type {any} */
|
|
770
|
+
var id;
|
|
771
|
+
for (let index = 0; index < candidates.length; index += 1) {
|
|
772
|
+
id = candidates[index];
|
|
773
|
+
if (typeof id === "string" && id.length > 0 && id !== deletedId) {
|
|
774
|
+
return { navigate: true, target: "session", id: id };
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return { navigate: true, target: "home" };
|
|
778
|
+
}
|
|
779
|
+
|
|
596
780
|
function DeleteSessionMenuItem(/** @type {any} */ props) {
|
|
597
781
|
var menuState =
|
|
598
782
|
typeof props.useMenuOpenState === "function" ? props.useMenuOpenState() : [false, () => {}];
|
|
@@ -664,6 +848,7 @@ window.__ModuleLoader__.load({
|
|
|
664
848
|
"aria-label": label,
|
|
665
849
|
onClick: () => props.openPanel(),
|
|
666
850
|
className: "dsh-sdel-footer",
|
|
851
|
+
"data-session-delete-footer": "",
|
|
667
852
|
style: {
|
|
668
853
|
display: "flex",
|
|
669
854
|
alignItems: "center",
|
|
@@ -682,6 +867,8 @@ window.__ModuleLoader__.load({
|
|
|
682
867
|
? h(
|
|
683
868
|
"span",
|
|
684
869
|
{
|
|
870
|
+
"data-session-delete-count": "",
|
|
871
|
+
"data-session-delete-count-value": String(count),
|
|
685
872
|
style: {
|
|
686
873
|
marginLeft: props.wide ? "auto" : 0,
|
|
687
874
|
minWidth: "16px",
|
|
@@ -805,11 +992,39 @@ window.__ModuleLoader__.load({
|
|
|
805
992
|
.then((/** @type {any} */ result) => {
|
|
806
993
|
props.requestStore.set(null);
|
|
807
994
|
if (isWorkspace) props.onTrashedMany?.(result);
|
|
808
|
-
else
|
|
995
|
+
else
|
|
996
|
+
props.onTrashed?.(
|
|
997
|
+
Object.assign({}, result, {
|
|
998
|
+
wasCurrent: request.currentId === request.sessionId,
|
|
999
|
+
workspaceId: request.workspaceId ?? null,
|
|
1000
|
+
}),
|
|
1001
|
+
);
|
|
809
1002
|
})
|
|
810
1003
|
.catch((/** @type {any} */ reason) => {
|
|
811
1004
|
setBusy(false);
|
|
812
|
-
|
|
1005
|
+
if (!isWorkspace && isPartialFailure(reason)) {
|
|
1006
|
+
// 已移入回收站但收尾失败(AUD-SD-03):磁盘事实变了,别让用户以为「删除失败」
|
|
1007
|
+
// 再点一次(重试只会得到 not-found)。关框、按事实提示、照常刷新列表。
|
|
1008
|
+
props.requestStore.set(null);
|
|
1009
|
+
const partialEntryId = reason?.details?.entryId ?? null;
|
|
1010
|
+
props.onTrashed?.({
|
|
1011
|
+
sessionId: request.sessionId,
|
|
1012
|
+
entryId: partialEntryId,
|
|
1013
|
+
title: request.title || null,
|
|
1014
|
+
wasCurrent: request.currentId === request.sessionId,
|
|
1015
|
+
workspaceId: request.workspaceId ?? null,
|
|
1016
|
+
});
|
|
1017
|
+
// 错误 toast 也带上 entryId:partial 的「已进回收站」仍然给撤销入口,
|
|
1018
|
+
// 否则用户只剩面板一条路(复审 F12)。
|
|
1019
|
+
props.toastStore?.set({
|
|
1020
|
+
entryId: partialEntryId,
|
|
1021
|
+
title: request.title || null,
|
|
1022
|
+
text: trashFailureText(reason, props.t),
|
|
1023
|
+
error: true,
|
|
1024
|
+
});
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
setError(trashFailureText(reason, props.t));
|
|
813
1028
|
});
|
|
814
1029
|
};
|
|
815
1030
|
|
|
@@ -838,11 +1053,14 @@ window.__ModuleLoader__.load({
|
|
|
838
1053
|
request.title,
|
|
839
1054
|
)
|
|
840
1055
|
: null,
|
|
841
|
-
h("div", { style: { color: T.dim } }, impact),
|
|
1056
|
+
h("div", { style: { color: T.dim }, "data-session-delete-impact": "" }, impact),
|
|
842
1057
|
!isWorkspace && removes.length > 0
|
|
843
1058
|
? h(
|
|
844
1059
|
"div",
|
|
845
|
-
{
|
|
1060
|
+
{
|
|
1061
|
+
style: { color: T.faint, fontSize: "12px", marginTop: "2px" },
|
|
1062
|
+
"data-session-delete-refs": "",
|
|
1063
|
+
},
|
|
846
1064
|
props.t("confirm.refs", { n: removes.length }),
|
|
847
1065
|
)
|
|
848
1066
|
: null,
|
|
@@ -875,11 +1093,21 @@ window.__ModuleLoader__.load({
|
|
|
875
1093
|
blocked
|
|
876
1094
|
? h(
|
|
877
1095
|
"div",
|
|
878
|
-
{
|
|
1096
|
+
{
|
|
1097
|
+
style: { color: T.danger, marginTop: "10px" },
|
|
1098
|
+
role: "alert",
|
|
1099
|
+
"data-session-delete-blocked": "",
|
|
1100
|
+
},
|
|
879
1101
|
props.t("confirm.blocked", { reason: plan.blockers[0].message }),
|
|
880
1102
|
)
|
|
881
1103
|
: null,
|
|
882
|
-
error
|
|
1104
|
+
error
|
|
1105
|
+
? h(
|
|
1106
|
+
"div",
|
|
1107
|
+
{ style: { color: T.danger, marginTop: "8px" }, "data-session-delete-error": "" },
|
|
1108
|
+
error,
|
|
1109
|
+
)
|
|
1110
|
+
: null,
|
|
883
1111
|
plan
|
|
884
1112
|
? h(
|
|
885
1113
|
"div",
|
|
@@ -956,13 +1184,14 @@ window.__ModuleLoader__.load({
|
|
|
956
1184
|
null,
|
|
957
1185
|
h(
|
|
958
1186
|
Btn,
|
|
959
|
-
{ innerRef: cancelRef, onClick: close, disabled: busy },
|
|
1187
|
+
{ innerRef: cancelRef, action: "cancel", onClick: close, disabled: busy },
|
|
960
1188
|
props.t("confirm.cancel"),
|
|
961
1189
|
),
|
|
962
1190
|
h(
|
|
963
1191
|
Btn,
|
|
964
1192
|
{
|
|
965
1193
|
innerRef: confirmRef,
|
|
1194
|
+
action: "confirm",
|
|
966
1195
|
modalAutofocus: true,
|
|
967
1196
|
onClick: confirm,
|
|
968
1197
|
variant: "danger",
|
|
@@ -1008,6 +1237,13 @@ window.__ModuleLoader__.load({
|
|
|
1008
1237
|
var readOnlyState = React.useState(false);
|
|
1009
1238
|
var readOnly = readOnlyState[0];
|
|
1010
1239
|
var setReadOnly = readOnlyState[1];
|
|
1240
|
+
// 恢复结果里没通过的引用(USIM-U3-05):留住清单,界面才能「可展开 + 可重试」。
|
|
1241
|
+
var restoreDetailState = React.useState(null);
|
|
1242
|
+
var restoreDetail = restoreDetailState[0];
|
|
1243
|
+
var setRestoreDetail = restoreDetailState[1];
|
|
1244
|
+
var retryingState = React.useState(false);
|
|
1245
|
+
var retrying = retryingState[0];
|
|
1246
|
+
var setRetrying = retryingState[1];
|
|
1011
1247
|
var batchControl = React.useRef({ stop: false });
|
|
1012
1248
|
|
|
1013
1249
|
var loader = React.useMemo(
|
|
@@ -1052,19 +1288,75 @@ window.__ModuleLoader__.load({
|
|
|
1052
1288
|
|
|
1053
1289
|
var doRestore = (/** @type {any} */ entryId, /** @type {any} */ sessionId) => {
|
|
1054
1290
|
setBusyId(entryId);
|
|
1291
|
+
setRestoreDetail(null);
|
|
1055
1292
|
props
|
|
1056
1293
|
.call("restore", { entryId: entryId })
|
|
1057
|
-
.then(() => {
|
|
1294
|
+
.then((/** @type {any} */ result) => {
|
|
1058
1295
|
setBusyId(null);
|
|
1059
1296
|
refresh();
|
|
1060
1297
|
props.bump?.();
|
|
1061
|
-
|
|
1298
|
+
var failures = restoreFailures(result);
|
|
1299
|
+
if (failures.length === 0) {
|
|
1300
|
+
// 恢复成功的终点就是「回到会话里」:先关框再重开(USIM-U2-17)。
|
|
1301
|
+
// 成功路径只走 onRestoreComplete 一处(N2:以前这里还会再调一次
|
|
1302
|
+
// onRestored,导致 refreshRows + openSession 各跑两遍)。
|
|
1303
|
+
setError(null);
|
|
1304
|
+
setRestoreDetail(null);
|
|
1305
|
+
props.onRestoreComplete?.(result);
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
// 没全过:仍要把 retired 清掉并刷新列表,再把话说清楚(AUD-SD-02)。
|
|
1309
|
+
props.onRestored?.(result?.sessionId || sessionId, { open: false });
|
|
1310
|
+
setError(restoreNotice(result, props.t));
|
|
1311
|
+
setRestoreDetail({
|
|
1312
|
+
sessionId: result?.sessionId || sessionId,
|
|
1313
|
+
result: result,
|
|
1314
|
+
failures: failures,
|
|
1315
|
+
});
|
|
1062
1316
|
})
|
|
1063
1317
|
.catch((/** @type {any} */ reason) => {
|
|
1064
1318
|
setBusyId(null);
|
|
1065
1319
|
setError(errorText(reason));
|
|
1066
1320
|
});
|
|
1067
1321
|
};
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* 重检未通过的引用(USIM-U3-05 的可操作出口):宿主按回执里的快照重放一次。
|
|
1325
|
+
*/
|
|
1326
|
+
var retryFailedRefs = () => {
|
|
1327
|
+
if (!restoreDetail || retrying) return;
|
|
1328
|
+
setRetrying(true);
|
|
1329
|
+
props
|
|
1330
|
+
.call("recheckRestore", {
|
|
1331
|
+
receiptId:
|
|
1332
|
+
typeof restoreDetail.result?.receiptId === "string"
|
|
1333
|
+
? restoreDetail.result.receiptId
|
|
1334
|
+
: undefined,
|
|
1335
|
+
sessionId: restoreDetail.sessionId,
|
|
1336
|
+
})
|
|
1337
|
+
.then((/** @type {any} */ result) => {
|
|
1338
|
+
setRetrying(false);
|
|
1339
|
+
props.bump?.();
|
|
1340
|
+
var left = restoreFailures(result);
|
|
1341
|
+
if (left.length === 0) {
|
|
1342
|
+
setError(props.t("restore.retry.ok"));
|
|
1343
|
+
setRestoreDetail(null);
|
|
1344
|
+
props.onRestored?.(result?.sessionId || restoreDetail.sessionId);
|
|
1345
|
+
refresh();
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
setError(props.t("restore.retry.partial", { n: left.length }));
|
|
1349
|
+
setRestoreDetail({
|
|
1350
|
+
sessionId: result?.sessionId || restoreDetail.sessionId,
|
|
1351
|
+
result: result,
|
|
1352
|
+
failures: left,
|
|
1353
|
+
});
|
|
1354
|
+
})
|
|
1355
|
+
.catch((/** @type {any} */ reason) => {
|
|
1356
|
+
setRetrying(false);
|
|
1357
|
+
setError(errorText(reason));
|
|
1358
|
+
});
|
|
1359
|
+
};
|
|
1068
1360
|
var doPurge = (/** @type {any} */ entryId, /** @type {any} */ sessionId) => {
|
|
1069
1361
|
setBusyId(entryId);
|
|
1070
1362
|
props
|
|
@@ -1101,7 +1393,8 @@ window.__ModuleLoader__.load({
|
|
|
1101
1393
|
setBatch(state);
|
|
1102
1394
|
},
|
|
1103
1395
|
shouldStop: () => batchControl.current.stop === true,
|
|
1104
|
-
onRestored: (/** @type {any} */ sessionId) =>
|
|
1396
|
+
onRestored: (/** @type {any} */ sessionId, /** @type {any} */ info) =>
|
|
1397
|
+
props.onRestored?.(sessionId, info),
|
|
1105
1398
|
}).then((/** @type {any} */ summary) => {
|
|
1106
1399
|
setSelected((/** @type {any} */ current) => {
|
|
1107
1400
|
/** @type {Record<string, boolean>} */
|
|
@@ -1117,12 +1410,16 @@ window.__ModuleLoader__.load({
|
|
|
1117
1410
|
refresh();
|
|
1118
1411
|
props.bump?.();
|
|
1119
1412
|
if (kind === "purge") props.onPurged?.(undefined);
|
|
1413
|
+
// 批量恢复全绿时同样「完成即关框」(U2-17 的批量版);有失败就留在面板里看清单。
|
|
1414
|
+
if (kind === "restore" && summary.failures.length === 0) {
|
|
1415
|
+
props.onBatchRestoreDone?.(summary);
|
|
1416
|
+
}
|
|
1120
1417
|
});
|
|
1121
1418
|
};
|
|
1122
1419
|
|
|
1123
1420
|
var toolbar = h(
|
|
1124
1421
|
"div",
|
|
1125
|
-
{ className: "dsh-sdel-toolbar" },
|
|
1422
|
+
{ className: "dsh-sdel-toolbar", "data-session-delete-toolbar": "" },
|
|
1126
1423
|
h(Check, {
|
|
1127
1424
|
checked: allSelected,
|
|
1128
1425
|
disabled: batchRunning || entries.length === 0,
|
|
@@ -1146,6 +1443,7 @@ window.__ModuleLoader__.load({
|
|
|
1146
1443
|
Btn,
|
|
1147
1444
|
{
|
|
1148
1445
|
disabled: batchRunning || selectedIds.length === 0,
|
|
1446
|
+
action: "batch-restore",
|
|
1149
1447
|
onClick: () => startBatch(selectedIds, "restore"),
|
|
1150
1448
|
},
|
|
1151
1449
|
props.t("trash.restoreMany", { n: selectedIds.length }),
|
|
@@ -1155,6 +1453,7 @@ window.__ModuleLoader__.load({
|
|
|
1155
1453
|
{
|
|
1156
1454
|
variant: "danger",
|
|
1157
1455
|
disabled: batchRunning || selectedIds.length === 0,
|
|
1456
|
+
action: "batch-purge",
|
|
1158
1457
|
onClick: () => setConfirmPurge("__batch__"),
|
|
1159
1458
|
},
|
|
1160
1459
|
props.t("trash.purgeMany", { n: selectedIds.length }),
|
|
@@ -1164,7 +1463,7 @@ window.__ModuleLoader__.load({
|
|
|
1164
1463
|
var batchLine = batch
|
|
1165
1464
|
? h(
|
|
1166
1465
|
"div",
|
|
1167
|
-
{ className: "dsh-sdel-batch" },
|
|
1466
|
+
{ className: "dsh-sdel-batch", "data-session-delete-batch": "" },
|
|
1168
1467
|
h(
|
|
1169
1468
|
"span",
|
|
1170
1469
|
{ role: "status" },
|
|
@@ -1178,10 +1477,17 @@ window.__ModuleLoader__.load({
|
|
|
1178
1477
|
batch.failures.length > 0
|
|
1179
1478
|
? h(
|
|
1180
1479
|
"span",
|
|
1181
|
-
{ style: { color: T.danger } },
|
|
1480
|
+
{ style: { color: T.danger }, "data-session-delete-batch-failed": "" },
|
|
1182
1481
|
props.t("batch.failed", { n: batch.failures.length }),
|
|
1183
1482
|
)
|
|
1184
1483
|
: null,
|
|
1484
|
+
batch.partials > 0
|
|
1485
|
+
? h(
|
|
1486
|
+
"span",
|
|
1487
|
+
{ style: { color: T.danger }, "data-session-delete-batch-partial": "" },
|
|
1488
|
+
props.t("batch.partial", { n: batch.partials }),
|
|
1489
|
+
)
|
|
1490
|
+
: null,
|
|
1185
1491
|
batch.running
|
|
1186
1492
|
? h(
|
|
1187
1493
|
Btn,
|
|
@@ -1201,20 +1507,21 @@ window.__ModuleLoader__.load({
|
|
|
1201
1507
|
confirmPurge === "__batch__"
|
|
1202
1508
|
? h(
|
|
1203
1509
|
"div",
|
|
1204
|
-
{ className: "dsh-sdel-confirm" },
|
|
1510
|
+
{ className: "dsh-sdel-confirm", "data-session-delete-confirm-row": "" },
|
|
1205
1511
|
h("span", null, props.t("trash.purgeManyConfirm", { n: selectedIds.length })),
|
|
1206
1512
|
h(
|
|
1207
1513
|
Btn,
|
|
1208
1514
|
{
|
|
1209
1515
|
tight: true,
|
|
1210
1516
|
variant: "danger",
|
|
1517
|
+
action: "batch-purge-confirm",
|
|
1211
1518
|
onClick: () => startBatch(selectedIds, "purge"),
|
|
1212
1519
|
},
|
|
1213
1520
|
props.t("panel.purge"),
|
|
1214
1521
|
),
|
|
1215
1522
|
h(
|
|
1216
1523
|
Btn,
|
|
1217
|
-
{ tight: true, onClick: () => setConfirmPurge(null) },
|
|
1524
|
+
{ tight: true, action: "batch-purge-cancel", onClick: () => setConfirmPurge(null) },
|
|
1218
1525
|
props.t("panel.cancelConfirm"),
|
|
1219
1526
|
),
|
|
1220
1527
|
)
|
|
@@ -1227,7 +1534,12 @@ window.__ModuleLoader__.load({
|
|
|
1227
1534
|
rows.push(
|
|
1228
1535
|
h(
|
|
1229
1536
|
"div",
|
|
1230
|
-
{
|
|
1537
|
+
{
|
|
1538
|
+
key: entry.entryId,
|
|
1539
|
+
className: "dsh-sdel-row",
|
|
1540
|
+
"data-session-delete-row": String(entry.entryId),
|
|
1541
|
+
"data-session-delete-row-session": String(entry.sessionId ?? ""),
|
|
1542
|
+
},
|
|
1231
1543
|
h(Check, {
|
|
1232
1544
|
checked: Boolean(selected[entry.entryId]),
|
|
1233
1545
|
disabled: batchRunning,
|
|
@@ -1245,41 +1557,51 @@ window.__ModuleLoader__.load({
|
|
|
1245
1557
|
{
|
|
1246
1558
|
className: "dsh-sdel-row-title dsh-sdel-truncate",
|
|
1247
1559
|
title: entry.title || entry.sessionId,
|
|
1560
|
+
"data-session-delete-row-title": "",
|
|
1248
1561
|
},
|
|
1249
1562
|
entry.title || entry.sessionId,
|
|
1250
1563
|
),
|
|
1251
1564
|
h(
|
|
1252
1565
|
"span",
|
|
1253
|
-
{ className: "dsh-sdel-row-meta" },
|
|
1566
|
+
{ className: "dsh-sdel-row-meta", "data-session-delete-row-meta": "" },
|
|
1254
1567
|
`${props.t("panel.size", { size: formatBytes(entry.bytes) })} · ${props.t("panel.trashedAt", { time: formatTime(entry.trashedAt) })}`,
|
|
1255
1568
|
),
|
|
1256
1569
|
),
|
|
1257
1570
|
confirmThis
|
|
1258
1571
|
? h(
|
|
1259
1572
|
"span",
|
|
1260
|
-
{
|
|
1573
|
+
{
|
|
1574
|
+
className: "dsh-sdel-row-actions dsh-sdel-row-actions--open",
|
|
1575
|
+
"data-session-delete-row-actions": "confirm",
|
|
1576
|
+
},
|
|
1261
1577
|
h(
|
|
1262
1578
|
Btn,
|
|
1263
1579
|
{
|
|
1264
1580
|
tight: true,
|
|
1265
1581
|
variant: "danger",
|
|
1582
|
+
action: "row-purge-confirm",
|
|
1266
1583
|
onClick: () => doPurge(entry.entryId, entry.sessionId),
|
|
1267
1584
|
},
|
|
1268
1585
|
props.t("panel.purgeConfirm"),
|
|
1269
1586
|
),
|
|
1270
1587
|
h(
|
|
1271
1588
|
Btn,
|
|
1272
|
-
{
|
|
1589
|
+
{
|
|
1590
|
+
tight: true,
|
|
1591
|
+
action: "row-purge-cancel",
|
|
1592
|
+
onClick: () => setConfirmPurge(null),
|
|
1593
|
+
},
|
|
1273
1594
|
props.t("panel.cancelConfirm"),
|
|
1274
1595
|
),
|
|
1275
1596
|
)
|
|
1276
1597
|
: h(
|
|
1277
1598
|
"span",
|
|
1278
|
-
{ className: "dsh-sdel-row-actions" },
|
|
1599
|
+
{ className: "dsh-sdel-row-actions", "data-session-delete-row-actions": "" },
|
|
1279
1600
|
h(
|
|
1280
1601
|
Btn,
|
|
1281
1602
|
{
|
|
1282
1603
|
tight: true,
|
|
1604
|
+
action: "row-restore",
|
|
1283
1605
|
disabled: busyId === entry.entryId || batchRunning,
|
|
1284
1606
|
onClick: () => doRestore(entry.entryId, entry.sessionId),
|
|
1285
1607
|
},
|
|
@@ -1290,6 +1612,7 @@ window.__ModuleLoader__.load({
|
|
|
1290
1612
|
{
|
|
1291
1613
|
tight: true,
|
|
1292
1614
|
variant: "danger",
|
|
1615
|
+
action: "row-purge",
|
|
1293
1616
|
disabled: busyId === entry.entryId || batchRunning,
|
|
1294
1617
|
onClick: () => setConfirmPurge(entry.entryId),
|
|
1295
1618
|
},
|
|
@@ -1306,32 +1629,107 @@ window.__ModuleLoader__.load({
|
|
|
1306
1629
|
readOnly
|
|
1307
1630
|
? h(
|
|
1308
1631
|
"div",
|
|
1309
|
-
{
|
|
1632
|
+
{
|
|
1633
|
+
style: { color: T.danger, marginBottom: "10px" },
|
|
1634
|
+
"data-session-delete-readonly": "",
|
|
1635
|
+
},
|
|
1310
1636
|
props.t("panel.readOnly"),
|
|
1311
1637
|
)
|
|
1312
1638
|
: null,
|
|
1313
|
-
error
|
|
1639
|
+
error
|
|
1640
|
+
? h(
|
|
1641
|
+
"div",
|
|
1642
|
+
{ style: { color: T.danger, marginBottom: "10px" }, "data-session-delete-error": "" },
|
|
1643
|
+
error,
|
|
1644
|
+
)
|
|
1645
|
+
: null,
|
|
1646
|
+
restoreDetail
|
|
1647
|
+
? h(
|
|
1648
|
+
"div",
|
|
1649
|
+
{
|
|
1650
|
+
className: "dsh-sdel-restore-detail",
|
|
1651
|
+
"data-session-delete-restore-detail": "",
|
|
1652
|
+
role: "alert",
|
|
1653
|
+
style: {
|
|
1654
|
+
border: `1px solid ${T.border}`,
|
|
1655
|
+
borderRadius: "8px",
|
|
1656
|
+
padding: "8px 10px",
|
|
1657
|
+
marginBottom: "10px",
|
|
1658
|
+
fontSize: "12px",
|
|
1659
|
+
color: T.dim,
|
|
1660
|
+
},
|
|
1661
|
+
},
|
|
1662
|
+
h(
|
|
1663
|
+
"div",
|
|
1664
|
+
{ style: { color: T.danger, fontWeight: 600, marginBottom: "4px" } },
|
|
1665
|
+
props.t("restore.detail.title"),
|
|
1666
|
+
),
|
|
1667
|
+
restoreDetail.failures.map((/** @type {any} */ item, /** @type {number} */ index) =>
|
|
1668
|
+
h(
|
|
1669
|
+
"div",
|
|
1670
|
+
{
|
|
1671
|
+
key: `restore-failure-${index}`,
|
|
1672
|
+
className: "dsh-sdel-truncate",
|
|
1673
|
+
title: `${item.label}:${item.detail}`,
|
|
1674
|
+
"data-session-delete-restore-failure": item.id,
|
|
1675
|
+
},
|
|
1676
|
+
`${item.label}:${item.detail}`,
|
|
1677
|
+
),
|
|
1678
|
+
),
|
|
1679
|
+
restoreDetail.result?.wasLive === true
|
|
1680
|
+
? h(
|
|
1681
|
+
"div",
|
|
1682
|
+
{ style: { marginTop: "6px", color: T.faint } },
|
|
1683
|
+
props.t("restore.busyHint"),
|
|
1684
|
+
)
|
|
1685
|
+
: null,
|
|
1686
|
+
h(
|
|
1687
|
+
"div",
|
|
1688
|
+
{ style: { marginTop: "8px" } },
|
|
1689
|
+
h(
|
|
1690
|
+
Btn,
|
|
1691
|
+
{
|
|
1692
|
+
tight: true,
|
|
1693
|
+
action: "restore-retry",
|
|
1694
|
+
disabled: retrying,
|
|
1695
|
+
onClick: retryFailedRefs,
|
|
1696
|
+
},
|
|
1697
|
+
retrying ? props.t("restore.detail.retrying") : props.t("restore.detail.retry"),
|
|
1698
|
+
),
|
|
1699
|
+
),
|
|
1700
|
+
)
|
|
1701
|
+
: null,
|
|
1314
1702
|
entries.length === 0
|
|
1315
|
-
? h(
|
|
1703
|
+
? h(
|
|
1704
|
+
"div",
|
|
1705
|
+
{ "data-session-delete-panel": "", "data-session-delete-empty": "" },
|
|
1706
|
+
h("div", { style: { color: T.dim, padding: "12px 0" } }, props.t("panel.empty")),
|
|
1707
|
+
)
|
|
1316
1708
|
: h(
|
|
1317
1709
|
"div",
|
|
1318
|
-
{ className: "dsh-sdel-panel" },
|
|
1710
|
+
{ className: "dsh-sdel-panel", "data-session-delete-panel": "" },
|
|
1319
1711
|
toolbar,
|
|
1320
1712
|
confirmLine,
|
|
1321
1713
|
batchLine,
|
|
1322
|
-
h("div", { className: "dsh-sdel-list" }, rows),
|
|
1714
|
+
h("div", { className: "dsh-sdel-list", "data-session-delete-list": "" }, rows),
|
|
1323
1715
|
),
|
|
1324
1716
|
(data?.unknown?.length ?? 0) > 0
|
|
1325
1717
|
? h(
|
|
1326
1718
|
"div",
|
|
1327
|
-
{
|
|
1719
|
+
{
|
|
1720
|
+
style: { color: T.faint, fontSize: "12px", marginTop: "8px" },
|
|
1721
|
+
"data-session-delete-unknown": "",
|
|
1722
|
+
},
|
|
1328
1723
|
props.t("panel.unknown", { n: data.unknown.length }),
|
|
1329
1724
|
)
|
|
1330
1725
|
: null,
|
|
1331
1726
|
(data?.pending?.length ?? 0) > 0
|
|
1332
1727
|
? h(
|
|
1333
1728
|
"div",
|
|
1334
|
-
{
|
|
1729
|
+
{
|
|
1730
|
+
style: { color: T.faint, fontSize: "12px", marginTop: "4px" },
|
|
1731
|
+
"data-session-delete-pending": "",
|
|
1732
|
+
},
|
|
1335
1733
|
props.t("panel.pending", { n: data.pending.length }),
|
|
1336
1734
|
)
|
|
1337
1735
|
: null,
|
|
@@ -1361,17 +1759,156 @@ window.__ModuleLoader__.load({
|
|
|
1361
1759
|
);
|
|
1362
1760
|
}
|
|
1363
1761
|
|
|
1762
|
+
/**
|
|
1763
|
+
* 一条操作回执:摘要一行,展开后逐项列出引用/校验结果(USIM-U3-05)。
|
|
1764
|
+
* 用户被 toast 指引来「详见操作回执」,这里就必须真的能查到是哪一处没通过,
|
|
1765
|
+
* 并且对恢复回执提供「重试未通过的引用」。
|
|
1766
|
+
*/
|
|
1767
|
+
function ReceiptRow(/** @type {any} */ props) {
|
|
1768
|
+
var receipt = props.receipt || {};
|
|
1769
|
+
var retryingState = React.useState(false);
|
|
1770
|
+
var retrying = retryingState[0];
|
|
1771
|
+
var setRetrying = retryingState[1];
|
|
1772
|
+
var noteState = React.useState(null);
|
|
1773
|
+
var note = noteState[0];
|
|
1774
|
+
var setNote = noteState[1];
|
|
1775
|
+
var refs = Array.isArray(receipt.refs) ? receipt.refs : [];
|
|
1776
|
+
var checks = Array.isArray(receipt.checks) ? receipt.checks : [];
|
|
1777
|
+
var failures = restoreFailures(receipt);
|
|
1778
|
+
var action = String(receipt.action || "");
|
|
1779
|
+
// B1(复审):没有 `expected` 快照的旧回执不能重检——服务端也会拒绝,
|
|
1780
|
+
// 这里先不给按钮,别让用户点出一个假的「重检通过」。
|
|
1781
|
+
var hasSnapshot = receipt.expected !== null && typeof receipt.expected === "object";
|
|
1782
|
+
var retryable =
|
|
1783
|
+
failures.length > 0 &&
|
|
1784
|
+
(action === "restore" || action === "restore-recheck") &&
|
|
1785
|
+
typeof receipt.sessionId === "string" &&
|
|
1786
|
+
hasSnapshot &&
|
|
1787
|
+
typeof props.call === "function";
|
|
1788
|
+
|
|
1789
|
+
/** @type {any[]} */
|
|
1790
|
+
var detailLines = [];
|
|
1791
|
+
/** @param {string} title @param {any[]} items @param {string} keyPrefix */
|
|
1792
|
+
var pushGroup = (title, items, keyPrefix) => {
|
|
1793
|
+
if (items.length === 0) return;
|
|
1794
|
+
detailLines.push(
|
|
1795
|
+
h(
|
|
1796
|
+
"div",
|
|
1797
|
+
{ key: `${keyPrefix}-title`, style: { color: T.faint, marginTop: "4px" } },
|
|
1798
|
+
title,
|
|
1799
|
+
),
|
|
1800
|
+
);
|
|
1801
|
+
items.forEach((/** @type {any} */ item, /** @type {number} */ index) => {
|
|
1802
|
+
var status = String(item?.status || "");
|
|
1803
|
+
var label = String(item?.label || item?.id || "");
|
|
1804
|
+
var detail = item?.detail ? String(item.detail) : "";
|
|
1805
|
+
var mark = status === "ok" ? "✓" : status === "failed" ? "✗" : "·";
|
|
1806
|
+
detailLines.push(
|
|
1807
|
+
h(
|
|
1808
|
+
"div",
|
|
1809
|
+
{
|
|
1810
|
+
key: `${keyPrefix}-${index}`,
|
|
1811
|
+
style: { color: status === "failed" ? T.danger : T.dim },
|
|
1812
|
+
"data-session-delete-receipt-item": `${item?.id || ""}:${status}`,
|
|
1813
|
+
},
|
|
1814
|
+
`${mark} ${label}${detail ? `:${detail}` : ""}${item?.retried === true ? `(${props.t("restore.detail.retried")})` : ""}`,
|
|
1815
|
+
),
|
|
1816
|
+
);
|
|
1817
|
+
});
|
|
1818
|
+
};
|
|
1819
|
+
pushGroup(props.t("receipt.refs"), refs, "refs");
|
|
1820
|
+
// trash 回执的引用清单在 `removed` 里(N3):两者都渲染,文案才对得上
|
|
1821
|
+
// README 的「show every reference and check」。
|
|
1822
|
+
var removed = Array.isArray(receipt.removed) ? receipt.removed : [];
|
|
1823
|
+
pushGroup(props.t("receipt.removed"), removed, "removed");
|
|
1824
|
+
pushGroup(props.t("receipt.checks"), checks, "checks");
|
|
1825
|
+
|
|
1826
|
+
var summaryText = `${formatTime(receipt.at)} · ${action} · ${String(receipt.title || receipt.sessionId || "")}`;
|
|
1827
|
+
if (refs.length > 0 || checks.length > 0) {
|
|
1828
|
+
summaryText +=
|
|
1829
|
+
failures.length > 0
|
|
1830
|
+
? ` · ${props.t("receipt.summary.partial", { n: failures.length })}`
|
|
1831
|
+
: ` · ${props.t("receipt.summary.ok")}`;
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
return h(
|
|
1835
|
+
"details",
|
|
1836
|
+
{
|
|
1837
|
+
className: "dsh-sdel-receipt",
|
|
1838
|
+
"data-session-delete-receipt": String(receipt.id || ""),
|
|
1839
|
+
style: { padding: "2px 0" },
|
|
1840
|
+
},
|
|
1841
|
+
h("summary", { className: "dsh-sdel-truncate", title: summaryText }, summaryText),
|
|
1842
|
+
detailLines.length > 0
|
|
1843
|
+
? h(
|
|
1844
|
+
"div",
|
|
1845
|
+
{ style: { padding: "4px 0 4px 12px", fontSize: "12px", lineHeight: 1.5 } },
|
|
1846
|
+
detailLines,
|
|
1847
|
+
)
|
|
1848
|
+
: null,
|
|
1849
|
+
receipt.wasLive === true
|
|
1850
|
+
? h(
|
|
1851
|
+
"div",
|
|
1852
|
+
{ style: { padding: "0 0 4px 12px", fontSize: "12px", color: T.faint } },
|
|
1853
|
+
props.t("restore.busyHint"),
|
|
1854
|
+
)
|
|
1855
|
+
: null,
|
|
1856
|
+
retryable
|
|
1857
|
+
? h(
|
|
1858
|
+
"div",
|
|
1859
|
+
{ style: { padding: "0 0 4px 12px" } },
|
|
1860
|
+
h(
|
|
1861
|
+
Btn,
|
|
1862
|
+
{
|
|
1863
|
+
tight: true,
|
|
1864
|
+
action: "receipt-restore-retry",
|
|
1865
|
+
disabled: retrying,
|
|
1866
|
+
onClick: () => {
|
|
1867
|
+
if (retrying) return;
|
|
1868
|
+
setRetrying(true);
|
|
1869
|
+
props
|
|
1870
|
+
.call("recheckRestore", {
|
|
1871
|
+
receiptId: typeof receipt.id === "string" ? receipt.id : undefined,
|
|
1872
|
+
sessionId: receipt.sessionId,
|
|
1873
|
+
})
|
|
1874
|
+
.then((/** @type {any} */ result) => {
|
|
1875
|
+
setRetrying(false);
|
|
1876
|
+
var left = restoreFailures(result);
|
|
1877
|
+
setNote(
|
|
1878
|
+
left.length === 0
|
|
1879
|
+
? props.t("restore.retry.ok")
|
|
1880
|
+
: props.t("restore.retry.partial", { n: left.length }),
|
|
1881
|
+
);
|
|
1882
|
+
props.onChanged?.();
|
|
1883
|
+
})
|
|
1884
|
+
.catch((/** @type {any} */ reason) => {
|
|
1885
|
+
setRetrying(false);
|
|
1886
|
+
setNote(errorText(reason));
|
|
1887
|
+
});
|
|
1888
|
+
},
|
|
1889
|
+
},
|
|
1890
|
+
retrying ? props.t("restore.detail.retrying") : props.t("restore.detail.retry"),
|
|
1891
|
+
),
|
|
1892
|
+
note ? h("div", { style: { color: T.faint, marginTop: "4px" } }, String(note)) : null,
|
|
1893
|
+
)
|
|
1894
|
+
: null,
|
|
1895
|
+
);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1364
1898
|
/**
|
|
1365
1899
|
* 设置页「会话回收站」:偏好 + 回收站概览 + 维护(体检/回执/审计)。
|
|
1366
1900
|
* 原来这四块是回收站面板里的四个页签,搬到这里后主面板只剩一件事。
|
|
1367
1901
|
*/
|
|
1902
|
+
/** 设置页体检结论的页面级缓存:重开设置页复用,不重复扫全库(AUD-SD-08)。 */
|
|
1903
|
+
var settingsHealthCache = createSettingsCache();
|
|
1904
|
+
|
|
1368
1905
|
function SettingsSection(/** @type {any} */ props) {
|
|
1369
1906
|
var prefsState = useStore(props.prefsStore);
|
|
1370
1907
|
var prefs = prefsState[0];
|
|
1371
1908
|
var infoState = React.useState(null);
|
|
1372
1909
|
var info = infoState[0];
|
|
1373
1910
|
var setInfo = infoState[1];
|
|
1374
|
-
var healthState = React.useState(
|
|
1911
|
+
var healthState = React.useState(settingsHealthCache.health);
|
|
1375
1912
|
var health = healthState[0];
|
|
1376
1913
|
var setHealth = healthState[1];
|
|
1377
1914
|
var healthErrorState = React.useState(null);
|
|
@@ -1383,6 +1920,9 @@ window.__ModuleLoader__.load({
|
|
|
1383
1920
|
var auditState = React.useState(null);
|
|
1384
1921
|
var audit = auditState[0];
|
|
1385
1922
|
var setAudit = auditState[1];
|
|
1923
|
+
var scanningState = React.useState(false);
|
|
1924
|
+
var scanning = scanningState[0];
|
|
1925
|
+
var setScanning = scanningState[1];
|
|
1386
1926
|
var cleaningState = React.useState(false);
|
|
1387
1927
|
var cleaning = cleaningState[0];
|
|
1388
1928
|
var setCleaning = cleaningState[1];
|
|
@@ -1393,42 +1933,26 @@ window.__ModuleLoader__.load({
|
|
|
1393
1933
|
var message = msgState[0];
|
|
1394
1934
|
var setMessage = msgState[1];
|
|
1395
1935
|
|
|
1936
|
+
var loader = React.useMemo(
|
|
1937
|
+
() =>
|
|
1938
|
+
createSettingsLoader(
|
|
1939
|
+
props.call,
|
|
1940
|
+
{
|
|
1941
|
+
setInfo: setInfo,
|
|
1942
|
+
setReceipts: setReceipts,
|
|
1943
|
+
setAudit: setAudit,
|
|
1944
|
+
setHealth: setHealth,
|
|
1945
|
+
setHealthError: setHealthError,
|
|
1946
|
+
setMessage: setMessage,
|
|
1947
|
+
},
|
|
1948
|
+
settingsHealthCache,
|
|
1949
|
+
),
|
|
1950
|
+
[],
|
|
1951
|
+
);
|
|
1952
|
+
|
|
1396
1953
|
React.useEffect(() => {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
.call("list")
|
|
1400
|
-
.then((/** @type {any} */ value) => {
|
|
1401
|
-
if (alive) setInfo(value);
|
|
1402
|
-
})
|
|
1403
|
-
.catch(() => {});
|
|
1404
|
-
props
|
|
1405
|
-
.call("healthScan")
|
|
1406
|
-
.then((/** @type {any} */ value) => {
|
|
1407
|
-
if (alive) setHealth(value);
|
|
1408
|
-
})
|
|
1409
|
-
.catch((/** @type {any} */ reason) => {
|
|
1410
|
-
if (alive) setHealthError(errorText(reason));
|
|
1411
|
-
});
|
|
1412
|
-
props
|
|
1413
|
-
.call("receipts", { limit: 50 })
|
|
1414
|
-
.then((/** @type {any} */ value) => {
|
|
1415
|
-
if (alive) setReceipts(value?.entries || []);
|
|
1416
|
-
})
|
|
1417
|
-
.catch((/** @type {any} */ reason) => {
|
|
1418
|
-
// 空白 + 一声不响是最差的失败姿态:把原因写进页面里。
|
|
1419
|
-
if (alive) setMessage(errorText(reason));
|
|
1420
|
-
});
|
|
1421
|
-
props
|
|
1422
|
-
.call("audit", { limit: 100 })
|
|
1423
|
-
.then((/** @type {any} */ value) => {
|
|
1424
|
-
if (alive) setAudit(value?.entries || []);
|
|
1425
|
-
})
|
|
1426
|
-
.catch((/** @type {any} */ reason) => {
|
|
1427
|
-
if (alive) setMessage(errorText(reason));
|
|
1428
|
-
});
|
|
1429
|
-
return () => {
|
|
1430
|
-
alive = false;
|
|
1431
|
-
};
|
|
1954
|
+
// 只拉轻量数据;体检是用户动作(曾经一挂载就跑全库扫描,见 AUD-SD-08)。
|
|
1955
|
+
void loader.load();
|
|
1432
1956
|
}, []);
|
|
1433
1957
|
|
|
1434
1958
|
var entries = info?.entries || [];
|
|
@@ -1443,6 +1967,13 @@ window.__ModuleLoader__.load({
|
|
|
1443
1967
|
props.call("setPrefs", { cascadeChildren: next }).catch(() => {});
|
|
1444
1968
|
};
|
|
1445
1969
|
|
|
1970
|
+
var runScan = () => {
|
|
1971
|
+
setScanning(true);
|
|
1972
|
+
loader.scanHealth().then(() => {
|
|
1973
|
+
setScanning(false);
|
|
1974
|
+
});
|
|
1975
|
+
};
|
|
1976
|
+
|
|
1446
1977
|
var cleanable = health?.ok ? health.cleanable : null;
|
|
1447
1978
|
var cleanRows = [];
|
|
1448
1979
|
if (confirmClean && cleanable && cleanable.total > 0) {
|
|
@@ -1460,6 +1991,7 @@ window.__ModuleLoader__.load({
|
|
|
1460
1991
|
{
|
|
1461
1992
|
tight: true,
|
|
1462
1993
|
variant: "danger",
|
|
1994
|
+
action: "health-clean",
|
|
1463
1995
|
disabled: cleaning,
|
|
1464
1996
|
onClick: () => {
|
|
1465
1997
|
setCleaning(true);
|
|
@@ -1469,6 +2001,8 @@ window.__ModuleLoader__.load({
|
|
|
1469
2001
|
setCleaning(false);
|
|
1470
2002
|
setConfirmClean(false);
|
|
1471
2003
|
setMessage(props.t("settings.health.cleaned", { n: result.total }));
|
|
2004
|
+
// 刚清理过,缓存里的数字已经不对了:重新扫一次让结论刷新。
|
|
2005
|
+
return loader.scanHealth();
|
|
1472
2006
|
})
|
|
1473
2007
|
.catch((/** @type {any} */ reason) => {
|
|
1474
2008
|
setCleaning(false);
|
|
@@ -1480,7 +2014,7 @@ window.__ModuleLoader__.load({
|
|
|
1480
2014
|
),
|
|
1481
2015
|
h(
|
|
1482
2016
|
Btn,
|
|
1483
|
-
{ tight: true, onClick: () => setConfirmClean(false) },
|
|
2017
|
+
{ tight: true, action: "health-clean-cancel", onClick: () => setConfirmClean(false) },
|
|
1484
2018
|
props.t("confirm.cancel"),
|
|
1485
2019
|
),
|
|
1486
2020
|
),
|
|
@@ -1489,9 +2023,14 @@ window.__ModuleLoader__.load({
|
|
|
1489
2023
|
|
|
1490
2024
|
return h(
|
|
1491
2025
|
"div",
|
|
1492
|
-
{ className: "dsh-sdel-settings" },
|
|
1493
|
-
h(
|
|
2026
|
+
{ className: "dsh-sdel-settings", "data-session-delete-settings": "" },
|
|
2027
|
+
h(
|
|
2028
|
+
"div",
|
|
2029
|
+
{ className: "dsh-sdel-group", "data-session-delete-group": "delete" },
|
|
2030
|
+
props.t("settings.group.delete"),
|
|
2031
|
+
),
|
|
1494
2032
|
h(SettingRow, {
|
|
2033
|
+
anchor: "cascade",
|
|
1495
2034
|
title: props.t("settings.cascade.title"),
|
|
1496
2035
|
description: props.t("settings.cascade.desc"),
|
|
1497
2036
|
action: h(Toggle, {
|
|
@@ -1501,12 +2040,14 @@ window.__ModuleLoader__.load({
|
|
|
1501
2040
|
}),
|
|
1502
2041
|
}),
|
|
1503
2042
|
h(SettingRow, {
|
|
2043
|
+
anchor: "cascade-reset",
|
|
1504
2044
|
title: "",
|
|
1505
2045
|
description: null,
|
|
1506
2046
|
action: h(
|
|
1507
2047
|
Btn,
|
|
1508
2048
|
{
|
|
1509
2049
|
tight: true,
|
|
2050
|
+
action: "cascade-reset",
|
|
1510
2051
|
disabled: !cascade,
|
|
1511
2052
|
onClick: () => {
|
|
1512
2053
|
setCascade(false);
|
|
@@ -1516,8 +2057,13 @@ window.__ModuleLoader__.load({
|
|
|
1516
2057
|
props.t("settings.cascade.reset"),
|
|
1517
2058
|
),
|
|
1518
2059
|
}),
|
|
1519
|
-
h(
|
|
2060
|
+
h(
|
|
2061
|
+
"div",
|
|
2062
|
+
{ className: "dsh-sdel-group", "data-session-delete-group": "trash" },
|
|
2063
|
+
props.t("settings.group.trash"),
|
|
2064
|
+
),
|
|
1520
2065
|
h(SettingRow, {
|
|
2066
|
+
anchor: "trash",
|
|
1521
2067
|
title: props.t("settings.trash.summary", {
|
|
1522
2068
|
n: entries.length,
|
|
1523
2069
|
size: formatBytes(totalBytes),
|
|
@@ -1527,6 +2073,7 @@ window.__ModuleLoader__.load({
|
|
|
1527
2073
|
Btn,
|
|
1528
2074
|
{
|
|
1529
2075
|
tight: true,
|
|
2076
|
+
action: "open-trash",
|
|
1530
2077
|
onClick: () => {
|
|
1531
2078
|
props.close?.();
|
|
1532
2079
|
props.panelStore.set(true);
|
|
@@ -1535,94 +2082,155 @@ window.__ModuleLoader__.load({
|
|
|
1535
2082
|
props.t("settings.trash.open"),
|
|
1536
2083
|
),
|
|
1537
2084
|
}),
|
|
1538
|
-
h(
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
:
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
2085
|
+
h(
|
|
2086
|
+
"div",
|
|
2087
|
+
{ className: "dsh-sdel-group", "data-session-delete-group": "maintenance" },
|
|
2088
|
+
props.t("settings.group.maintenance"),
|
|
2089
|
+
),
|
|
2090
|
+
h(
|
|
2091
|
+
"div",
|
|
2092
|
+
{
|
|
2093
|
+
"data-session-delete-health": "",
|
|
2094
|
+
"data-session-delete-health-state": healthError
|
|
2095
|
+
? "error"
|
|
2096
|
+
: scanning
|
|
2097
|
+
? "scanning"
|
|
2098
|
+
: health
|
|
2099
|
+
? health.ok
|
|
2100
|
+
? "ok"
|
|
2101
|
+
: "unavailable"
|
|
2102
|
+
: "idle",
|
|
2103
|
+
},
|
|
2104
|
+
h(SettingRow, {
|
|
2105
|
+
anchor: "health",
|
|
2106
|
+
title: props.t("settings.health.title"),
|
|
2107
|
+
description: props.t("settings.health.desc"),
|
|
2108
|
+
action: h(
|
|
2109
|
+
React.Fragment,
|
|
2110
|
+
null,
|
|
2111
|
+
h(
|
|
2112
|
+
Btn,
|
|
2113
|
+
{ tight: true, action: "health-run", disabled: scanning, onClick: runScan },
|
|
2114
|
+
props.t("settings.health.run"),
|
|
2115
|
+
),
|
|
2116
|
+
cleanable && cleanable.total > 0
|
|
2117
|
+
? h(
|
|
2118
|
+
Btn,
|
|
2119
|
+
{
|
|
2120
|
+
tight: true,
|
|
2121
|
+
action: "health-clean-confirm",
|
|
2122
|
+
disabled: cleaning,
|
|
2123
|
+
onClick: () => setConfirmClean(true),
|
|
2124
|
+
},
|
|
2125
|
+
props.t("settings.health.items", { n: cleanable.total }),
|
|
2126
|
+
)
|
|
2127
|
+
: null,
|
|
2128
|
+
),
|
|
2129
|
+
children: healthError
|
|
1557
2130
|
? h(
|
|
1558
2131
|
"div",
|
|
1559
|
-
{ style: { color: T.
|
|
1560
|
-
props.t("settings.
|
|
2132
|
+
{ style: { color: T.danger, fontSize: "12px" } },
|
|
2133
|
+
props.t("settings.health.unavailable", { reason: healthError }),
|
|
1561
2134
|
)
|
|
1562
|
-
:
|
|
2135
|
+
: scanning
|
|
1563
2136
|
? h(
|
|
1564
2137
|
"div",
|
|
1565
|
-
{ style: { color: T.
|
|
1566
|
-
props.t("settings.
|
|
2138
|
+
{ style: { color: T.faint, fontSize: "12px" } },
|
|
2139
|
+
props.t("settings.loading"),
|
|
1567
2140
|
)
|
|
1568
|
-
: health
|
|
2141
|
+
: !health
|
|
1569
2142
|
? h(
|
|
1570
2143
|
"div",
|
|
1571
|
-
{ style: { color: T.
|
|
1572
|
-
props.t("settings.health.
|
|
2144
|
+
{ style: { color: T.faint, fontSize: "12px" } },
|
|
2145
|
+
props.t("settings.health.idle"),
|
|
1573
2146
|
)
|
|
1574
|
-
:
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
(health.
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
2147
|
+
: !health.ok
|
|
2148
|
+
? h(
|
|
2149
|
+
"div",
|
|
2150
|
+
{ style: { color: T.dim, fontSize: "12px" } },
|
|
2151
|
+
props.t("settings.health.unavailable", { reason: health.reason || "" }),
|
|
2152
|
+
)
|
|
2153
|
+
: health.findings && health.findings.length === 0
|
|
2154
|
+
? h(
|
|
2155
|
+
"div",
|
|
2156
|
+
{ style: { color: T.dim, fontSize: "12px" } },
|
|
2157
|
+
props.t("settings.health.ok"),
|
|
2158
|
+
)
|
|
2159
|
+
: h(
|
|
2160
|
+
"div",
|
|
2161
|
+
{ style: { color: T.dim, fontSize: "12px" } },
|
|
2162
|
+
joinList(
|
|
2163
|
+
(health.findings || []).map(
|
|
2164
|
+
(/** @type {any} */ finding) => finding.label,
|
|
2165
|
+
),
|
|
2166
|
+
4,
|
|
2167
|
+
),
|
|
2168
|
+
),
|
|
2169
|
+
}),
|
|
2170
|
+
),
|
|
1583
2171
|
cleanRows.length > 0 ? h("div", { style: { padding: "0 0 12px" } }, cleanRows) : null,
|
|
1584
2172
|
h(
|
|
1585
2173
|
"div",
|
|
1586
|
-
{
|
|
2174
|
+
{
|
|
2175
|
+
className: "dsh-sdel-setting-row dsh-sdel-setting-row--stack",
|
|
2176
|
+
"data-session-delete-receipts": "",
|
|
2177
|
+
},
|
|
1587
2178
|
h(
|
|
1588
2179
|
Disclosure,
|
|
1589
2180
|
{
|
|
2181
|
+
anchor: "receipts",
|
|
1590
2182
|
label: props.t("settings.receipts.title"),
|
|
1591
2183
|
meta: receipts ? String(receipts.length) : "",
|
|
1592
2184
|
},
|
|
1593
2185
|
!receipts || receipts.length === 0
|
|
1594
2186
|
? h("div", null, props.t("settings.receipts.empty"))
|
|
1595
2187
|
: receipts.map((/** @type {any} */ receipt, /** @type {any} */ receiptIndex) =>
|
|
1596
|
-
h(
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
2188
|
+
h(ReceiptRow, {
|
|
2189
|
+
key: `receipt-${receiptIndex}`,
|
|
2190
|
+
receipt: receipt,
|
|
2191
|
+
call: props.call,
|
|
2192
|
+
t: props.t,
|
|
2193
|
+
onChanged: () => {
|
|
2194
|
+
void loader.load();
|
|
2195
|
+
},
|
|
2196
|
+
}),
|
|
1601
2197
|
),
|
|
1602
2198
|
),
|
|
1603
2199
|
),
|
|
1604
2200
|
h(
|
|
1605
2201
|
"div",
|
|
1606
|
-
{
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
2202
|
+
{
|
|
2203
|
+
className: "dsh-sdel-setting-row dsh-sdel-setting-row--stack",
|
|
2204
|
+
"data-session-delete-audit": "",
|
|
2205
|
+
},
|
|
2206
|
+
h(Disclosure, {
|
|
2207
|
+
anchor: "audit",
|
|
2208
|
+
label: props.t("settings.audit.title"),
|
|
2209
|
+
meta: audit ? String(audit.length) : "",
|
|
2210
|
+
children:
|
|
2211
|
+
!audit || audit.length === 0
|
|
2212
|
+
? h("div", null, props.t("settings.audit.empty"))
|
|
2213
|
+
: audit
|
|
2214
|
+
.slice()
|
|
2215
|
+
.reverse()
|
|
2216
|
+
.map((/** @type {any} */ entry, /** @type {any} */ auditIndex) =>
|
|
2217
|
+
h(
|
|
2218
|
+
"div",
|
|
2219
|
+
{ key: `audit-${auditIndex}`, className: "dsh-sdel-truncate" },
|
|
2220
|
+
`${formatTime(entry.ts)} · ${String(entry.action || "")} · ${String(entry.result || "")}${entry.detail ? ` · ${entry.detail}` : ""}`,
|
|
2221
|
+
),
|
|
1620
2222
|
),
|
|
1621
|
-
|
|
1622
|
-
),
|
|
2223
|
+
}),
|
|
1623
2224
|
),
|
|
1624
2225
|
message
|
|
1625
|
-
? h(
|
|
2226
|
+
? h(
|
|
2227
|
+
"div",
|
|
2228
|
+
{
|
|
2229
|
+
style: { color: T.dim, fontSize: "12px", paddingTop: "8px" },
|
|
2230
|
+
"data-session-delete-message": "",
|
|
2231
|
+
},
|
|
2232
|
+
message,
|
|
2233
|
+
)
|
|
1626
2234
|
: null,
|
|
1627
2235
|
);
|
|
1628
2236
|
}
|
|
@@ -1632,6 +2240,7 @@ window.__ModuleLoader__.load({
|
|
|
1632
2240
|
var toast = toastState[0];
|
|
1633
2241
|
var entryId = toast ? toast.entryId : null;
|
|
1634
2242
|
var text = toast ? toast.text : null;
|
|
2243
|
+
var isError = toast?.error === true;
|
|
1635
2244
|
var shownState = React.useState(false);
|
|
1636
2245
|
var shown = shownState[0];
|
|
1637
2246
|
var setShown = shownState[1];
|
|
@@ -1647,12 +2256,16 @@ window.__ModuleLoader__.load({
|
|
|
1647
2256
|
var raise = setTimeout(() => {
|
|
1648
2257
|
setShown(true);
|
|
1649
2258
|
}, 10);
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
2259
|
+
// 失败要能读到:错误 toast 不自动消失(AUD-SD-09 之前 6 秒就没了)。
|
|
2260
|
+
var timer =
|
|
2261
|
+
toast.error === true
|
|
2262
|
+
? null
|
|
2263
|
+
: setTimeout(() => {
|
|
2264
|
+
props.toastStore.set(null);
|
|
2265
|
+
}, 6000);
|
|
1653
2266
|
return () => {
|
|
1654
2267
|
clearTimeout(raise);
|
|
1655
|
-
clearTimeout(timer);
|
|
2268
|
+
if (timer !== null) clearTimeout(timer);
|
|
1656
2269
|
};
|
|
1657
2270
|
}, [toast]);
|
|
1658
2271
|
|
|
@@ -1660,14 +2273,16 @@ window.__ModuleLoader__.load({
|
|
|
1660
2273
|
return h(
|
|
1661
2274
|
"div",
|
|
1662
2275
|
{
|
|
2276
|
+
"data-session-delete-toast": isError ? "error" : "ok",
|
|
2277
|
+
role: isError ? "alert" : "status",
|
|
1663
2278
|
style: {
|
|
1664
2279
|
position: "fixed",
|
|
1665
2280
|
bottom: "24px",
|
|
1666
2281
|
right: "24px",
|
|
1667
2282
|
zIndex: 2147000000,
|
|
1668
2283
|
background: T.toastBg,
|
|
1669
|
-
color: T.toastText,
|
|
1670
|
-
border: `1px solid ${T.border}`,
|
|
2284
|
+
color: isError ? T.danger : T.toastText,
|
|
2285
|
+
border: `1px solid ${isError ? T.danger : T.border}`,
|
|
1671
2286
|
borderRadius: "10px",
|
|
1672
2287
|
padding: "10px 14px",
|
|
1673
2288
|
fontSize: "13px",
|
|
@@ -1675,27 +2290,53 @@ window.__ModuleLoader__.load({
|
|
|
1675
2290
|
display: "flex",
|
|
1676
2291
|
alignItems: "center",
|
|
1677
2292
|
gap: "12px",
|
|
2293
|
+
maxWidth: "min(520px, 92vw)",
|
|
1678
2294
|
opacity: shown ? 1 : 0,
|
|
1679
2295
|
transform: shown ? "translateY(0)" : "translateY(8px)",
|
|
1680
2296
|
transition: "opacity .18s ease, transform .18s ease",
|
|
1681
2297
|
},
|
|
1682
2298
|
},
|
|
1683
|
-
h("span",
|
|
2299
|
+
h("span", { "data-session-delete-toast-text": "" }, text ? text : props.t("confirm.done")),
|
|
2300
|
+
isError
|
|
2301
|
+
? h(
|
|
2302
|
+
Btn,
|
|
2303
|
+
{
|
|
2304
|
+
tight: true,
|
|
2305
|
+
action: "toast-dismiss",
|
|
2306
|
+
onClick: () => props.toastStore.set(null),
|
|
2307
|
+
},
|
|
2308
|
+
props.t("panel.close"),
|
|
2309
|
+
)
|
|
2310
|
+
: null,
|
|
1684
2311
|
entryId
|
|
1685
2312
|
? h(
|
|
1686
2313
|
Btn,
|
|
1687
2314
|
{
|
|
1688
2315
|
disabled: restoring,
|
|
2316
|
+
action: "undo",
|
|
1689
2317
|
onClick: () => {
|
|
1690
2318
|
setRestoring(true);
|
|
1691
2319
|
props
|
|
1692
2320
|
.call("restore", { entryId: toast.entryId })
|
|
1693
|
-
.then(() => {
|
|
2321
|
+
.then((/** @type {any} */ result) => {
|
|
1694
2322
|
setRestoring(false);
|
|
2323
|
+
var notice = restoreNotice(result, props.t);
|
|
2324
|
+
if (notice) {
|
|
2325
|
+
// 会话回来了但引用没全回来:说清楚,别让人以为完整撤销了。
|
|
2326
|
+
props.toastStore.set({ text: notice, error: true });
|
|
2327
|
+
return;
|
|
2328
|
+
}
|
|
1695
2329
|
props.toastStore.set(null);
|
|
2330
|
+
props.onRestored?.(result?.sessionId);
|
|
2331
|
+
props.bump?.();
|
|
1696
2332
|
})
|
|
1697
|
-
.catch(() => {
|
|
2333
|
+
.catch((/** @type {any} */ reason) => {
|
|
1698
2334
|
setRestoring(false);
|
|
2335
|
+
// 撤销失败曾经完全静默(AUD-SD-09):现在留在 toast 里直到用户关掉。
|
|
2336
|
+
props.toastStore.set({
|
|
2337
|
+
text: props.t("toast.undoFailed", { message: errorText(reason) }),
|
|
2338
|
+
error: true,
|
|
2339
|
+
});
|
|
1699
2340
|
});
|
|
1700
2341
|
},
|
|
1701
2342
|
},
|
|
@@ -1755,6 +2396,100 @@ window.__ModuleLoader__.load({
|
|
|
1755
2396
|
return { load: load, loadHealth: loadHealth };
|
|
1756
2397
|
}
|
|
1757
2398
|
|
|
2399
|
+
/**
|
|
2400
|
+
* 设置页体检结论的缓存(AUD-SD-08):页面会话内复用,重开设置页不再扫全库。
|
|
2401
|
+
*/
|
|
2402
|
+
function createSettingsCache() {
|
|
2403
|
+
return { health: /** @type {any} */ (null), healthAt: 0 };
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
/**
|
|
2407
|
+
* 设置页加载器。设计目标(ADR 0004 §7):
|
|
2408
|
+
* - 挂载时只拉轻量数据(list / receipts / audit),**绝不**自动跑全库体检;
|
|
2409
|
+
* - 体检是用户动作(`scanHealth()`),结果写进缓存供下次打开复用;
|
|
2410
|
+
* - 任何一个请求失败都只影响自己那一块,不许把设置页整体打挂。
|
|
2411
|
+
* @param {(method: string, request?: any) => Promise<any>} call
|
|
2412
|
+
* @param {{ setInfo?: (value: any) => void, setReceipts?: (value: any) => void,
|
|
2413
|
+
* setAudit?: (value: any) => void, setHealth?: (value: any) => void,
|
|
2414
|
+
* setHealthError?: (value: any) => void, setMessage?: (value: string) => void }} sinks
|
|
2415
|
+
* @param {{ health: any, healthAt: number }} [cache]
|
|
2416
|
+
*/
|
|
2417
|
+
function createSettingsLoader(call, sinks, cache) {
|
|
2418
|
+
var shared = cache || createSettingsCache();
|
|
2419
|
+
/**
|
|
2420
|
+
* @param {((value: any) => void) | undefined} setter
|
|
2421
|
+
* @param {any} value
|
|
2422
|
+
*/
|
|
2423
|
+
var push = (setter, value) => {
|
|
2424
|
+
try {
|
|
2425
|
+
setter?.(value);
|
|
2426
|
+
} catch (_error) {
|
|
2427
|
+
/* 渲染层挂了不该让 RPC 的 rejection 逃逸 */
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
/**
|
|
2431
|
+
* @param {string} method
|
|
2432
|
+
* @param {((value: any) => void) | undefined} setter
|
|
2433
|
+
* @param {(value: any) => any} pick
|
|
2434
|
+
*/
|
|
2435
|
+
var fetchInto = (method, setter, pick) =>
|
|
2436
|
+
Promise.resolve()
|
|
2437
|
+
.then(() => call(method))
|
|
2438
|
+
.then(
|
|
2439
|
+
(/** @type {any} */ value) => {
|
|
2440
|
+
push(setter, pick(value));
|
|
2441
|
+
return value;
|
|
2442
|
+
},
|
|
2443
|
+
(/** @type {any} */ reason) => {
|
|
2444
|
+
push(sinks.setMessage, errorText(reason));
|
|
2445
|
+
return null;
|
|
2446
|
+
},
|
|
2447
|
+
);
|
|
2448
|
+
|
|
2449
|
+
var load = () => {
|
|
2450
|
+
// 先显示上次的体检结论(或 null = 尚未体检),不触发任何扫描。
|
|
2451
|
+
push(sinks.setHealth, shared.health);
|
|
2452
|
+
return Promise.all([
|
|
2453
|
+
fetchInto("list", sinks.setInfo, (/** @type {any} */ value) => value),
|
|
2454
|
+
fetchInto(
|
|
2455
|
+
"receipts",
|
|
2456
|
+
sinks.setReceipts,
|
|
2457
|
+
(/** @type {any} */ value) => value?.entries || [],
|
|
2458
|
+
),
|
|
2459
|
+
fetchInto("audit", sinks.setAudit, (/** @type {any} */ value) => value?.entries || []),
|
|
2460
|
+
]);
|
|
2461
|
+
};
|
|
2462
|
+
|
|
2463
|
+
var scanHealth = () =>
|
|
2464
|
+
Promise.resolve()
|
|
2465
|
+
.then(() => call("healthScan"))
|
|
2466
|
+
.then(
|
|
2467
|
+
(/** @type {any} */ value) => {
|
|
2468
|
+
shared.health = value;
|
|
2469
|
+
shared.healthAt = Date.now();
|
|
2470
|
+
push(sinks.setHealth, value);
|
|
2471
|
+
push(sinks.setHealthError, null);
|
|
2472
|
+
return value;
|
|
2473
|
+
},
|
|
2474
|
+
(/** @type {any} */ reason) => {
|
|
2475
|
+
// 扫描失败只影响体检那一行:把原因放在那里,别抛进 React。
|
|
2476
|
+
shared.health = null;
|
|
2477
|
+
shared.healthAt = 0;
|
|
2478
|
+
push(sinks.setHealth, null);
|
|
2479
|
+
push(sinks.setHealthError, errorText(reason));
|
|
2480
|
+
return null;
|
|
2481
|
+
},
|
|
2482
|
+
);
|
|
2483
|
+
|
|
2484
|
+
var invalidate = () => {
|
|
2485
|
+
shared.health = null;
|
|
2486
|
+
shared.healthAt = 0;
|
|
2487
|
+
push(sinks.setHealth, null);
|
|
2488
|
+
};
|
|
2489
|
+
|
|
2490
|
+
return { load: load, scanHealth: scanHealth, invalidate: invalidate, cache: shared };
|
|
2491
|
+
}
|
|
2492
|
+
|
|
1758
2493
|
/**
|
|
1759
2494
|
* 分批执行批量动作。宿主单次上限是防御性硬上限,界面按 chunkSize 切块;
|
|
1760
2495
|
* 每块之间让出一帧:进度可见、可中途停止、部分失败不中断其余批次。
|
|
@@ -1762,8 +2497,9 @@ window.__ModuleLoader__.load({
|
|
|
1762
2497
|
* 「部分失败被汇总、成功的也不再算失败」。
|
|
1763
2498
|
* @param {{ ids: string[], kind: "purge" | "restore", call: (method: string, request?: any) => Promise<any>,
|
|
1764
2499
|
* chunkSize?: number, onProgress?: (state: any) => void, shouldStop?: () => boolean,
|
|
1765
|
-
* onRestored?: (sessionId: string) => void }} options
|
|
1766
|
-
* @returns {Promise<{ kind: string, total: number, done: number, ok: number, failures: any[],
|
|
2500
|
+
* onRestored?: (sessionId: string, options?: { open?: boolean }) => void }} options
|
|
2501
|
+
* @returns {Promise<{ kind: string, total: number, done: number, ok: number, failures: any[],
|
|
2502
|
+
* partials: number, stopped: boolean }>}
|
|
1767
2503
|
*/
|
|
1768
2504
|
async function runBatch(options) {
|
|
1769
2505
|
var ids = options.ids || [];
|
|
@@ -1772,6 +2508,7 @@ window.__ModuleLoader__.load({
|
|
|
1772
2508
|
var groups = chunk(ids, chunkSize);
|
|
1773
2509
|
/** @type {any[]} */
|
|
1774
2510
|
var failures = [];
|
|
2511
|
+
var partials = 0;
|
|
1775
2512
|
var done = 0;
|
|
1776
2513
|
var stopped = false;
|
|
1777
2514
|
const emit = (/** @type {boolean} */ running) => {
|
|
@@ -1782,6 +2519,7 @@ window.__ModuleLoader__.load({
|
|
|
1782
2519
|
done: done,
|
|
1783
2520
|
total: ids.length,
|
|
1784
2521
|
failures: failures.slice(),
|
|
2522
|
+
partials: partials,
|
|
1785
2523
|
});
|
|
1786
2524
|
} catch (_error) {}
|
|
1787
2525
|
};
|
|
@@ -1799,7 +2537,15 @@ window.__ModuleLoader__.load({
|
|
|
1799
2537
|
for (let itemIndex = 0; itemIndex < results.length; itemIndex += 1) {
|
|
1800
2538
|
const item = results[itemIndex];
|
|
1801
2539
|
if (!item.ok) failures.push(item);
|
|
1802
|
-
else
|
|
2540
|
+
else {
|
|
2541
|
+
// 条目回来了但引用没全回来:单独计数,批量行里要说出来(AUD-SD-02)。
|
|
2542
|
+
if (item.partial === true) partials += 1;
|
|
2543
|
+
// N1:批量恢复不逐条导航——宿主 replaceMain 会互相 supersede,
|
|
2544
|
+
// 最终停在任意一条还会闪;批量结束后统一交给 onBatchRestoreDone。
|
|
2545
|
+
if (kind === "restore" && item.sessionId) {
|
|
2546
|
+
options.onRestored?.(item.sessionId, { open: false });
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
1803
2549
|
}
|
|
1804
2550
|
} catch (reason) {
|
|
1805
2551
|
for (let groupIndex = 0; groupIndex < group.length; groupIndex += 1) {
|
|
@@ -1818,6 +2564,7 @@ window.__ModuleLoader__.load({
|
|
|
1818
2564
|
done: done,
|
|
1819
2565
|
ok: done - failures.length,
|
|
1820
2566
|
failures: failures,
|
|
2567
|
+
partials: partials,
|
|
1821
2568
|
stopped: stopped,
|
|
1822
2569
|
};
|
|
1823
2570
|
}
|
|
@@ -1844,6 +2591,8 @@ window.__ModuleLoader__.load({
|
|
|
1844
2591
|
call: props.call,
|
|
1845
2592
|
onPurged: props.onPurged,
|
|
1846
2593
|
onRestored: props.onRestored,
|
|
2594
|
+
onRestoreComplete: props.onRestoreComplete,
|
|
2595
|
+
onBatchRestoreDone: props.onBatchRestoreDone,
|
|
1847
2596
|
tickStore: props.tickStore,
|
|
1848
2597
|
bump: props.bump,
|
|
1849
2598
|
}),
|
|
@@ -2007,6 +2756,105 @@ window.__ModuleLoader__.load({
|
|
|
2007
2756
|
}
|
|
2008
2757
|
});
|
|
2009
2758
|
};
|
|
2759
|
+
|
|
2760
|
+
/**
|
|
2761
|
+
* 宿主的界面导航服务(Client 半的 `uiWorkspace`)。
|
|
2762
|
+
* 不是公开契约,所以按「有就用、没有就降级」处理,绝不因为缺它抛错。
|
|
2763
|
+
*/
|
|
2764
|
+
const uiWorkspace = () => {
|
|
2765
|
+
try {
|
|
2766
|
+
return ctx.get ? ctx.get("uiWorkspace") : undefined;
|
|
2767
|
+
} catch (_error) {
|
|
2768
|
+
return undefined;
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
|
|
2772
|
+
/** 当前列表里第一个可切换的会话 id(用于删除当前会话后自动跳走)。 */
|
|
2773
|
+
const availableSessionIds = () => {
|
|
2774
|
+
const sessions = hostSessions();
|
|
2775
|
+
const list = sessions?.list?.getSnapshot?.();
|
|
2776
|
+
if (!list) return [];
|
|
2777
|
+
const ids = Array.isArray(list.ids) ? list.ids : Object.keys(list.byId || {});
|
|
2778
|
+
/** @type {string[]} */
|
|
2779
|
+
const out = [];
|
|
2780
|
+
for (let index = 0; index < ids.length; index += 1) {
|
|
2781
|
+
const id = String(ids[index]);
|
|
2782
|
+
if (retired.has(id)) continue;
|
|
2783
|
+
out.push(id);
|
|
2784
|
+
}
|
|
2785
|
+
return out;
|
|
2786
|
+
};
|
|
2787
|
+
|
|
2788
|
+
/**
|
|
2789
|
+
* 重新把视图绑到某个会话上(USIM-U2-05 / USIM-U3-02 ②)。
|
|
2790
|
+
*
|
|
2791
|
+
* 删除时宿主客户端会 dispose 这个会话的作用域;恢复/删除之后光刷新列表**不会**
|
|
2792
|
+
* 重建主视图的绑定,页面就停在「会话不可用」上(要切走再切回才好)。
|
|
2793
|
+
* `uiWorkspace.openSession` 是「选中会话并显示它的对话」这一条正式导航动作,
|
|
2794
|
+
* 会重新 retain 一份引用,正好补上这一步。
|
|
2795
|
+
* @param {string} sessionId
|
|
2796
|
+
* @returns {boolean}
|
|
2797
|
+
*/
|
|
2798
|
+
const reopenSession = (sessionId) => {
|
|
2799
|
+
if (typeof sessionId !== "string" || sessionId.length === 0) return false;
|
|
2800
|
+
const workspace = uiWorkspace();
|
|
2801
|
+
if (workspace && typeof workspace.openSession === "function") {
|
|
2802
|
+
try {
|
|
2803
|
+
workspace.openSession(sessionId);
|
|
2804
|
+
return true;
|
|
2805
|
+
} catch (error) {
|
|
2806
|
+
ctx.logger?.warn?.(
|
|
2807
|
+
`session-delete: openSession failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
2808
|
+
);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
// 退化路径:至少把投影缓存刷一遍,标题与消息不至于停在旧值。
|
|
2812
|
+
try {
|
|
2813
|
+
const sessions = hostSessions();
|
|
2814
|
+
void sessions?.refreshProjections?.(sessionId);
|
|
2815
|
+
} catch (_error) {
|
|
2816
|
+
/* 老宿主没有该通道时忽略 */
|
|
2817
|
+
}
|
|
2818
|
+
return false;
|
|
2819
|
+
};
|
|
2820
|
+
|
|
2821
|
+
/**
|
|
2822
|
+
* 删除的是当前正在看的会话时,别把人留在「已删除的会话」页上(USIM-U2-05):
|
|
2823
|
+
* 切到下一个可用会话,没有就回新会话页。
|
|
2824
|
+
* @param {string | null | undefined} deletedId
|
|
2825
|
+
* @param {string | null} workspaceId
|
|
2826
|
+
*/
|
|
2827
|
+
const leaveDeletedSessionView = (deletedId, workspaceId) => {
|
|
2828
|
+
if (typeof deletedId !== "string" || deletedId.length === 0) return false;
|
|
2829
|
+
const decision = afterTrashNavigation({
|
|
2830
|
+
deletedId: deletedId,
|
|
2831
|
+
currentId: deletedId,
|
|
2832
|
+
candidates: availableSessionIds(),
|
|
2833
|
+
});
|
|
2834
|
+
if (!decision.navigate) return false;
|
|
2835
|
+
const workspace = uiWorkspace();
|
|
2836
|
+
if (decision.target === "session" && decision.id) {
|
|
2837
|
+
if (reopenSession(decision.id)) return true;
|
|
2838
|
+
}
|
|
2839
|
+
if (workspace && typeof workspace.startSession === "function") {
|
|
2840
|
+
try {
|
|
2841
|
+
// 带上原工作区:否则宿主可能落到「选择一个工作区开始」的空态。
|
|
2842
|
+
if (typeof workspaceId === "string" && workspaceId.length > 0) {
|
|
2843
|
+
workspace.startSession(workspaceId);
|
|
2844
|
+
} else {
|
|
2845
|
+
workspace.startSession();
|
|
2846
|
+
}
|
|
2847
|
+
return true;
|
|
2848
|
+
} catch (error) {
|
|
2849
|
+
ctx.logger?.warn?.(
|
|
2850
|
+
`session-delete: startSession failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
2851
|
+
);
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
// 宿主没有导航服务:至少让列表重算,README 里写明需要手动切换。
|
|
2855
|
+
void refreshRows(undefined);
|
|
2856
|
+
return false;
|
|
2857
|
+
};
|
|
2010
2858
|
// 快捷键只做「打开回收站」这种非破坏性动作;删除始终需要菜单 + 确认框。
|
|
2011
2859
|
window.addEventListener("keydown", (/** @type {any} */ event) => {
|
|
2012
2860
|
if (!(event.metaKey || event.ctrlKey) || !event.altKey) return;
|
|
@@ -2019,11 +2867,20 @@ window.__ModuleLoader__.load({
|
|
|
2019
2867
|
});
|
|
2020
2868
|
|
|
2021
2869
|
const onTrashed = (/** @type {any} */ result) => {
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2870
|
+
const deletedId = typeof result?.sessionId === "string" ? result.sessionId : null;
|
|
2871
|
+
// 优先用打开确认框时记下的判断(宿主删完就把行摘了),老路径再退回实时判断。
|
|
2872
|
+
const wasCurrent =
|
|
2873
|
+
result?.wasCurrent === true || (Boolean(deletedId) && currentSession()?.id === deletedId);
|
|
2874
|
+
toastStore.set({
|
|
2875
|
+
entryId: result?.entryId ?? null,
|
|
2876
|
+
title: result?.title || null,
|
|
2877
|
+
// 删除当前会话时把「还能恢复」说在明处(USIM-U2-05)。
|
|
2878
|
+
text: wasCurrent ? translate("toast.trashedCurrent") : undefined,
|
|
2879
|
+
});
|
|
2880
|
+
void refreshRows(deletedId ?? undefined).then(() => {
|
|
2881
|
+
tickStore.set(tickStore.getSnapshot() + 1);
|
|
2882
|
+
if (wasCurrent) leaveDeletedSessionView(deletedId, result?.workspaceId ?? null);
|
|
2883
|
+
});
|
|
2027
2884
|
};
|
|
2028
2885
|
/**
|
|
2029
2886
|
* 工作区批量的收尾:逐条结果汇总成一句 toast,并把删掉的 id 记进 retired,
|
|
@@ -2033,18 +2890,26 @@ window.__ModuleLoader__.load({
|
|
|
2033
2890
|
const onTrashedMany = (result) => {
|
|
2034
2891
|
var ok = 0;
|
|
2035
2892
|
var total = 0;
|
|
2893
|
+
const current = currentSession();
|
|
2894
|
+
/** @type {string | null} */
|
|
2895
|
+
var currentDeleted = null;
|
|
2036
2896
|
if (result && Array.isArray(result.results)) {
|
|
2037
2897
|
total = result.results.length;
|
|
2038
2898
|
for (let index = 0; index < total; index += 1) {
|
|
2039
2899
|
const item = result.results[index];
|
|
2040
2900
|
if (!item.ok) continue;
|
|
2041
2901
|
ok += 1;
|
|
2042
|
-
if (item.sessionId)
|
|
2902
|
+
if (item.sessionId) {
|
|
2903
|
+
retired.add(String(item.sessionId));
|
|
2904
|
+
if (current?.id === item.sessionId) currentDeleted = String(item.sessionId);
|
|
2905
|
+
}
|
|
2043
2906
|
}
|
|
2044
2907
|
}
|
|
2045
2908
|
toastStore.set({ text: translate("toast.workspace.done", { ok: ok, total: total }) });
|
|
2046
|
-
void refreshRows(undefined)
|
|
2047
|
-
|
|
2909
|
+
void refreshRows(undefined).then(() => {
|
|
2910
|
+
tickStore.set(tickStore.getSnapshot() + 1);
|
|
2911
|
+
if (currentDeleted) leaveDeletedSessionView(currentDeleted, null);
|
|
2912
|
+
});
|
|
2048
2913
|
};
|
|
2049
2914
|
|
|
2050
2915
|
/** 当前会话(主视图持有的那一条)。快捷键的语义就是「这个会话」。 */
|
|
@@ -2106,9 +2971,35 @@ window.__ModuleLoader__.load({
|
|
|
2106
2971
|
const onPurged = (/** @type {any} */ sessionId) => {
|
|
2107
2972
|
void refreshRows(sessionId || undefined);
|
|
2108
2973
|
};
|
|
2109
|
-
|
|
2974
|
+
/**
|
|
2975
|
+
* 恢复后的列表收尾。
|
|
2976
|
+
* @param {any} sessionId
|
|
2977
|
+
* @param {{ open?: boolean }} [options] open=false 用于批量恢复:只刷新,不逐条导航(N1)
|
|
2978
|
+
*/
|
|
2979
|
+
const onRestored = (sessionId, options = {}) => {
|
|
2110
2980
|
if (sessionId) retired.delete(sessionId);
|
|
2981
|
+
// 恢复是「把会话还给我」:列表刷新之外还必须重建主视图绑定,
|
|
2982
|
+
// 否则当前视图停在「会话不可用」上(USIM-U3-02 ②)。
|
|
2983
|
+
void refreshRows(undefined).then(() => {
|
|
2984
|
+
if (options.open === false) return;
|
|
2985
|
+
reopenSession(typeof sessionId === "string" ? sessionId : "");
|
|
2986
|
+
});
|
|
2987
|
+
};
|
|
2988
|
+
|
|
2989
|
+
/** 恢复成功的收尾:关框 + 说一句 + 重新打开会话(USIM-U2-17)。 */
|
|
2990
|
+
const onRestoreComplete = (/** @type {any} */ result) => {
|
|
2991
|
+
panelStore.set(false);
|
|
2992
|
+
toastStore.set({ text: translate("toast.restored") });
|
|
2993
|
+
onRestored(result?.sessionId, { open: true });
|
|
2994
|
+
};
|
|
2995
|
+
|
|
2996
|
+
/** 批量恢复全绿的收尾:关框 + 汇总 toast,只刷新一次、不逐条导航(N1)。 */
|
|
2997
|
+
const onBatchRestoreDone = (/** @type {any} */ summary) => {
|
|
2998
|
+
panelStore.set(false);
|
|
2999
|
+
var ok = summary && typeof summary.ok === "number" ? summary.ok : 0;
|
|
3000
|
+
toastStore.set({ text: translate("toast.restoredMany", { n: ok }) });
|
|
2111
3001
|
void refreshRows(undefined);
|
|
3002
|
+
tickStore.set(tickStore.getSnapshot() + 1);
|
|
2112
3003
|
};
|
|
2113
3004
|
|
|
2114
3005
|
/**
|
|
@@ -2117,7 +3008,14 @@ window.__ModuleLoader__.load({
|
|
|
2117
3008
|
* 工作区「…」菜单也有正式入口。拿不到服务(老宿主)时退回旧 slot,功能不减。
|
|
2118
3009
|
*/
|
|
2119
3010
|
const openSessionConfirm = (/** @type {any} */ sessionId, /** @type {any} */ title) => {
|
|
2120
|
-
|
|
3011
|
+
// 打开确认框这一刻的「当前会话 / 当前工作区」必须记下来:
|
|
3012
|
+
// 删除成功后宿主会把这一行从列表里摘掉,事后再问「删的是当前会话吗」就问不到了。
|
|
3013
|
+
requestStore.set({
|
|
3014
|
+
sessionId: sessionId,
|
|
3015
|
+
title: title || null,
|
|
3016
|
+
currentId: currentSession()?.id ?? null,
|
|
3017
|
+
workspaceId: currentWorkspace()?.id ?? null,
|
|
3018
|
+
});
|
|
2121
3019
|
};
|
|
2122
3020
|
const openWorkspaceConfirm = (/** @type {any} */ workspaceId, /** @type {any} */ title) => {
|
|
2123
3021
|
requestStore.set({ workspaceId: String(workspaceId), title: title || null });
|
|
@@ -2400,6 +3298,8 @@ window.__ModuleLoader__.load({
|
|
|
2400
3298
|
onTrashedMany: onTrashedMany,
|
|
2401
3299
|
onPurged: onPurged,
|
|
2402
3300
|
onRestored: onRestored,
|
|
3301
|
+
onRestoreComplete: onRestoreComplete,
|
|
3302
|
+
onBatchRestoreDone: onBatchRestoreDone,
|
|
2403
3303
|
tickStore: tickStore,
|
|
2404
3304
|
bump: () => tickStore.set(tickStore.getSnapshot() + 1),
|
|
2405
3305
|
}),
|
|
@@ -2421,6 +3321,14 @@ window.__ModuleLoader__.load({
|
|
|
2421
3321
|
batchChunk: BATCH_CHUNK,
|
|
2422
3322
|
menuFallback: MENU_FALLBACK,
|
|
2423
3323
|
createPanelLoader: createPanelLoader,
|
|
3324
|
+
createSettingsLoader: createSettingsLoader,
|
|
3325
|
+
createSettingsCache: createSettingsCache,
|
|
3326
|
+
trashFailureText: trashFailureText,
|
|
3327
|
+
restoreNotice: restoreNotice,
|
|
3328
|
+
restoreFailures: restoreFailures,
|
|
3329
|
+
restoreDetailText: restoreDetailText,
|
|
3330
|
+
afterTrashNavigation: afterTrashNavigation,
|
|
3331
|
+
isPartialFailure: isPartialFailure,
|
|
2424
3332
|
runBatch: runBatch,
|
|
2425
3333
|
panelPollMs: PANEL_POLL_MS,
|
|
2426
3334
|
// 词典也暴露出来:单测要比对「内联词典 / locale/*.json」的键集,防止两处漂移。
|