fix: 对话删除后不再复活(并集合并bug)

- 根因: server∪mine 并集合并, 本机删的对话服务端还有 -> 下次同步并回
- 改用删除墓碑: removeChat 记录 {id,at} 到 it-tools-ai-chat-deleted 并纳入同步
- 合并时先并集再按墓碑剔除; 墓碑不过期(500上限截断), 删除永久生效

测试5项: 本机删除不复活/服务端墓碑生效/未删保留/旧墓碑生效/新对话不误删 ✓

CHANGELOG记录
This commit is contained in:
personal82555 committed 2026-10-13 22:06:45 +08:00
1 parent fc8e1c7c37
commit d880df224d
3 files changed
+53

No files matched your search

+9
View File
@@ -89,12 +89,21 @@ function newChat() {
saveConvs();
}
// 删除墓碑:记录被删对话 id,合并时统一剔除,避免 server∪mine 并集把已删对话“复活”
const DELETED_KEY = 'it-tools-ai-chat-deleted';
function removeChat(id: string) {
conversations.value = conversations.value.filter(c => c.id !== id);
if (curId.value === id) {
curId.value = conversations.value[0]?.id || '';
}
saveConvs();
try {
const del = JSON.parse(localStorage.getItem(DELETED_KEY) || '[]');
del.push({ id, at: Date.now() });
localStorage.setItem(DELETED_KEY, JSON.stringify(del.slice(-500)));
}
catch { /* ignore */ }
}
function fmtTime(ts: number) {