Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

fix: stop duplicate new window when tray and multi-window are combined

Tw931a6cfa46b34a
diff --git a/src-tauri/src/app/setup.rs b/src-tauri/src/app/setup.rs
index 8fc4aaaa..9ca25157 100644
--- a/src-tauri/src/app/setup.rs
+++ b/src-tauri/src/app/setup.rs
@@ -22,7 +22,10 @@ pub fn set_system_tray(
return Ok(());
}
- let new_window = MenuItemBuilder::with_id("new_window", "New Window").build(app)?;
+ // Menu events are broadcast to every handler in Tauri v2, so the tray item
+ // must not share the "new_window" id with the app menu accelerator
+ // (Cmd/Ctrl+N), or one click opens two windows.
+ let new_window = MenuItemBuilder::with_id("tray_new_window", "New Window").build(app)?;
let hide_app = MenuItemBuilder::with_id("hide_app", "Hide").build(app)?;
let show_app = MenuItemBuilder::with_id("show_app", "Show").build(app)?;
let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
@@ -42,7 +45,7 @@ pub fn set_system_tray(
let mut tray_builder = TrayIconBuilder::new()
.menu(&menu)
.on_menu_event(move |app, event| match event.id().as_ref() {
- "new_window" => {
+ "tray_new_window" => {
open_additional_window_safe(app);
}
"hide_app" => {