fix: S1 安全冲刺——切库清空标签页+冲刷(FR-V6)、重命名/移动同步标签页路径(FR-T7)、默认库路径设置页(FR-V5);vaultBrowse IPC+pickDirectory;tab-store closeAll/renamePath;store resetEditor/syncCurrentPath;safety E2E 2 项

This commit is contained in:
hunter-dev
2026-08-26 11:05:22 +08:00
parent 81b410e281
commit c4af03adce
10 changed files with 190 additions and 8 deletions
@@ -9,6 +9,8 @@ interface TabState {
closeTab: (id: string) => void;
setActive: (id: string) => void;
togglePin: (id: string) => void;
closeAll: () => void; // FR-V6: 切库时清空全部标签页
renamePath: (oldPath: string, newPath: string) => void; // FR-T7: 重命名/移动后同步标签页路径
activePath: () => string | null;
persist: () => void;
restore: () => void;
@@ -54,6 +56,20 @@ export const useTabs = create<TabState>((set, get) => ({
get().persist();
},
closeAll: () => { set({ tabs: [], activeId: null }); get().persist(); },
renamePath: (oldPath, newPath) => {
set(s => ({
tabs: s.tabs.map(t => {
if (t.path === oldPath) return { ...t, path: newPath };
// 文件夹重命名/移动:子文档标签页路径前缀替换
if (oldPath && t.path.startsWith(oldPath + '/')) return { ...t, path: newPath + t.path.slice(oldPath.length) };
return t;
}),
}));
get().persist();
},
activePath: () => { const { tabs, activeId } = get(); return tabs.find(t => t.id === activeId)?.path ?? null; },
persist: () => {