fix: restore hotkey functionality after silent startup

This commit is contained in:
wonfen 2025-02-02 11:37:10 +08:00
parent 0b75b5ef26
commit 8749648d97

View File

@ -65,9 +65,11 @@ impl Hotkey {
_ => bail!("invalid function \"{func}\""), _ => bail!("invalid function \"{func}\""),
}; };
let is_quit = func.trim() == "quit";
let _ = manager.on_shortcut(hotkey, move |app_handle, hotkey, event| { let _ = manager.on_shortcut(hotkey, move |app_handle, hotkey, event| {
if event.state == ShortcutState::Pressed { if event.state == ShortcutState::Pressed {
if hotkey.key == Code::KeyQ { if hotkey.key == Code::KeyQ && is_quit {
if let Some(window) = app_handle.get_webview_window("main") { if let Some(window) = app_handle.get_webview_window("main") {
if window.is_focused().unwrap_or(false) { if window.is_focused().unwrap_or(false) {
f(); f();