feat: Support Open/Close Dashboard Hotkey

#439
This commit is contained in:
MystiPanda
2024-02-24 13:39:30 +08:00
parent 8e4d7e989b
commit 2835e79973
6 changed files with 13 additions and 7 deletions

View File

@@ -10,13 +10,19 @@ use crate::log_err;
use crate::utils::resolve;
use anyhow::{bail, Result};
use serde_yaml::{Mapping, Value};
use tauri::{AppHandle, ClipboardManager};
use tauri::{AppHandle, ClipboardManager, Manager};
// 打开面板
pub fn open_dashboard() {
pub fn open_or_close_dashboard() {
let handle = handle::Handle::global();
let app_handle = handle.app_handle.lock();
if let Some(app_handle) = app_handle.as_ref() {
if let Some(window) = app_handle.get_window("main") {
if let Ok(true) = window.is_focused() {
let _ = window.close();
return;
}
}
resolve::create_window(app_handle);
}
}