mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: parse hotkey (#5167)
* fix: incorrectly parse hotkey * refactor: parse hotkey * fix: panic on linux * chore: update * chore: update style * fix: register hotkey error on windows * chore: update style --------- Co-authored-by: Tunglies <tunglies.dev@outlook.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use crate::process::AsyncHandler;
|
||||
use crate::utils::notification::{NotificationEvent, notify_event};
|
||||
use crate::{
|
||||
config::Config, core::handle, feat, logging, logging_error,
|
||||
module::lightweight::entry_lightweight_mode, singleton_with_logging, utils::logging::Type,
|
||||
config::Config, core::handle, feat, logging, module::lightweight::entry_lightweight_mode,
|
||||
singleton_with_logging, utils::logging::Type,
|
||||
};
|
||||
use anyhow::{Result, bail};
|
||||
use parking_lot::Mutex;
|
||||
@@ -224,7 +224,7 @@ impl Hotkey {
|
||||
|
||||
let is_quit = matches!(function, HotkeyFunction::Quit);
|
||||
|
||||
let _ = manager.on_shortcut(hotkey, move |app_handle, hotkey_event, event| {
|
||||
manager.on_shortcut(hotkey, move |app_handle, hotkey_event, event| {
|
||||
let hotkey_event_owned = *hotkey_event;
|
||||
let event_owned = event;
|
||||
let function_owned = function;
|
||||
@@ -271,7 +271,7 @@ impl Hotkey {
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})?;
|
||||
|
||||
logging!(
|
||||
debug,
|
||||
@@ -402,7 +402,7 @@ impl Hotkey {
|
||||
});
|
||||
|
||||
for (key, func) in add.iter() {
|
||||
logging_error!(Type::Hotkey, self.register(key, func).await);
|
||||
self.register(key, func).await?;
|
||||
}
|
||||
|
||||
// Update the current hotkeys after all async operations
|
||||
|
||||
@@ -676,7 +676,14 @@ async fn create_tray_menu(
|
||||
.filter_map(|item| {
|
||||
let mut parts = item.split(',');
|
||||
match (parts.next(), parts.next()) {
|
||||
(Some(func), Some(key)) => Some((func.into(), key.into())),
|
||||
(Some(func), Some(key)) => {
|
||||
// 托盘菜单中的 `accelerator` 属性,在 Linux/Windows 中都不支持小键盘按键的解析
|
||||
if key.to_uppercase().contains("NUMPAD") {
|
||||
None
|
||||
} else {
|
||||
Some((func.into(), key.into()))
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user