style: cargo fmt (fix CI format check)

This commit is contained in:
晴天
2026-03-11 03:03:47 +08:00
parent 5cd160f4e0
commit 16999e66b7
5 changed files with 36 additions and 23 deletions

View File

@@ -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

View File

@@ -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<Value, String> {
pub async fn verify_bot_token(platform: String, form: Value) -> Result<Value, String> {
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<String, Strin
let _ = handle.join();
let _ = app.emit("plugin-progress", 95);
let status = child.wait().map_err(|e| format!("等待安装进程失败: {}", e))?;
let status = child
.wait()
.map_err(|e| format!("等待安装进程失败: {}", e))?;
let _ = app.emit("plugin-progress", 100);
if !status.success() {

View File

@@ -149,10 +149,7 @@ fn patch_gateway_origins() {
merged.push(r.clone());
}
}
cui.insert(
"allowedOrigins".to_string(),
serde_json::json!(merged),
);
cui.insert("allowedOrigins".to_string(), serde_json::json!(merged));
}
}
}

View File

@@ -112,7 +112,9 @@ pub async fn skills_install_dep(kind: String, spec: Value) -> Result<Value, Stri
cmd.args(&args).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!("执行 {program} 失败: {e}"))?;
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
@@ -150,7 +152,9 @@ pub async fn skills_clawhub_install(slug: String) -> Result<Value, String> {
.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<Value, String> {
.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() {

View File

@@ -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() {