fix(tabs): 关闭全部标签页后编辑器未清空——closeTab 仅清空 tabs/activeId 不清 store.currentPath, 导致 TiptapEditor 仍渲染旧文档. TabBar useEffect 加 resetEditor: 当 activeId 为 null 且 currentPath 非空时调用 store.resetEditor 清空 currentPath/body/meta, 编辑器正确显示空状态提示; 新增 E2E 验证

This commit is contained in:
hunter-dev
2026-08-26 19:21:29 +08:00
parent 34d3fec449
commit b01bdd380a
2 changed files with 21 additions and 1 deletions
@@ -7,10 +7,12 @@ export function TabBar() {
const { openDoc, currentPath } = useStore();
const [hoveredTab, setHoveredTab] = useState<string | null>(null);
// 当 activeId 变化,加载对应标签的文档
// 当 activeId 变化,加载对应标签的文档;标签全部关闭时清空编辑器
const resetEditor = useStore(s => s.resetEditor);
useEffect(() => {
const tab = tabs.find(t => t.id === activeId);
if (tab && tab.path !== currentPath) openDoc(tab.path);
else if (!activeId && currentPath) resetEditor();
}, [activeId]);
if (tabs.length === 0) return null;