refactor: 代码清理 — 删除 AppError、重命名 replacePaths、修正 detectExportFormat、统一 PATH 长度、优化 BOM 检查、添加同步注释

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 22:14:13 +08:00
parent 613fb51fd7
commit 1ce3ebfd9e
10 changed files with 35 additions and 65 deletions
+7 -7
View File
@@ -34,7 +34,7 @@ interface AppState {
moveUp: (index: number, target: TargetType) => void;
moveDown: (index: number, target: TargetType) => void;
cleanPaths: (target: TargetType, validateFn: (p: string) => boolean) => string[];
importPaths: (target: TargetType, importPaths: string[]) => void;
replacePaths: (target: TargetType, newPaths: string[]) => void;
clearPaths: (target: TargetType) => void;
undo: () => void;
@@ -169,18 +169,18 @@ export const useAppStore = create<AppState>((set, get) => ({
return removed;
},
importPaths: (target, importPaths) => {
if (importPaths.length === 0) return;
replacePaths: (target, newPaths) => {
if (newPaths.length === 0) return;
const state = get();
const list = target === TargetType.SYSTEM ? state.sysPaths : state.userPaths;
state.undoRedo.push({
type: OperationType.IMPORT, target, index: 0, count: importPaths.length,
oldPaths: [...list], newPaths: [...importPaths],
type: OperationType.IMPORT, target, index: 0, count: newPaths.length,
oldPaths: [...list], newPaths: [...newPaths],
});
if (target === TargetType.SYSTEM) set({ sysPaths: [...importPaths], selectedIndices: [] });
else set({ userPaths: [...importPaths], selectedIndices: [] });
if (target === TargetType.SYSTEM) set({ sysPaths: [...newPaths], selectedIndices: [] });
else set({ userPaths: [...newPaths], selectedIndices: [] });
get()._markDirty();
},