Skip to content

Commit f393051

Browse files
committed
fix: 修复 Windows 下 Kiro 凭证使用时终端窗口闪现问题
- usage_cmd.rs: reg query 命令添加 CREATE_NO_WINDOW - kiro.rs: wmic 命令添加 CREATE_NO_WINDOW 这两处是 PR #13 遗漏的,是 Kiro 凭证频繁调用的命令
1 parent 7a09af8 commit f393051

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/src/commands/usage_cmd.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ fn get_raw_machine_id() -> Result<String, String> {
171171
#[cfg(target_os = "windows")]
172172
{
173173
// Windows: 使用注册表中的 MachineGuid
174+
use std::os::windows::process::CommandExt;
174175
use std::process::Command;
175176
let output = Command::new("reg")
176177
.args([
@@ -179,6 +180,7 @@ fn get_raw_machine_id() -> Result<String, String> {
179180
"/v",
180181
"MachineGuid",
181182
])
183+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
182184
.output()
183185
.map_err(|e| format!("执行 reg query 失败: {}", e))?;
184186

src-tauri/src/providers/kiro.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,24 @@ fn get_raw_machine_id() -> Option<String> {
5252
.map(|s| s.trim().to_lowercase())
5353
} else if cfg!(target_os = "windows") {
5454
// Windows: 使用 wmic 获取系统 UUID
55-
Command::new("wmic")
56-
.args(["csproduct", "get", "UUID"])
57-
.output()
58-
.ok()
59-
.and_then(|o| String::from_utf8(o.stdout).ok())
60-
.and_then(|s| {
61-
s.lines()
62-
.skip(1) // 跳过表头
63-
.find(|l| !l.trim().is_empty())
64-
.map(|s| s.trim().to_lowercase())
65-
})
55+
#[cfg(target_os = "windows")]
56+
{
57+
use std::os::windows::process::CommandExt;
58+
Command::new("wmic")
59+
.args(["csproduct", "get", "UUID"])
60+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
61+
.output()
62+
.ok()
63+
.and_then(|o| String::from_utf8(o.stdout).ok())
64+
.and_then(|s| {
65+
s.lines()
66+
.skip(1) // 跳过表头
67+
.find(|l| !l.trim().is_empty())
68+
.map(|s| s.trim().to_lowercase())
69+
})
70+
}
71+
#[cfg(not(target_os = "windows"))]
72+
None
6673
} else {
6774
None
6875
}

0 commit comments

Comments
 (0)