mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-06-29 09:55:56 +08:00
refactor: 代码清理 — 删除 AppError、重命名 replacePaths、修正 detectExportFormat、统一 PATH 长度、优化 BOM 检查、添加同步注释
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user