feat(tauri): hide main window to tray on Windows close (#1583)

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
This commit is contained in:
Matt Van Horn
2026-05-12 20:02:27 -07:00
committed by GitHub
co-authored by Matt Van Horn Steven Enamakel
parent 721cb2b64c
commit d9da5bfc09
+14
View File
@@ -2120,6 +2120,20 @@ pub fn run() {
let _ = window.hide();
}
}
#[cfg(target_os = "windows")]
RunEvent::WindowEvent {
label,
event: WindowEvent::CloseRequested { api, .. },
..
} if label == "main" => {
log::info!(
"[window] close requested on main window — hiding to tray instead of destroying"
);
api.prevent_close();
if let Some(window) = app_handle.get_webview_window("main") {
let _ = window.hide();
}
}
#[cfg(target_os = "macos")]
RunEvent::Reopen { .. } => {
log::info!("[window] reopen event — showing main window");