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>,
)
.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(
app,
"tray_quit",
@@ -625,6 +633,7 @@ pub fn run() {
&compose_item,
&profile_item,
&search_item,
&settings_item,
&separator,
&quit_item,
],
@@ -653,6 +662,9 @@ pub fn run() {
"tray_search" => {
let _ = tauri::Emitter::emit(app, "app://navigate", "search");
}
"tray_settings" => {
let _ = tauri::Emitter::emit(app, "app://navigate", "settings");
}
"tray_quit" => {
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
/// cases). Returns an unsubscribe function.
export async function listenTrayEvents(
handler: (event: "show" | "home" | "compose" | "profile" | "search") => void,
handler: (event: "show" | "home" | "compose" | "profile" | "search" | "settings") => void,
): Promise<() => void> {
const { listen } = await import("@tauri-apps/api/event");
const unlisteners: Array<() => void> = [];
const u1 = await listen("app://show", () => handler("show"));
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"));
unlisteners.push(u1, u2, u3);