From e538fa05734fad7bd84c9f1c3cdd9b13b4c61823 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Mon, 11 May 2026 00:11:02 +0800 Subject: [PATCH] fix: comment out useless exit handling --- src-tauri/src/lib.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index bf5aa7453..922a94e65 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -396,22 +396,24 @@ pub fn run() { }); } tauri::RunEvent::Exit => AsyncHandler::block_on(async { + // TODO: Do not perform cleanup in RunEvent::Exit. + // At this point the exit can no longer be prevented, + // so async cleanup is not reliable. + // Do not breaking changes yet version. if !handle::Handle::global().is_exiting() { feat::quit().await; } }), + #[allow(unused_variables)] tauri::RunEvent::ExitRequested { api, code, .. } => { - if core::handle::Handle::global().is_exiting() { - return; - } + // TODO: Migrate the cleanup logic from RunEvent::Exit to RunEvent::ExitRequested. + // This lets us call api.prevent_exit(), run async cleanup first, + // and then call app_handle.exit(code) after cleanup has completed. + // Do not breaking changes yet version. - AsyncHandler::block_on(async { - let _ = handle::Handle::mihomo().await.clear_all_ws_connections().await; - }); - - if code.is_none() { - api.prevent_exit(); - } + // if Some(0) == code { + // api.prevent_exit(); + // } } tauri::RunEvent::WindowEvent { label, event, .. } if label == "main" => match event { tauri::WindowEvent::CloseRequested { .. } => {