feat: minimize to system tray on window close instead of quitting
When user clicks the X button, the app now hides to the system tray instead of exiting. Users can restore the window by clicking the tray icon or selecting "显示 Heicode" from the tray menu. To fully quit, use "退出 Heicode" from the tray menu. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1083,17 +1083,19 @@ pub fn run() {
|
||||
.expect("error while building tauri application");
|
||||
|
||||
app.run(|app_handle, event| match event {
|
||||
// Close (×) on the main window now means "really quit" rather than
|
||||
// "minimize to tray". Mark the app as quitting so any cleanup paths
|
||||
// that check is_quitting do the right thing; the tray icon stays
|
||||
// available for users who explicitly choose 「显示 Heicode」/「退出 Heicode」
|
||||
// from the tray menu.
|
||||
RunEvent::WindowEvent {
|
||||
label,
|
||||
event: WindowEvent::CloseRequested { .. },
|
||||
event: WindowEvent::CloseRequested { api, .. },
|
||||
..
|
||||
} if label == MAIN_WINDOW_LABEL => {
|
||||
mark_app_quitting(app_handle);
|
||||
if should_hide_to_tray(app_handle, &label) {
|
||||
api.prevent_close();
|
||||
if let Some(window) = app_handle.get_webview_window(MAIN_WINDOW_LABEL) {
|
||||
let _ = window.hide();
|
||||
}
|
||||
} else {
|
||||
mark_app_quitting(app_handle);
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
RunEvent::Reopen {
|
||||
|
||||
Reference in New Issue
Block a user