fix: always occupies hotkey globally when app launch silently (#5866)

* fix: always occupies hotkey when app launch silently

* docs: update Changelog.md

* chore: update
This commit is contained in:
oomeow
2025-12-18 22:21:15 +08:00
committed by GitHub
parent 9713343323
commit a1286ad057
6 changed files with 28 additions and 52 deletions
+9 -48
View File
@@ -1,53 +1,9 @@
import { KeyboardEvent } from "react";
import { debugLog } from "@/utils/debug";
import getSystem from "./get-system";
const KEY_MAP: Record<string, string> = {
// Option + 特殊字符映射
"–": "Minus", // Option + -
"≠": "Equal", // Option + =
"\u201C": "BracketLeft", // Option + [
"\u2019": "BracketRight", // Option + ]
"«": "Backslash", // Option + \
"…": "Semicolon", // Option + ;
æ: "Quote", // Option + '
"≤": "Comma", // Option + ,
"≥": "Period", // Option + .
"÷": "Slash", // Option + /
const OS = getSystem();
// Option组合键映射
Å: "A",
"∫": "B",
Ç: "C",
"∂": "D",
"´": "E",
ƒ: "F",
"©": "G",
"˙": "H",
ˆ: "I",
"∆": "J",
"˚": "K",
"¬": "L",
µ: "M",
"˜": "N",
Ø: "O",
π: "P",
Œ: "Q",
"®": "R",
ß: "S",
"†": "T",
"¨": "U",
"√": "V",
"∑": "W",
"≈": "X",
"¥": "Y",
Ω: "Z",
};
const mapKeyCombination = (key: string): string => {
const mappedKey = KEY_MAP[key] || key;
return `${mappedKey}`;
};
export const parseHotkey = (keyEvent: KeyboardEvent) => {
const nativeEvent = keyEvent.nativeEvent;
const key = nativeEvent.code;
@@ -64,16 +20,21 @@ export const parseHotkey = (keyEvent: KeyboardEvent) => {
} else if (temp.endsWith("RIGHT")) {
temp = temp.slice(0, -5);
}
debugLog(temp, mapKeyCombination(temp));
switch (temp) {
case "CONTROL":
return "CTRL";
case "ALT":
if (OS === "macos") {
return "OPTION";
} else {
return "ALT";
}
case "META":
return "CMD";
case " ":
return "SPACE";
default:
return KEY_MAP[temp] || temp;
return temp;
}
};