fix(shutdown): mark shutdown as exiting to stop background tasks (#5024)

* fix(shutdown): mark shutdown as exiting to stop background tasks

- lib.rs:570 → Flag app as exiting on ExitRequested, notify proxy guard, start cleanup immediately, with fallback in Exit event
- tray/mod.rs:190 → Add unified exit checks around tray init/updates to prevent UI recreation during shutdown
- event_driven_proxy.rs:252 → Ensure proxy guard skips all restore/re-enable work (including sysproxy.exe calls) once exit flag is set

* fix(shutdown): refine exit handling and proxy guard notifications

* fix(shutdown): add guard to run shutdown routine only once per lifecycle
This commit is contained in:
Sline
2025-10-11 16:49:47 +08:00
committed by GitHub
parent 601e99f0b5
commit 3d2507430b
4 changed files with 115 additions and 13 deletions

View File

@@ -12,7 +12,7 @@ mod utils;
#[cfg(target_os = "macos")]
use crate::utils::window_manager::WindowManager;
use crate::{
core::{handle, hotkey},
core::{EventDrivenProxyManager, handle, hotkey},
process::AsyncHandler,
utils::{resolve, server},
};
@@ -584,11 +584,20 @@ pub fn run() {
}
}
tauri::RunEvent::Exit => {
// Avoid duplicate cleanup
if core::handle::Handle::global().is_exiting() {
return;
let handle = core::handle::Handle::global();
if handle.is_exiting() {
logging!(
debug,
Type::System,
"Exit事件触发但退出流程已执行跳过重复清理"
);
} else {
logging!(debug, Type::System, "Exit事件触发执行清理流程");
handle.set_is_exiting();
EventDrivenProxyManager::global().notify_app_stopping();
feat::clean();
}
feat::clean();
}
tauri::RunEvent::WindowEvent { label, event, .. } => {
if label == "main" {