chore: dashboard

This commit is contained in:
lencx
2022-12-13 19:10:42 +08:00
parent 430d6e4af2
commit 8363ff234d
18 changed files with 169 additions and 141 deletions

View File

@@ -48,6 +48,10 @@ pub fn init(context: &Context<EmbeddedAssets>) -> Menu {
let preferences_menu = Submenu::new(
"Preferences",
Menu::with_items([
CustomMenuItem::new("dashboard".to_string(), "Dashboard")
.accelerator("CmdOrCtrl+D")
.into(),
MenuItem::Separator.into(),
Submenu::new(
"Theme",
Menu::new()
@@ -165,6 +169,7 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
match menu_id {
// Preferences
"dashboard" => app.get_window("main").unwrap().show().unwrap(),
"restart" => tauri::api::process::restart(&app.env()),
"inject_script" => open(&app, script_path),
"go_conf" => utils::open_file(utils::chat_root()),

View File

@@ -36,10 +36,15 @@ fn main() {
.on_window_event(|event| {
// https://github.com/tauri-apps/tauri/discussions/2684
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
// TODO: https://github.com/tauri-apps/tauri/issues/3084
// event.window().hide().unwrap();
// https://github.com/tauri-apps/tao/pull/517
event.window().minimize().unwrap();
let win = event.window();
if win.label() == "main" {
win.hide().unwrap();
} else {
// TODO: https://github.com/tauri-apps/tauri/issues/3084
// event.window().hide().unwrap();
// https://github.com/tauri-apps/tao/pull/517
event.window().minimize().unwrap();
}
api.prevent_close();
}
})