Skip to content
Snippets Groups Projects
Unverified Commit d05d8d6a authored by GyDi's avatar GyDi
Browse files

feat: native menu supports

parent b6aa50d3
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,8 @@ mod utils;
use crate::utils::{resolve, server};
use tauri::{
api, CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem,
api, CustomMenuItem, Manager, Menu, MenuItem, Submenu, SystemTray, SystemTrayEvent,
SystemTrayMenu, SystemTrayMenuItem,
};
fn main() -> std::io::Result<()> {
......@@ -19,7 +20,18 @@ fn main() -> std::io::Result<()> {
return Ok(());
}
let menu = SystemTrayMenu::new()
let submenu_file = Submenu::new(
"File",
Menu::new()
.add_native_item(MenuItem::Undo)
.add_native_item(MenuItem::Redo)
.add_native_item(MenuItem::Copy)
.add_native_item(MenuItem::Paste)
.add_native_item(MenuItem::Cut)
.add_native_item(MenuItem::SelectAll),
);
let tray_menu = SystemTrayMenu::new()
.add_item(CustomMenuItem::new("open_window", "Show"))
.add_item(CustomMenuItem::new("restart_clash", "Restart Clash"))
.add_native_item(SystemTrayMenuItem::Separator)
......@@ -30,7 +42,8 @@ fn main() -> std::io::Result<()> {
.manage(states::ClashState::default())
.manage(states::ProfilesState::default())
.setup(|app| Ok(resolve::resolve_setup(app)))
.system_tray(SystemTray::new().with_menu(menu))
.menu(Menu::new().add_submenu(submenu_file))
.system_tray(SystemTray::new().with_menu(tray_menu))
.on_system_tray_event(move |app_handle, event| match event {
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
"open_window" => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment