fix(example) can't use tray icon to exit (#1183)

This commit is contained in:
Tony
2024-04-15 14:58:02 +08:00
committed by GitHub
parent df1516da14
commit fe05b872aa
+6 -4
View File
@@ -145,10 +145,12 @@ pub fn run() {
app.run(move |_app_handle, _event| {
#[cfg(desktop)]
if let RunEvent::ExitRequested { api, .. } = &_event {
// Keep the event loop running even if all windows are closed
// This allow us to catch system tray events when there is no window
api.prevent_exit();
if let RunEvent::ExitRequested { code, api, .. } = &_event {
if code.is_none() {
// Keep the event loop running even if all windows are closed
// This allow us to catch system tray events when there is no window
api.prevent_exit();
}
}
})
}