perf: 全局响应速度优化——1.核心: 所有组件 useStore() 改为窄选择器 useStore(s=>s.field), 之前每次按键 setBody 改变 store.body 导致订阅整个 store 的 14 个组件全部 re-render(TiptapEditor/Editor/FileTree/TabBar/DocInfoPanel/Toolbar/App/SearchBox/TagFilter/SettingsPanel/GraphView/LinkGraph/MoreActions/TitleBar); TiptapEditor 不再订阅 body(仅 currentPath/setBody), body 从 getState() 在 effect 内获取; 2.OutlinePanel collect debounce 300ms(之前每次按键遍历文档树); 3.OutlinePanel scroll handler rAF 节流(之前每像素滚动调 coordsAtPos); 4.修复 TabBar resetEditor 重复声明 + TiptapEditor content 引用

This commit is contained in:
hunter-dev
2026-08-26 22:34:16 +08:00
parent 7f48cef344
commit 3fe35ef873
14 changed files with 68 additions and 35 deletions
@@ -10,7 +10,9 @@ function saveLabel(s: SaveState): string {
}
export function Editor() {
const { currentPath, title, saveState } = useStore();
const currentPath = useStore(s => s.currentPath);
const title = useStore(s => s.title);
const saveState = useStore(s => s.saveState);
if (!currentPath) {
return (
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', opacity: 0.4 }}>