tauri-app: tray settings menu item

Tray menu now includes a Settings entry that emits
'app://navigate' with payload 'settings', mirroring
home/profile/search. client.ts listenTrayEvents type
extended to include 'settings'.
This commit is contained in:
tomdebone
2026-07-07 18:57:45 +02:00
parent 43fc889d47
commit 6a82c906de
2 changed files with 14 additions and 2 deletions
+12
View File
@@ -606,6 +606,14 @@ pub fn run() {
None::<&str>, None::<&str>,
) )
.map_err(|e| format!("failed to build search menu item: {e}"))?; .map_err(|e| format!("failed to build search menu item: {e}"))?;
let settings_item = tauri::menu::MenuItem::with_id(
app,
"tray_settings",
"Settings",
true,
None::<&str>,
)
.map_err(|e| format!("failed to build settings menu item: {e}"))?;
let quit_item = tauri::menu::MenuItem::with_id( let quit_item = tauri::menu::MenuItem::with_id(
app, app,
"tray_quit", "tray_quit",
@@ -625,6 +633,7 @@ pub fn run() {
&compose_item, &compose_item,
&profile_item, &profile_item,
&search_item, &search_item,
&settings_item,
&separator, &separator,
&quit_item, &quit_item,
], ],
@@ -653,6 +662,9 @@ pub fn run() {
"tray_search" => { "tray_search" => {
let _ = tauri::Emitter::emit(app, "app://navigate", "search"); let _ = tauri::Emitter::emit(app, "app://navigate", "search");
} }
"tray_settings" => {
let _ = tauri::Emitter::emit(app, "app://navigate", "settings");
}
"tray_quit" => { "tray_quit" => {
app.exit(0); app.exit(0);
} }
+2 -2
View File
@@ -355,13 +355,13 @@ export async function showNotification(
/// The handler receives the event payload (empty object for these /// The handler receives the event payload (empty object for these
/// cases). Returns an unsubscribe function. /// cases). Returns an unsubscribe function.
export async function listenTrayEvents( export async function listenTrayEvents(
handler: (event: "show" | "home" | "compose" | "profile" | "search") => void, handler: (event: "show" | "home" | "compose" | "profile" | "search" | "settings") => void,
): Promise<() => void> { ): Promise<() => void> {
const { listen } = await import("@tauri-apps/api/event"); const { listen } = await import("@tauri-apps/api/event");
const unlisteners: Array<() => void> = []; const unlisteners: Array<() => void> = [];
const u1 = await listen("app://show", () => handler("show")); const u1 = await listen("app://show", () => handler("show"));
const u2 = await listen("app://navigate", (e) => { const u2 = await listen("app://navigate", (e) => {
handler(e.payload as "home" | "profile" | "search"); handler(e.payload as "home" | "profile" | "search" | "settings");
}); });
const u3 = await listen("app://compose", () => handler("compose")); const u3 = await listen("app://compose", () => handler("compose"));
unlisteners.push(u1, u2, u3); unlisteners.push(u1, u2, u3);