chore: unified hotkey registration

This commit is contained in:
huzibaca 2024-09-25 15:45:12 +08:00
parent b8cb48aead
commit fc5c959a55
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302
2 changed files with 3 additions and 7 deletions

View File

@ -158,6 +158,7 @@ pub fn run() {
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
{ {
log_err!(hotkey::Hotkey::global().register("Control+Q", "quit")); log_err!(hotkey::Hotkey::global().register("Control+Q", "quit"));
log_err!(hotkey::Hotkey::global().register("Escape", "quit"));
}; };
} }
tauri::WindowEvent::Focused(false) => { tauri::WindowEvent::Focused(false) => {
@ -169,6 +170,7 @@ pub fn run() {
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
{ {
log_err!(hotkey::Hotkey::global().unregister("Control+Q")); log_err!(hotkey::Hotkey::global().unregister("Control+Q"));
log_err!(hotkey::Hotkey::global().unregister("Escape"));
}; };
} }
_ => {} _ => {}

View File

@ -27,6 +27,7 @@ import "dayjs/locale/zh-cn";
import { getPortableFlag } from "@/services/cmds"; import { getPortableFlag } from "@/services/cmds";
import React from "react"; import React from "react";
import { TransitionGroup, CSSTransition } from "react-transition-group"; import { TransitionGroup, CSSTransition } from "react-transition-group";
const appWindow = getCurrentWebviewWindow(); const appWindow = getCurrentWebviewWindow();
export let portableFlag = false; export let portableFlag = false;
@ -48,13 +49,6 @@ const Layout = () => {
if (!routersEles) return null; if (!routersEles) return null;
useEffect(() => { useEffect(() => {
window.addEventListener("keydown", (e) => {
// macOS有cmd+w
if (e.key === "Escape" && OS !== "macos") {
appWindow.close();
}
});
listen("verge://refresh-clash-config", async () => { listen("verge://refresh-clash-config", async () => {
// the clash info may be updated // the clash info may be updated
await getAxios(true); await getAxios(true);