v0.2.0: 全面代码质量优化

- ESLint flat config + Prettier + EditorConfig
- Markdown处理器LRU缓存
- Zustand选择器优化减少重渲染
- CodeMirror Compartment主题热切换
- Preview防抖(150ms) + IndexedDB去抖(500ms)
- 组件拆分: App.tsx 310→104行, Sidebar.tsx 244→90行
- 统一错误处理 errorHandler.ts
- ConfirmDialog替代原生confirm
- LoadingSpinner加载状态
- Toast多条堆叠+类型区分
- 可访问性增强(ARIA属性、键盘导航)
- Vitest测试框架(78个测试用例)
- Git hooks(husky + lint-staged)
- 项目文档(README.md, CONTRIBUTING.md)
This commit is contained in:
thzxx
2026-06-03 22:13:32 +08:00
parent 3cecb0f9eb
commit 7a4e2b0a67
72 changed files with 5103 additions and 894 deletions
+8 -9
View File
@@ -16,6 +16,7 @@ interface SidebarState {
toggleDir: (path: string) => void
expandDirs: (paths: string[]) => void
setSidebarWidth: (width: number) => void
/** @deprecated AR-04: 设置由 useSettingsInit 统一加载,此方法仅作兼容保留 */
loadFromDB: () => Promise<void>
}
@@ -27,7 +28,7 @@ export const useSidebarStore = create<SidebarState>((set, get) => ({
sidebarWidth: 240,
_loaded: false,
// 从 IndexedDB 加载 sidebar 设置
// AR-04: 设置由 useSettingsInit 统一加载
loadFromDB: async () => {
if (get()._loaded) return
try {
@@ -42,29 +43,27 @@ export const useSidebarStore = create<SidebarState>((set, get) => ({
}
},
setVisible: (visible) => {
setVisible: (visible: boolean) => {
set({ isVisible: visible })
// 异步保存到 DB
settingsRepository.save({ sidebarCollapsed: !visible })
},
setRootPath: (path) => set({ rootPath: path }),
setTree: (tree) => set({ tree }),
toggleDir: (path) =>
setRootPath: (path: string | null) => set({ rootPath: path }),
setTree: (tree: FileNode[]) => set({ tree }),
toggleDir: (path: string) =>
set(state => ({
expandedDirs: state.expandedDirs.includes(path)
? state.expandedDirs.filter(p => p !== path)
: [...state.expandedDirs, path]
})),
expandDirs: (paths) =>
expandDirs: (paths: string[]) =>
set(state => {
const newDirs = paths.filter(p => !state.expandedDirs.includes(p))
return newDirs.length > 0
? { expandedDirs: [...state.expandedDirs, ...newDirs] }
: state
}),
setSidebarWidth: (width) => {
setSidebarWidth: (width: number) => {
set({ sidebarWidth: width })
// 异步保存到 DB
settingsRepository.save({ sidebarWidth: width })
}
}))