فهرست منبع

fix(core): `menu_ids` not updated with global menu

Lucas Nogueira 3 سال پیش
والد
کامیت
e3122ab51f
2فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 8 0
      core/tauri-runtime/src/window.rs
  2. 1 1
      core/tauri/src/manager.rs

+ 8 - 0
core/tauri-runtime/src/window.rs

@@ -146,6 +146,14 @@ impl<R: Runtime> PendingWindow<R> {
     }
   }
 
+  pub fn set_menu(mut self, menu: Menu) -> Self {
+    let mut menu_ids = HashMap::new();
+    get_menu_ids(&mut menu_ids, &menu);
+    self.menu_ids = menu_ids;
+    self.window_builder = self.window_builder.menu(menu);
+    self
+  }
+
   pub fn register_uri_scheme_protocol<
     N: Into<String>,
     H: Fn(&HttpRequest) -> Result<HttpResponse, Box<dyn std::error::Error>> + Send + Sync + 'static,

+ 1 - 1
core/tauri/src/manager.rs

@@ -248,7 +248,7 @@ impl<R: Runtime> WindowManager<R> {
 
     if pending.window_builder.get_menu().is_none() {
       if let Some(menu) = &self.inner.menu {
-        pending.window_builder = pending.window_builder.menu(menu.clone());
+        pending = pending.set_menu(menu.clone());
       }
     }