From bafcdb91a841fcc6ebeeac1b3c4c194ee002d7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Fri, 13 Mar 2026 16:07:17 +0800 Subject: [PATCH] style: cargo fmt (fix CI rustfmt check) --- src-tauri/src/commands/config.rs | 46 ++++++++++++++++++++++++----- src-tauri/src/commands/messaging.rs | 26 ++++++++++++---- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src-tauri/src/commands/config.rs b/src-tauri/src/commands/config.rs index dc78124..5e68603 100644 --- a/src-tauri/src/commands/config.rs +++ b/src-tauri/src/commands/config.rs @@ -641,7 +641,12 @@ pub async fn upgrade_openclaw( let _ = app.emit("upgrade-log", "配置 Git HTTPS 模式..."); // 先清除旧的 insteadOf 规则,再逐条添加(git config 不带 --add 会覆盖,只保留最后一条) let _ = Command::new("git") - .args(["config", "--global", "--unset-all", "url.https://github.com/.insteadOf"]) + .args([ + "config", + "--global", + "--unset-all", + "url.https://github.com/.insteadOf", + ]) .output(); for from in &[ "ssh://git@github.com/", @@ -682,7 +687,10 @@ pub async fn upgrade_openclaw( let mut child = npm_command() .args(["install", "-g", &pkg, "--registry", registry, "--verbose"]) .env("GIT_TERMINAL_PROMPT", "0") - .env("GIT_SSH_COMMAND", "ssh -o BatchMode=yes -o StrictHostKeyChecking=no") + .env( + "GIT_SSH_COMMAND", + "ssh -o BatchMode=yes -o StrictHostKeyChecking=no", + ) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() @@ -738,7 +746,10 @@ pub async fn upgrade_openclaw( let mut child2 = npm_command() .args(["install", "-g", &pkg, "--registry", fallback, "--verbose"]) .env("GIT_TERMINAL_PROMPT", "0") - .env("GIT_SSH_COMMAND", "ssh -o BatchMode=yes -o StrictHostKeyChecking=no") + .env( + "GIT_SSH_COMMAND", + "ssh -o BatchMode=yes -o StrictHostKeyChecking=no", + ) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() @@ -754,7 +765,10 @@ pub async fn upgrade_openclaw( for line in BufReader::new(pipe).lines().map_while(Result::ok) { let _ = app3.emit("upgrade-log", &line); stderr_lines4.lock().unwrap().push(line); - if p < 75 { p += 2; let _ = app3.emit("upgrade-progress", p); } + if p < 75 { + p += 2; + let _ = app3.emit("upgrade-progress", p); + } } } }); @@ -765,12 +779,28 @@ pub async fn upgrade_openclaw( } let _ = handle2.join(); let _ = app.emit("upgrade-progress", 80); - let status2 = child2.wait().map_err(|e| format!("等待重试进程失败: {e}"))?; + let status2 = child2 + .wait() + .map_err(|e| format!("等待重试进程失败: {e}"))?; let _ = app.emit("upgrade-progress", 100); if !status2.success() { - let code2 = status2.code().map(|c| c.to_string()).unwrap_or("unknown".into()); - let tail = stderr_lines3.lock().unwrap().iter().rev().take(15).rev().cloned().collect::>().join("\n"); - return Err(format!("升级失败(镜像源和官方源均失败),exit code: {code2}\n{tail}")); + let code2 = status2 + .code() + .map(|c| c.to_string()) + .unwrap_or("unknown".into()); + let tail = stderr_lines3 + .lock() + .unwrap() + .iter() + .rev() + .take(15) + .rev() + .cloned() + .collect::>() + .join("\n"); + return Err(format!( + "升级失败(镜像源和官方源均失败),exit code: {code2}\n{tail}" + )); } let _ = app.emit("upgrade-log", "✅ 官方源安装成功"); } else { diff --git a/src-tauri/src/commands/messaging.rs b/src-tauri/src/commands/messaging.rs index 517c78b..d1cc262 100644 --- a/src-tauri/src/commands/messaging.rs +++ b/src-tauri/src/commands/messaging.rs @@ -915,16 +915,24 @@ fn is_plugin_builtin(plugin_id: &str) -> bool { } #[cfg(target_os = "macos")] { - dirs.push(PathBuf::from("/opt/homebrew/lib/node_modules/@qingchencloud/openclaw-zh")); + dirs.push(PathBuf::from( + "/opt/homebrew/lib/node_modules/@qingchencloud/openclaw-zh", + )); dirs.push(PathBuf::from("/opt/homebrew/lib/node_modules/openclaw")); - dirs.push(PathBuf::from("/usr/local/lib/node_modules/@qingchencloud/openclaw-zh")); + dirs.push(PathBuf::from( + "/usr/local/lib/node_modules/@qingchencloud/openclaw-zh", + )); dirs.push(PathBuf::from("/usr/local/lib/node_modules/openclaw")); } #[cfg(target_os = "linux")] { - dirs.push(PathBuf::from("/usr/local/lib/node_modules/@qingchencloud/openclaw-zh")); + dirs.push(PathBuf::from( + "/usr/local/lib/node_modules/@qingchencloud/openclaw-zh", + )); dirs.push(PathBuf::from("/usr/local/lib/node_modules/openclaw")); - dirs.push(PathBuf::from("/usr/lib/node_modules/@qingchencloud/openclaw-zh")); + dirs.push(PathBuf::from( + "/usr/lib/node_modules/@qingchencloud/openclaw-zh", + )); dirs.push(PathBuf::from("/usr/lib/node_modules/openclaw")); } dirs @@ -1219,8 +1227,14 @@ pub async fn install_qqbot_plugin(app: tauri::AppHandle) -> Result