窗口默认关闭为隐藏

This commit is contained in:
Tw93
2023-04-06 00:14:58 +08:00
parent 7780c30f45
commit 3b8bd14fb6
2 changed files with 7 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ pub fn get_menu() -> Menu {
let show = CustomMenuItem::new("show", "Show");
let close = CustomMenuItem::new("close", "Close");
let quit = CustomMenuItem::new("quit", "Quit");
#[cfg(target_os = "macos")]
let first_menu = Menu::new()
.add_native_item(MenuItem::EnterFullScreen)

View File

@@ -53,6 +53,12 @@ pub fn run_app() {
}
Ok(())
})
.on_window_event(|event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
event.window().minimize().unwrap();
api.prevent_close();
}
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}