diff --git a/src-tauri/src/cmds.rs b/src-tauri/src/cmds.rs index 7953219..34c4533 100644 --- a/src-tauri/src/cmds.rs +++ b/src-tauri/src/cmds.rs @@ -195,5 +195,4 @@ pub fn restart(app_handle: tauri::AppHandle) { #[tauri::command] pub fn exit_app(app_handle: tauri::AppHandle) { app_handle.exit(0); - std::process::exit(0); } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 9c92f7d..5bae5a8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -98,23 +98,20 @@ fn main() -> tauri::Result<()> { let app = builder.build(tauri::generate_context!())?; app.run(|app_handle, err| match err { - tauri::RunEvent::ExitRequested { api, .. } => { - let closer = Config::settings() - .data() - .get_closer() - .unwrap_or("minimize".to_string()); - - if closer == "minimize" { - api.prevent_exit(); - return; - } - + tauri::RunEvent::ExitRequested { .. } => { let _ = app_handle.save_window_state(StateFlags::default()); } tauri::RunEvent::WindowEvent { label, event, .. } => { if label == "main" { match event { tauri::WindowEvent::CloseRequested { api, .. } => { + let closer = Config::settings() + .data() + .get_closer() + .unwrap_or("minimize".to_string()); + if closer == "close" { + return; + } // CloseRequested Event api.prevent_close(); if let Some(window) = core::handle::Handle::global().get_window() {