diff --git a/src-tauri/src/commands/config.rs b/src-tauri/src/commands/config.rs index 231ba16..2ee1e21 100644 --- a/src-tauri/src/commands/config.rs +++ b/src-tauri/src/commands/config.rs @@ -502,8 +502,7 @@ pub async fn list_openclaw_versions(source: String) -> Result, Strin .timeout(std::time::Duration::from_secs(10)) .build() .map_err(|e| format!("HTTP 初始化失败: {e}"))?; - let pkg = npm_package_name(&source) - .replace('/', "%2F"); + let pkg = npm_package_name(&source).replace('/', "%2F"); let registry = get_configured_registry(); let url = format!("{registry}/{pkg}"); let resp = client @@ -523,8 +522,14 @@ pub async fn list_openclaw_versions(source: String) -> Result, Strin let mut vers: Vec = obj.keys().cloned().collect(); // 按版本号排序(新版本在前) vers.sort_by(|a, b| { - let pa: Vec = a.split(|c: char| !c.is_ascii_digit()).filter_map(|s| s.parse().ok()).collect(); - let pb: Vec = b.split(|c: char| !c.is_ascii_digit()).filter_map(|s| s.parse().ok()).collect(); + let pa: Vec = a + .split(|c: char| !c.is_ascii_digit()) + .filter_map(|s| s.parse().ok()) + .collect(); + let pb: Vec = b + .split(|c: char| !c.is_ascii_digit()) + .filter_map(|s| s.parse().ok()) + .collect(); pb.cmp(&pa) }); vers @@ -535,7 +540,11 @@ pub async fn list_openclaw_versions(source: String) -> Result, Strin /// 执行 npm 全局安装/升级/降级 openclaw(流式推送日志) #[tauri::command] -pub async fn upgrade_openclaw(app: tauri::AppHandle, source: String, version: Option) -> Result { +pub async fn upgrade_openclaw( + app: tauri::AppHandle, + source: String, + version: Option, +) -> Result { use std::io::{BufRead, BufReader}; use std::process::Stdio; use tauri::Emitter; @@ -728,9 +737,7 @@ pub async fn uninstall_openclaw( let _ = app.emit("upgrade-log", "正在卸载 Gateway 服务..."); #[cfg(not(target_os = "macos"))] { - let _ = openclaw_command() - .args(["gateway", "uninstall"]) - .output(); + let _ = openclaw_command().args(["gateway", "uninstall"]).output(); } // 3. npm uninstall @@ -781,9 +788,7 @@ pub async fn uninstall_openclaw( "openclaw" }; let _ = app.emit("upgrade-log", format!("清理 {other_pkg}...")); - let _ = npm_command() - .args(["uninstall", "-g", other_pkg]) - .output(); + let _ = npm_command().args(["uninstall", "-g", other_pkg]).output(); let _ = app.emit("upgrade-progress", 80); // 5. 可选:清理配置目录 diff --git a/src-tauri/src/commands/skills.rs b/src-tauri/src/commands/skills.rs index 131c82f..e89cb9a 100644 --- a/src-tauri/src/commands/skills.rs +++ b/src-tauri/src/commands/skills.rs @@ -77,7 +77,10 @@ pub async fn skills_install_dep(kind: String, spec: Value) -> Result { let module = spec @@ -93,7 +96,10 @@ pub async fn skills_install_dep(kind: String, spec: Value) -> Result return Err(format!("不支持的安装类型: {other}")), }; @@ -131,8 +137,7 @@ pub async fn skills_clawhub_install(slug: String) -> Result { // 确保 skills 目录存在 let skills_dir = super::openclaw_dir().join("skills"); if !skills_dir.exists() { - std::fs::create_dir_all(&skills_dir) - .map_err(|e| format!("创建 skills 目录失败: {e}"))?; + std::fs::create_dir_all(&skills_dir).map_err(|e| format!("创建 skills 目录失败: {e}"))?; } let output = tokio::process::Command::new("npx")