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
+2
View File
@@ -63,6 +63,8 @@ pub fn save_user_paths(paths: Vec<String>) -> Result<(), String> {
save_paths(HKEY_CURRENT_USER, USER_REG_PATH, "用户", &paths)
}
/// 将分号分隔的 PATH 字符串拆分为数组。
/// 注意:TS 端 src/core/validation.ts 有相同逻辑的 split_path,修改时需同步两端。
pub(crate) fn split_path(raw: &str) -> Vec<String> {
raw.split(';')
.map(|s| s.trim().to_string())
-36
View File
@@ -1,36 +0,0 @@
use serde::Serialize;
/// 传给前端的统一错误类型(保留供未来迁移使用,届时所有命令改为返回 Result<T, AppError>
#[allow(dead_code)]
#[derive(Debug, Serialize)]
pub struct AppError {
pub message: String,
}
impl std::fmt::Display for AppError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.message)
}
}
impl From<&str> for AppError {
fn from(s: &str) -> Self {
AppError {
message: s.to_string(),
}
}
}
impl From<String> for AppError {
fn from(s: String) -> Self {
AppError { message: s }
}
}
impl From<std::io::Error> for AppError {
fn from(e: std::io::Error) -> Self {
AppError {
message: format!("IO 错误: {}", e),
}
}
}
-1
View File
@@ -1,5 +1,4 @@
mod commands;
mod error;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {