mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-06 20:02:49 +08:00
fix: 修复 Tauri GUI 环境下安装源检测错误
Tauri 进程 PATH 不含 /opt/homebrew/bin,导致 npm list 命令 静默失败,始终返回 official。改为优先检查 openclaw bin 的 symlink 指向判断安装源,npm list 作为 fallback。
This commit is contained in:
@@ -85,13 +85,21 @@ async fn get_latest_version_for(source: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
/// 检测当前安装的是官方版还是汉化版
|
||||
/// 优先检查文件系统(不依赖 npm 命令的 PATH),fallback 到 npm list
|
||||
fn detect_installed_source() -> String {
|
||||
let output = Command::new("npm")
|
||||
// 方法1:直接检查 openclaw bin 的 symlink 指向
|
||||
if let Ok(target) = std::fs::read_link("/opt/homebrew/bin/openclaw") {
|
||||
if target.to_string_lossy().contains("openclaw-zh") {
|
||||
return "chinese".into();
|
||||
}
|
||||
return "official".into();
|
||||
}
|
||||
// 方法2:fallback 到 npm list
|
||||
if let Ok(o) = Command::new("npm")
|
||||
.args(["list", "-g", "@qingchencloud/openclaw-zh", "--depth=0"])
|
||||
.output();
|
||||
if let Ok(o) = output {
|
||||
let text = String::from_utf8_lossy(&o.stdout);
|
||||
if text.contains("openclaw-zh@") {
|
||||
.output()
|
||||
{
|
||||
if String::from_utf8_lossy(&o.stdout).contains("openclaw-zh@") {
|
||||
return "chinese".into();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user