mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-28 00:42:08 +08:00
refactor: run exit cleanup on exit request
This commit is contained in:
+12
-22
@@ -387,31 +387,21 @@ pub fn run() {
|
||||
event_handlers::handle_reopen(has_visible_windows).await;
|
||||
});
|
||||
}
|
||||
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;
|
||||
}
|
||||
}),
|
||||
tauri::RunEvent::Exit => {
|
||||
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() =>
|
||||
{
|
||||
{
|
||||
tauri::RunEvent::ExitRequested { api, code, .. } => {
|
||||
if module::lightweight::is_in_lightweight_mode() && !handle::Handle::global().is_exiting() {
|
||||
api.prevent_exit();
|
||||
} else if code.is_none() {
|
||||
api.prevent_exit();
|
||||
if !handle::Handle::global().is_exiting() {
|
||||
AsyncHandler::spawn(|| async {
|
||||
feat::quit().await;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
// if Some(0) == code {
|
||||
// api.prevent_exit();
|
||||
// }
|
||||
}
|
||||
tauri::RunEvent::WindowEvent { label, event, .. } if label == "main" => match event {
|
||||
tauri::WindowEvent::CloseRequested { .. } => {
|
||||
|
||||
Reference in New Issue
Block a user