Skip to content

Commit 64bdd15

Browse files
committed
refactor: Improve process termination handling on Windows and update window behavior during shutdown
1 parent a401adb commit 64bdd15

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

frontend/src-tauri/src/backend.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,13 @@ impl BackendManager {
698698
log::info!("🛑 使用 taskkill 强制终止进程树 (PID={})...", pid);
699699

700700
// /F 强制终止 /T 包含子进程
701-
let kill_result = Command::new("taskkill")
702-
.args(["/F", "/T", "/PID", &pid.to_string()])
703-
.output();
701+
let mut kill_cmd = Command::new("taskkill");
702+
kill_cmd.args(["/F", "/T", "/PID", &pid.to_string()]);
703+
#[cfg(target_os = "windows")]
704+
{
705+
kill_cmd.creation_flags(windows_subsystem_flag());
706+
}
707+
let kill_result = kill_cmd.output();
704708

705709
match kill_result {
706710
Ok(output) => {

frontend/src-tauri/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ pub fn run() {
4949
// 已经在关闭中,直接忽略后续点击
5050
if GRACEFUL_SHUTDOWN_STARTED.swap(true, Ordering::SeqCst) {
5151
api.prevent_close();
52+
let _ = window.hide();
5253
return;
5354
}
5455
api.prevent_close();
5556

56-
// 最小化窗口给用户反馈(关闭正在进行)
57-
let _ = window.minimize();
57+
// 立即隐藏窗口,避免关闭时出现最小化/弹回的怪异反馈。
58+
let _ = window.hide();
5859

5960
let app_handle = window.app_handle().clone();
6061
std::thread::spawn(move || {

0 commit comments

Comments
 (0)