refactor(signal): migrate signal to handling async in windows and remove windows_sys dependency (#5741)

* refactor(signal): migrate signal to handling async in windows and remove signal-hook dependency

* refactor(signal): enhance Windows signal handling with improved cleanup logic

* refactor(signal): improve exit handling in run function for async compatibility
This commit is contained in:
Tunglies
2025-12-06 11:33:49 +08:00
committed by GitHub
parent 5797bb7f8c
commit 90b1c6e153
8 changed files with 120 additions and 178 deletions

View File

@@ -405,21 +405,20 @@ pub fn run() {
event_handlers::handle_reopen(has_visible_windows).await;
});
}
#[cfg(target_os = "macos")]
tauri::RunEvent::Exit => AsyncHandler::block_on(async {
if !handle::Handle::global().is_exiting() {
feat::quit().await;
}
}),
tauri::RunEvent::ExitRequested { api, code, .. } => {
AsyncHandler::block_on(async {
let _ = handle::Handle::mihomo().await.clear_all_ws_connections().await;
});
if core::handle::Handle::global().is_exiting() {
return;
}
AsyncHandler::block_on(async {
let _ = handle::Handle::mihomo().await.clear_all_ws_connections().await;
});
if code.is_none() {
api.prevent_exit();
}

View File

@@ -143,11 +143,7 @@ pub(super) async fn init_auto_backup() {
pub fn init_signal() {
logging!(info, Type::Setup, "Initializing signal handlers...");
clash_verge_signal::register(
#[cfg(windows)]
handle::Handle::app_handle(),
feat::quit,
);
clash_verge_signal::register(feat::quit);
}
pub async fn init_work_config() {