mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
build: Update Cargo Depends
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user