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

@@ -1,12 +1,9 @@
use crate::config::Config;
use crate::core::event_driven_proxy::EventDrivenProxyManager;
use crate::core::{CoreManager, handle, sysopt};
use crate::utils;
use crate::utils::window_manager::WindowManager;
use crate::{
config::Config,
core::{CoreManager, handle, sysopt},
logging,
module::lightweight,
utils::logging::Type,
};
use crate::{logging, module::lightweight, utils::logging::Type};
/// Public API: open or close the dashboard
pub async fn open_or_close_dashboard() {
@@ -27,6 +24,7 @@ pub async fn quit() {
// 获取应用句柄并设置退出标志
let app_handle = handle::Handle::app_handle();
handle::Handle::global().set_is_exiting();
EventDrivenProxyManager::global().notify_app_stopping();
// 优先关闭窗口,提供立即反馈
if let Some(window) = handle::Handle::get_window() {