feat: add menu item

This commit is contained in:
lencx
2022-12-11 21:17:44 +08:00
parent 050b7010fc
commit 3eac43541e
9 changed files with 66 additions and 43 deletions

View File

@@ -1,4 +1,5 @@
use crate::{
app::window,
conf::{self, ChatConfJson},
utils,
};
@@ -69,6 +70,9 @@ pub fn init(chat_conf: &conf::ChatConfJson, context: &Context<EmbeddedAssets>) -
always_on_top_menu.into(),
#[cfg(target_os = "macos")]
titlebar_menu.into(),
CustomMenuItem::new("switch_origin".to_string(), "Switch Origin")
.accelerator("CmdOrCtrl+O")
.into(),
CustomMenuItem::new("inject_script".to_string(), "Inject Script")
.accelerator("CmdOrCtrl+J")
.into(),
@@ -152,6 +156,10 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
// Preferences
"inject_script" => open(&app, script_path),
"awesome" => open(&app, conf::AWESOME_URL.to_string()),
"switch_origin" => {
window::origin_window(&app);
// app.get_window("origin").unwrap().show();
}
"titlebar" => {
let chat_conf = conf::ChatConfJson::get_chat_conf();
ChatConfJson::amend(&serde_json::json!({ "titlebar": !chat_conf.titlebar })).unwrap();