fix: run exit cleanup before app shutdown

Close #7158
This commit is contained in:
Tunglies 2026-05-30 16:01:25 +08:00
parent 232be33754
commit 9c639bfcc5
No known key found for this signature in database
GPG Key ID: 318B5641280BC31B

View File

@ -395,9 +395,14 @@ pub fn run() {
event_handlers::handle_reopen(has_visible_windows).await;
});
}
tauri::RunEvent::Exit => {
tauri::RunEvent::Exit => AsyncHandler::block_on(async {
// Windows session ending currently reaches Tao as WM_ENDSESSION and
// destroys the loop without a preventable ExitRequested event.
if !handle::Handle::global().is_exiting() {
feat::quit().await;
}
logging!(info, Type::System, "Application exited");
}
}),
#[allow(unused_variables)]
tauri::RunEvent::ExitRequested { api, code, .. } => {
if module::lightweight::is_in_lightweight_mode() && !handle::Handle::global().is_exiting() {
@ -405,7 +410,7 @@ pub fn run() {
} else if code.is_none() {
api.prevent_exit();
if !handle::Handle::global().is_exiting() {
AsyncHandler::spawn(|| async {
AsyncHandler::block_on(async {
feat::quit().await;
});
}