From 172e75d5c614f67909da7727cd4f046af33b38b9 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Fri, 27 Dec 2024 01:05:47 +0900
Subject: [PATCH] refs #1651 Hide menu when launching app
---
src-tauri/src/lib.rs | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 613d4bf1..4789d00c 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -703,7 +703,6 @@ pub fn run() -> Result<(), Box> {
])
.setup(move |app| {
let app_handle = app.handle().clone();
- let _ = app.set_menu(menu::set_menu(&app_handle)?);
let user_dir = app.path().data_dir().unwrap_or_else(|_| {
std::env::current_dir().expect("Cannot access the current directory")
@@ -767,21 +766,30 @@ pub fn run() -> Result<(), Box> {
_ => {}
});
- let window = app
- .get_webview_window("main")
- .expect("Failed to get main window");
- #[cfg(not(target_os = "macos"))]
- {
- window.hide_menu().expect("Failed to hide menu");
- }
-
#[cfg(debug_assertions)]
{
+ let window = app
+ .get_webview_window("main")
+ .expect("Failed to get main window");
window.open_devtools();
window.close_devtools();
}
Ok(())
})
+ .menu(|app_handle| {
+ let m = menu::set_menu(app_handle).expect("Failed to generate menu");
+ Ok(m)
+ })
+ .on_page_load(|window, _payload| {
+ #[cfg(not(target_os = "macos"))]
+ {
+ // TODO: Read menu config from db
+ window
+ .app_handle()
+ .hide_menu()
+ .expect("Failed to hide menu");
+ }
+ })
.run(tauri::generate_context!())
.expect("error while running tauri application");