Skip to content

Commit 2e79602

Browse files
committed
fix: 解决终端窗口闪现问题
- 在 Windows 上为所有外部命令添加 CREATE_NO_WINDOW 标志 - 修复托盘复制 API 地址功能 - 修复打开配置文件夹和认证目录功能 - 修复工具版本检查功能 - 添加 sonner 依赖解决前端构建问题 - 修复代码格式问题
1 parent ffaa1bd commit 2e79602

3 files changed

Lines changed: 59 additions & 2 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/src/commands/config_cmd.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use std::path::PathBuf;
88
use tauri::AppHandle;
99
use tauri_plugin_autostart::ManagerExt;
1010

11+
#[cfg(target_os = "windows")]
12+
use std::os::windows::process::CommandExt;
13+
1114
#[derive(Debug, Clone, Serialize, Deserialize)]
1215
pub struct ConfigStatus {
1316
pub exists: bool,
@@ -85,6 +88,7 @@ pub async fn open_config_folder(_handle: AppHandle, app_type: String) -> Result<
8588
{
8689
std::process::Command::new("explorer")
8790
.arg(&config_dir)
91+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
8892
.spawn()
8993
.map_err(|e| e.to_string())?;
9094
}
@@ -112,6 +116,22 @@ pub async fn get_tool_versions() -> Result<Vec<ToolVersion>, String> {
112116
let mut versions = Vec::new();
113117

114118
// Check Claude Code version
119+
#[cfg(target_os = "windows")]
120+
let claude_version = std::process::Command::new("claude")
121+
.arg("--version")
122+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
123+
.output()
124+
.ok()
125+
.and_then(|o| {
126+
if o.status.success() {
127+
String::from_utf8(o.stdout).ok()
128+
} else {
129+
None
130+
}
131+
})
132+
.map(|s| s.trim().to_string());
133+
134+
#[cfg(not(target_os = "windows"))]
115135
let claude_version = std::process::Command::new("claude")
116136
.arg("--version")
117137
.output()
@@ -132,6 +152,22 @@ pub async fn get_tool_versions() -> Result<Vec<ToolVersion>, String> {
132152
});
133153

134154
// Check Codex version
155+
#[cfg(target_os = "windows")]
156+
let codex_version = std::process::Command::new("codex")
157+
.arg("--version")
158+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
159+
.output()
160+
.ok()
161+
.and_then(|o| {
162+
if o.status.success() {
163+
String::from_utf8(o.stdout).ok()
164+
} else {
165+
None
166+
}
167+
})
168+
.map(|s| s.trim().to_string());
169+
170+
#[cfg(not(target_os = "windows"))]
135171
let codex_version = std::process::Command::new("codex")
136172
.arg("--version")
137173
.output()
@@ -152,6 +188,22 @@ pub async fn get_tool_versions() -> Result<Vec<ToolVersion>, String> {
152188
});
153189

154190
// Check Gemini CLI version
191+
#[cfg(target_os = "windows")]
192+
let gemini_version = std::process::Command::new("gemini")
193+
.arg("--version")
194+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
195+
.output()
196+
.ok()
197+
.and_then(|o| {
198+
if o.status.success() {
199+
String::from_utf8(o.stdout).ok()
200+
} else {
201+
None
202+
}
203+
})
204+
.map(|s| s.trim().to_string());
205+
206+
#[cfg(not(target_os = "windows"))]
155207
let gemini_version = std::process::Command::new("gemini")
156208
.arg("--version")
157209
.output()
@@ -559,6 +611,7 @@ pub async fn open_auth_dir(path: String) -> Result<bool, String> {
559611
{
560612
std::process::Command::new("explorer")
561613
.arg(&expanded)
614+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
562615
.spawn()
563616
.map_err(|e| e.to_string())?;
564617
}

src-tauri/src/tray/menu_handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use tauri::{AppHandle, Emitter, Manager, Runtime};
1212
use tauri_plugin_autostart::ManagerExt;
1313
use tracing::{debug, error, info, warn};
1414

15+
#[cfg(target_os = "windows")]
16+
use std::os::windows::process::CommandExt;
17+
1518
/// 菜单事件类型
1619
///
1720
/// 用于前端监听的事件名称
@@ -191,6 +194,7 @@ fn handle_copy_api_address<R: Runtime>(app: &AppHandle<R>) {
191194
{
192195
let _ = std::process::Command::new("cmd")
193196
.args(["/C", &format!("echo {} | clip", api_address)])
197+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
194198
.spawn();
195199
info!("[托盘] API 地址已复制到剪贴板: {}", api_address);
196200
}

0 commit comments

Comments
 (0)