change tray menu text when toggling visibility

This commit is contained in:
2024-01-26 21:03:45 -08:00
parent 70e23c7e20
commit 69f6a39396
4 changed files with 48 additions and 15 deletions

View File

@ -1,15 +1,16 @@
use tauri::{
AppHandle,
Manager,
SystemTray,
SystemTrayEvent,
SystemTrayMenu,
CustomMenuItem,
};
use crate::app;
pub fn create() -> SystemTray {
let show = CustomMenuItem::new("show".to_string(), "Show");
let show = CustomMenuItem::new("show_hide".to_string(), "Show");
let quit = CustomMenuItem::new("exit".to_string(), "Exit");
let menu = SystemTrayMenu::new()
@ -25,8 +26,8 @@ pub fn handle_event(app: &AppHandle, event: SystemTrayEvent) {
SystemTrayEvent::MenuItemClick{ id, .. } => {
match id.as_str() {
"exit" => app.exit(0),
"show" => {
let _ = app.get_window("main").map(|w| w.show());
"show_hide" => {
let _ = app::toggle_main_window(app);
}
_ => (),
}