feat: config tray (#178)

This commit is contained in:
lencx
2023-01-09 13:15:54 +08:00
parent e68ab20420
commit 2764219867
2 changed files with 21 additions and 0 deletions

View File

@@ -68,6 +68,14 @@ pub fn init() -> Menu {
titlebar
};
let system_tray =
CustomMenuItem::new("system_tray".to_string(), "System Tray");
let system_tray_menu = if chat_conf.tray {
system_tray.selected()
} else {
system_tray
};
let preferences_menu = Submenu::new(
"Preferences",
Menu::with_items([
@@ -80,6 +88,7 @@ pub fn init() -> Menu {
titlebar_menu.into(),
#[cfg(target_os = "macos")]
CustomMenuItem::new("hide_dock_icon".to_string(), "Hide Dock Icon").into(),
system_tray_menu.into(),
CustomMenuItem::new("inject_script".to_string(), "Inject Script")
.accelerator("CmdOrCtrl+J")
.into(),
@@ -280,6 +289,15 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
.unwrap();
tauri::api::process::restart(&app.env());
}
"system_tray" => {
let chat_conf = conf::ChatConfJson::get_chat_conf();
ChatConfJson::amend(
&serde_json::json!({ "tray": !chat_conf.tray }),
None,
)
.unwrap();
tauri::api::process::restart(&app.env());
}
"theme_light" | "theme_dark" | "theme_system" => {
let theme = match menu_id {
"theme_dark" => "Dark",