fix: cargo fmt

This commit is contained in:
晴天
2026-03-08 01:52:25 +08:00
parent 02e1ef6b14
commit af6a447cf1
2 changed files with 25 additions and 15 deletions

View File

@@ -502,8 +502,7 @@ pub async fn list_openclaw_versions(source: String) -> Result<Vec<String>, 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<Vec<String>, Strin
let mut vers: Vec<String> = obj.keys().cloned().collect();
// 按版本号排序(新版本在前)
vers.sort_by(|a, b| {
let pa: Vec<u32> = a.split(|c: char| !c.is_ascii_digit()).filter_map(|s| s.parse().ok()).collect();
let pb: Vec<u32> = b.split(|c: char| !c.is_ascii_digit()).filter_map(|s| s.parse().ok()).collect();
let pa: Vec<u32> = a
.split(|c: char| !c.is_ascii_digit())
.filter_map(|s| s.parse().ok())
.collect();
let pb: Vec<u32> = 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<Vec<String>, Strin
/// 执行 npm 全局安装/升级/降级 openclaw流式推送日志
#[tauri::command]
pub async fn upgrade_openclaw(app: tauri::AppHandle, source: String, version: Option<String>) -> Result<String, String> {
pub async fn upgrade_openclaw(
app: tauri::AppHandle,
source: String,
version: Option<String>,
) -> Result<String, String> {
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. 可选:清理配置目录

View File

@@ -77,7 +77,10 @@ pub async fn skills_install_dep(kind: String, spec: Value) -> Result<Value, Stri
.and_then(|v| v.as_str())
.ok_or("缺少 package 参数")?
.to_string();
("npm".to_string(), vec!["install".to_string(), "-g".to_string(), package])
(
"npm".to_string(),
vec!["install".to_string(), "-g".to_string(), package],
)
}
"go" => {
let module = spec
@@ -93,7 +96,10 @@ pub async fn skills_install_dep(kind: String, spec: Value) -> Result<Value, Stri
.and_then(|v| v.as_str())
.ok_or("缺少 package 参数")?
.to_string();
("uv".to_string(), vec!["tool".to_string(), "install".to_string(), package])
(
"uv".to_string(),
vec!["tool".to_string(), "install".to_string(), package],
)
}
other => return Err(format!("不支持的安装类型: {other}")),
};
@@ -131,8 +137,7 @@ pub async fn skills_clawhub_install(slug: String) -> Result<Value, String> {
// 确保 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")