🐛 Optimize the multi-platform experience of hide on close

This commit is contained in:
Tw93
2025-08-31 15:02:25 +08:00
parent a7f1fa1b40
commit 85943b8134
9 changed files with 54 additions and 20 deletions

View File

@@ -13,7 +13,8 @@
"activation_shortcut": "",
"disabled_web_shortcuts": false,
"hide_on_close": true,
"incognito": false
"incognito": false,
"enable_wasm": false
}
],
"user_agent": {

View File

@@ -64,6 +64,7 @@ pub fn run_app() {
.on_window_event(move |_window, _event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = _event {
if hide_on_close {
// Hide window when hide_on_close is enabled (regardless of tray status)
let window = _window.clone();
tauri::async_runtime::spawn(async move {
#[cfg(target_os = "macos")]
@@ -77,8 +78,10 @@ pub fn run_app() {
window.hide().unwrap();
});
api.prevent_close();
} else {
// Exit app completely when hide_on_close is false
std::process::exit(0);
}
// If hide_on_close is false, allow normal close behavior
}
})
.run(tauri::generate_context!())