✨ 窗口默认关闭为隐藏
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user