From 16999e66b736ae582b307c9cebedac7ac0d6a9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Wed, 11 Mar 2026 03:03:47 +0800 Subject: [PATCH] style: cargo fmt (fix CI format check) --- src-tauri/src/commands/config.rs | 23 +++++++++++++++++++---- src-tauri/src/commands/messaging.rs | 15 +++++---------- src-tauri/src/commands/pairing.rs | 5 +---- src-tauri/src/commands/skills.rs | 12 +++++++++--- src-tauri/src/lib.rs | 4 ++-- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src-tauri/src/commands/config.rs b/src-tauri/src/commands/config.rs index 21202d7..8f2dc54 100644 --- a/src-tauri/src/commands/config.rs +++ b/src-tauri/src/commands/config.rs @@ -1315,7 +1315,9 @@ pub async fn test_model( } // 其他错误(400/422 等):服务器可达、认证通过,仅模型对简单测试不兼容 // 返回成功但带提示,避免误导用户认为模型不可用 - return Ok(format!("⚠ 连接正常(API 返回 {status},部分模型对简单测试不兼容,不影响实际使用)")); + return Ok(format!( + "⚠ 连接正常(API 返回 {status},部分模型对简单测试不兼容,不影响实际使用)" + )); } // 提取回复内容(兼容多种响应格式) @@ -1323,18 +1325,31 @@ pub async fn test_model( .ok() .and_then(|v| { // 标准 OpenAI 格式: choices[0].message.content - if let Some(msg) = v.get("choices").and_then(|c| c.get(0)).and_then(|c| c.get("message")) { + if let Some(msg) = v + .get("choices") + .and_then(|c| c.get(0)) + .and_then(|c| c.get("message")) + { let content = msg.get("content").and_then(|c| c.as_str()).unwrap_or(""); if !content.is_empty() { return Some(content.to_string()); } // reasoning 模型 - if let Some(rc) = msg.get("reasoning_content").and_then(|c| c.as_str()).filter(|s| !s.is_empty()) { + if let Some(rc) = msg + .get("reasoning_content") + .and_then(|c| c.as_str()) + .filter(|s| !s.is_empty()) + { return Some(format!("[reasoning] {rc}")); } } // DashScope 格式: output.text - if let Some(t) = v.get("output").and_then(|o| o.get("text")).and_then(|t| t.as_str()).filter(|s| !s.is_empty()) { + if let Some(t) = v + .get("output") + .and_then(|o| o.get("text")) + .and_then(|t| t.as_str()) + .filter(|s| !s.is_empty()) + { return Some(t.to_string()); } None diff --git a/src-tauri/src/commands/messaging.rs b/src-tauri/src/commands/messaging.rs index ae06fd6..33bfdc1 100644 --- a/src-tauri/src/commands/messaging.rs +++ b/src-tauri/src/commands/messaging.rs @@ -1,7 +1,6 @@ /// 消息渠道管理 /// 负责 Telegram / Discord / QQ Bot 等消息渠道的配置持久化与凭证校验 /// 配置写入 openclaw.json 的 channels / plugins 节点 - use serde_json::{json, Map, Value}; /// 读取指定平台的当前配置(从 openclaw.json 中提取表单可用的值) @@ -237,10 +236,7 @@ pub async fn save_messaging_platform( entry.insert("appId".into(), Value::String(app_id)); entry.insert("appSecret".into(), Value::String(app_secret)); entry.insert("enabled".into(), Value::Bool(true)); - entry.insert( - "connectionMode".into(), - Value::String("websocket".into()), - ); + entry.insert("connectionMode".into(), Value::String("websocket".into())); // 域名(默认 feishu,国际版选 lark) let domain = form_obj @@ -320,10 +316,7 @@ pub async fn toggle_messaging_platform( /// 在线校验 Bot 凭证(调用平台 API 验证 Token 是否有效) #[tauri::command] -pub async fn verify_bot_token( - platform: String, - form: Value, -) -> Result { +pub async fn verify_bot_token(platform: String, form: Value) -> Result { let form_obj = form.as_object().ok_or("表单数据格式错误")?; let client = reqwest::Client::builder() .timeout(std::time::Duration::from_secs(15)) @@ -551,7 +544,9 @@ pub async fn install_qqbot_plugin(app: tauri::AppHandle) -> Result Result Result { .current_dir(&home); #[cfg(target_os = "windows")] cmd.creation_flags(0x08000000); - let output = cmd.output().await + let output = cmd + .output() + .await .map_err(|e| format!("执行 clawhub 失败: {e}"))?; let stdout = String::from_utf8_lossy(&output.stdout).to_string(); @@ -181,7 +185,9 @@ pub async fn skills_clawhub_search(query: String) -> Result { .env("PATH", &path_env); #[cfg(target_os = "windows")] cmd.creation_flags(0x08000000); - let output = cmd.output().await + let output = cmd + .output() + .await .map_err(|e| format!("执行 clawhub 失败: {e}"))?; if !output.status.success() { diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c33a1fe..de8822d 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -4,8 +4,8 @@ mod tray; mod utils; use commands::{ - agent, assistant, config, device, extensions, logs, memory, messaging, pairing, service, skills, - update, + agent, assistant, config, device, extensions, logs, memory, messaging, pairing, service, + skills, update, }; pub fn run() {