Open jyc5131 opened 8 months ago
The weird thing is when we set the help menu by helpMenu, it breaks the help menu.
A possible fix is to remove the logic that adds a default help menu from Tauri. I'm not sure if this will break the behavior on older macOS.
Adding a menu named "Help" without setting it helpMenu will also add the spotlight box into it
Exactly the same issue here. I think this patch should work.
And you also need to setup the shell plugin
in order to open a link with the default browser. Documentation is here.
diff --git a/apps/readest-app/src-tauri/src/lib.rs b/apps/readest-app/src-tauri/src/lib.rs
index bbd599b..f0a64eb 100644
--- a/apps/readest-app/src-tauri/src/lib.rs
+++ b/apps/readest-app/src-tauri/src/lib.rs
@@ -13,9 +13,13 @@ mod tauri_traffic_light_positioner_plugin;
use tauri::TitleBarStyle;
use tauri::{WebviewUrl, WebviewWindowBuilder};
+use tauri::menu::{SubmenuBuilder, HELP_SUBMENU_ID};
+use tauri_plugin_shell::ShellExt;
+
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let builder = tauri::Builder::default()
+ .plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_dialog::init())
@@ -49,6 +53,29 @@ pub fn run() {
let _ = win_builder.build().unwrap();
+ let global_menu = app.menu().unwrap();
+ if let Some(item) = global_menu.get(HELP_SUBMENU_ID) {
+ let _ = global_menu.remove(&item);
+ }
+ let _ = global_menu.append(
+ &SubmenuBuilder::new(app, "Help")
+ .text("privacy_policy", "Privacy Policy")
+ .separator()
+ .text("report_issue", "Report An Issue...")
+ .text("readest_help", "Readest Help")
+ .build()?,
+ );
+
+ app.on_menu_event(move |app, event| {
+ if event.id() == "privacy_policy" {
+ let _ = app.shell().open("https://readest.com/privacy-policy", None);
+ } else if event.id() == "report_issue" {
+ let _ = app.shell().open("mailto:support@bilingify.com", None);
+ } else if event.id() == "readest_help" {
+ let _ = app.shell().open("https://readest.com/support", None);
+ }
+ });
+
Ok(())
})
.run(tauri::generate_context!())
Describe the bug
The default help menu have empty submenu in macos desktop, it will fail to pass apple review.
also I try to call set_as_help_menu_for_nsapp, it doesn't work.
if let Some(help_menu) = menu.get(tauri::menu::HELP_SUBMENU_ID) { _ = help_menu.as_submenu().unwrap().set_as_help_menu_for_nsapp(); }
and I try to remove the help menu, crashedlet menu = app.menu().unwrap(); menu.remove(&menu.get(tauri::menu::HELP_SUBMENU_ID).unwrap());
Reproduction
Expected behavior
the default help menu should have a search box under the Help menu.
Full
tauri info
outputStack trace
No response
Additional context
No response