Created
June 15, 2021 11:16
-
-
Save AlexMikhalev/8758f3df25f24e8ea3a74614c200d9a5 to your computer and use it in GitHub Desktop.
Taury Apps tray icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let show = CustomMenuItem::new("show".to_string(), "Show"); | |
let hide = CustomMenuItem::new("hide".to_string(), "Hide"); | |
let quit = CustomMenuItem::new("quit".to_string(), "Quit"); | |
let tray_menu_items = vec![ | |
SystemTrayMenuItem::Custom(show), | |
SystemTrayMenuItem::Custom(hide), | |
SystemTrayMenuItem::Separator, | |
SystemTrayMenuItem::Custom(quit), | |
]; | |
tauri::Builder::default() | |
.system_tray(tray_menu_items) | |
.on_system_tray_event(|app, event| match event.menu_item_id().as_str() { | |
"quit" => { | |
std::process::exit(0); | |
} | |
"show" => { | |
let window = app.get_window("main").unwrap(); | |
window.show().unwrap(); | |
window.unminimize().unwrap(); | |
} | |
"hide" => { | |
let window = app.get_window("main").unwrap(); | |
window.minimize().unwrap(); | |
window.hide().unwrap(); | |
} | |
_ => {} | |
}) | |
.invoke_handler(tauri::generate_handler![file_created_at, shellcode, close_app, hard_reset]) | |
.run(tauri::generate_context!()) | |
.expect("error while running tauri application"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment