fix: 最终审查修复 — 数据安全、功能缺失、状态管理

Rust:
- save_paths 添加 Windows PATH 32767 字符上限检查防静默截断
- backup_registry 回退路径统一为 backup_base_dir() 三级链

Store:
- 新增 isSaving 并发守卫防止重复保存
- 保存失败详情通过 Promise.allSettled.reason 展示
- isModified 改为与上次保存快照比较(undo/redo 后准确反映状态)
- 批删除合并为单条撤销记录(N 次删除 → 1 次 Ctrl+Z 恢复)
- 保存失败/备份失败使用 i18n 键(消除硬编码中文)

UI:
- 拖拽添加改用 webkitGetAsEntry().isDirectory 校验文件夹
- Ctrl+F 快捷键聚焦搜索框
- handleClean 使用 is_valid_path_format(替代不完整的 inline 函数)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 00:48:43 +08:00
parent e6a2416271
commit b159407773
8 changed files with 118 additions and 67 deletions
+8 -11
View File
@@ -2,16 +2,18 @@ use chrono::Local;
use std::fs;
use std::path::PathBuf;
/// 获取 APPDATA 路径下的备份目录
#[tauri::command]
pub fn get_appdata_dir() -> String {
fn backup_base_dir() -> PathBuf {
dirs::data_dir()
.or_else(dirs::home_dir)
.unwrap_or_else(|| PathBuf::from("."))
.join("PathEditor")
.join("backups")
.to_string_lossy()
.to_string()
}
/// 获取 APPDATA 路径下的备份目录
#[tauri::command]
pub fn get_appdata_dir() -> String {
backup_base_dir().to_string_lossy().to_string()
}
/// 备份当前注册表中的系统 PATH 和用户 PATH
@@ -21,12 +23,7 @@ pub fn backup_registry(custom_dir: Option<String>, sys_paths: Vec<String>, user_
// 确定备份目录
let backup_dir = match custom_dir {
Some(ref dir) if !dir.is_empty() => PathBuf::from(dir),
_ => {
dirs::data_dir()
.unwrap_or_else(|| PathBuf::from("C:\\"))
.join("PathEditor")
.join("backups")
}
_ => backup_base_dir(),
};
// 创建目录