From 409fc0cd1a307822bbca96995994856c89d99b4c Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 28 Mar 2024 19:15:11 +0100 Subject: [PATCH] feat: implement quit event Signed-off-by: Sefa Eyeoglu --- src-tauri/src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 4a2f602..5b43a3a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -6,6 +6,8 @@ mod menu; mod tray; +use tauri::Manager; + fn main() { let builder = tauri::Builder::default(); @@ -14,7 +16,14 @@ fn main() { let builder = builder .system_tray(tray::system_tray()) - .on_system_tray_event(tray::system_tray_handler); + .on_system_tray_event(tray::system_tray_handler) + .setup(|app| { + let handle = app.handle(); + app.listen_global("quit", move |_| { + handle.exit(0); + }); + Ok(()) + }); builder .build(tauri::generate_context!())