From da8932a3e0eca896cfeae887bbed16e132f123ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Sat, 28 Feb 2026 13:27:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Tauri=20GUI=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E5=AE=89=E8=A3=85=E6=BA=90=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tauri 进程 PATH 不含 /opt/homebrew/bin,导致 npm list 命令 静默失败,始终返回 official。改为优先检查 openclaw bin 的 symlink 指向判断安装源,npm list 作为 fallback。 --- src-tauri/src/commands/config.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/commands/config.rs b/src-tauri/src/commands/config.rs index fb62e47..a9e8d69 100644 --- a/src-tauri/src/commands/config.rs +++ b/src-tauri/src/commands/config.rs @@ -85,13 +85,21 @@ async fn get_latest_version_for(source: &str) -> Option { } /// 检测当前安装的是官方版还是汉化版 +/// 优先检查文件系统(不依赖 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(); } }