fix: 修复 Windows 下 Kiro 凭证使用时终端窗口闪现问题

- usage_cmd.rs: reg query 命令添加 CREATE_NO_WINDOW
- kiro.rs: wmic 命令添加 CREATE_NO_WINDOW

这两处是 PR #13 遗漏的,是 Kiro 凭证频繁调用的命令
This commit is contained in:
coso
2025-12-20 19:13:00 +08:00
parent 7a09af8dc3
commit f39305181f
3 changed files with 21 additions and 12 deletions
+1 -1
View File
@@ -3367,7 +3367,7 @@ dependencies = [
[[package]]
name = "proxycast"
version = "0.14.2"
version = "0.14.3"
dependencies = [
"anyhow",
"async-stream",
+2
View File
@@ -171,6 +171,7 @@ fn get_raw_machine_id() -> Result<String, String> {
#[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<String, String> {
"/v",
"MachineGuid",
])
.creation_flags(0x08000000) // CREATE_NO_WINDOW
.output()
.map_err(|e| format!("执行 reg query 失败: {}", e))?;
+18 -11
View File
@@ -52,17 +52,24 @@ fn get_raw_machine_id() -> Option<String> {
.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
}