From f39305181f9eb7de0c58ccd01909370702a45a89 Mon Sep 17 00:00:00 2001 From: coso Date: Sat, 20 Dec 2025 19:13:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Windows=20=E4=B8=8B?= =?UTF-8?q?=20Kiro=20=E5=87=AD=E8=AF=81=E4=BD=BF=E7=94=A8=E6=97=B6?= =?UTF-8?q?=E7=BB=88=E7=AB=AF=E7=AA=97=E5=8F=A3=E9=97=AA=E7=8E=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - usage_cmd.rs: reg query 命令添加 CREATE_NO_WINDOW - kiro.rs: wmic 命令添加 CREATE_NO_WINDOW 这两处是 PR #13 遗漏的,是 Kiro 凭证频繁调用的命令 --- src-tauri/Cargo.lock | 2 +- src-tauri/src/commands/usage_cmd.rs | 2 ++ src-tauri/src/providers/kiro.rs | 29 ++++++++++++++++++----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1ca411650..d8b334eb5 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3367,7 +3367,7 @@ dependencies = [ [[package]] name = "proxycast" -version = "0.14.2" +version = "0.14.3" dependencies = [ "anyhow", "async-stream", diff --git a/src-tauri/src/commands/usage_cmd.rs b/src-tauri/src/commands/usage_cmd.rs index 2c6a24a87..16b42f052 100644 --- a/src-tauri/src/commands/usage_cmd.rs +++ b/src-tauri/src/commands/usage_cmd.rs @@ -171,6 +171,7 @@ fn get_raw_machine_id() -> Result { #[cfg(target_os = "windows")] { // Windows: 使用注册表中的 MachineGuid + use std::os::windows::process::CommandExt; use std::process::Command; let output = Command::new("reg") .args([ @@ -179,6 +180,7 @@ fn get_raw_machine_id() -> Result { "/v", "MachineGuid", ]) + .creation_flags(0x08000000) // CREATE_NO_WINDOW .output() .map_err(|e| format!("执行 reg query 失败: {}", e))?; diff --git a/src-tauri/src/providers/kiro.rs b/src-tauri/src/providers/kiro.rs index 27a2e9c62..638f751ad 100644 --- a/src-tauri/src/providers/kiro.rs +++ b/src-tauri/src/providers/kiro.rs @@ -52,17 +52,24 @@ fn get_raw_machine_id() -> Option { .map(|s| s.trim().to_lowercase()) } else if cfg!(target_os = "windows") { // Windows: 使用 wmic 获取系统 UUID - Command::new("wmic") - .args(["csproduct", "get", "UUID"]) - .output() - .ok() - .and_then(|o| String::from_utf8(o.stdout).ok()) - .and_then(|s| { - s.lines() - .skip(1) // 跳过表头 - .find(|l| !l.trim().is_empty()) - .map(|s| s.trim().to_lowercase()) - }) + #[cfg(target_os = "windows")] + { + use std::os::windows::process::CommandExt; + Command::new("wmic") + .args(["csproduct", "get", "UUID"]) + .creation_flags(0x08000000) // CREATE_NO_WINDOW + .output() + .ok() + .and_then(|o| String::from_utf8(o.stdout).ok()) + .and_then(|s| { + s.lines() + .skip(1) // 跳过表头 + .find(|l| !l.trim().is_empty()) + .map(|s| s.trim().to_lowercase()) + }) + } + #[cfg(not(target_os = "windows"))] + None } else { None }