mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-06-29 01:45:54 +08:00
重构(应用状态存储): 调整savePaths返回结构化结果并更新所有调用处
- 新增SaveResult类型统一标准化保存操作的结果状态 - 修改savePaths函数返回结构化结果而非布尔值,完善长路径超限、部分失败等场景的处理逻辑,部分失败时重新加载路径避免状态偏移 - 更新useAppActions与ProfileDialog的保存逻辑,适配新API并添加长路径确认弹窗 - 补充相关测试用例,修正导入导出测试的版本号预期
This commit is contained in:
@@ -73,8 +73,19 @@ export function ProfileDialog({ open, onClose }: Props) {
|
||||
system: selectedData.sys.filter(e => !e.enabled).map(e => e.path),
|
||||
user: selectedData.user.filter(e => !e.enabled).map(e => e.path),
|
||||
});
|
||||
await useAppStore.getState().savePaths();
|
||||
onClose();
|
||||
const result = await useAppStore.getState().savePaths();
|
||||
if (result.kind === 'success') {
|
||||
onClose();
|
||||
} else if (result.kind === 'warning') {
|
||||
const { ask } = await import('@tauri-apps/plugin-dialog');
|
||||
const confirmed = await ask(t('status.saveWarningLongPaths'), { title: t('dialog.backupTitle'), kind: 'warning' });
|
||||
if (confirmed) {
|
||||
const forceResult = await useAppStore.getState().savePaths(true);
|
||||
if (forceResult.kind === 'success') {
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async (name: string) => {
|
||||
|
||||
Reference in New Issue
Block a user