build: Update Cargo Depends

This commit is contained in:
WhizPanda
2023-12-01 15:52:49 +08:00
parent 5a6d318cfb
commit 8a77f832a3
7 changed files with 287 additions and 195 deletions

View File

@@ -4,7 +4,6 @@ use once_cell::sync::OnceCell;
use parking_lot::Mutex;
use std::{collections::HashMap, sync::Arc};
use tauri::{AppHandle, GlobalShortcutManager};
use wry::application::accelerator::Accelerator;
pub struct Hotkey {
current: Arc<Mutex<Vec<String>>>, // 保存当前的热键设置
@@ -35,7 +34,7 @@ impl Hotkey {
match (key, func) {
(Some(key), Some(func)) => {
log_err!(Self::check_key(key).and_then(|_| self.register(key, func)));
log_err!(self.register(key, func));
}
_ => {
let key = key.unwrap_or("None");
@@ -50,16 +49,6 @@ impl Hotkey {
Ok(())
}
/// 检查一个键是否合法
fn check_key(hotkey: &str) -> Result<()> {
// fix #287
// tauri的这几个方法全部有Result expect会panic先检测一遍避免挂了
if hotkey.parse::<Accelerator>().is_err() {
bail!("invalid hotkey `{hotkey}`");
}
Ok(())
}
fn get_manager(&self) -> Result<impl GlobalShortcutManager> {
let app_handle = self.app_handle.lock();
if app_handle.is_none() {
@@ -109,11 +98,6 @@ impl Hotkey {
let (del, add) = Self::get_diff(old_map, new_map);
// 先检查一遍所有新的热键是不是可以用的
for (hotkey, _) in add.iter() {
Self::check_key(hotkey)?;
}
del.iter().for_each(|key| {
let _ = self.unregister(key);
});

View File

@@ -204,11 +204,11 @@ impl Tray {
"open_window" => resolve::create_window(app_handle),
"system_proxy" => feat::toggle_system_proxy(),
"tun_mode" => feat::toggle_tun_mode(),
"copy_env_sh" => feat::copy_clash_env("sh"),
"copy_env_sh" => feat::copy_clash_env(app_handle, "sh"),
#[cfg(target_os = "windows")]
"copy_env_cmd" => feat::copy_clash_env("cmd"),
"copy_env_cmd" => feat::copy_clash_env(app_handle, "cmd"),
#[cfg(target_os = "windows")]
"copy_env_ps" => feat::copy_clash_env("ps"),
"copy_env_ps" => feat::copy_clash_env(app_handle, "ps"),
"open_app_dir" => crate::log_err!(cmds::open_app_dir()),
"open_core_dir" => crate::log_err!(cmds::open_core_dir()),
"open_logs_dir" => crate::log_err!(cmds::open_logs_dir()),