mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:53:44 +08:00
fix: fixes #1940
This commit is contained in:
parent
3f79e42628
commit
1e3c995e6a
@ -49,6 +49,7 @@ impl Hotkey {
|
|||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
let manager = app_handle.global_shortcut();
|
let manager = app_handle.global_shortcut();
|
||||||
|
|
||||||
|
dbg!(&hotkey);
|
||||||
if manager.is_registered(hotkey) {
|
if manager.is_registered(hotkey) {
|
||||||
manager.unregister(hotkey)?;
|
manager.unregister(hotkey)?;
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,63 @@
|
|||||||
const KEY_MAP: Record<string, string> = {
|
const KEY_MAP: Record<string, string> = {
|
||||||
'"': "'",
|
// 特殊字符映射
|
||||||
":": ";",
|
"-": "Minus",
|
||||||
"?": "/",
|
"=": "Equal",
|
||||||
">": ".",
|
"[": "BracketLeft",
|
||||||
"<": ",",
|
"]": "BracketRight",
|
||||||
"{": "[",
|
"\\": "Backslash",
|
||||||
"}": "]",
|
";": "Semicolon",
|
||||||
"|": "\\",
|
"'": "Quote",
|
||||||
"!": "1",
|
",": "Comma",
|
||||||
"@": "2",
|
".": "Period",
|
||||||
"#": "3",
|
"/": "Slash",
|
||||||
$: "4",
|
// Option + 特殊字符映射
|
||||||
"%": "5",
|
"–": "Minus", // Option + -
|
||||||
"^": "6",
|
"≠": "Equal", // Option + =
|
||||||
"&": "7",
|
"\u201C": "BracketLeft", // Option + [
|
||||||
"*": "8",
|
"\u2019": "BracketRight", // Option + ]
|
||||||
"(": "9",
|
"«": "Backslash", // Option + \
|
||||||
")": "0",
|
"…": "Semicolon", // Option + ;
|
||||||
"~": "`",
|
æ: "Quote", // Option + '
|
||||||
|
"≤": "Comma", // Option + ,
|
||||||
|
"≥": "Period", // Option + .
|
||||||
|
"÷": "Slash", // Option + /
|
||||||
|
|
||||||
|
// 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 = (key: string) => {
|
export const parseHotkey = (key: string) => {
|
||||||
let temp = key.toUpperCase();
|
let temp = key.toUpperCase();
|
||||||
|
console.log(temp);
|
||||||
|
|
||||||
if (temp.startsWith("ARROW")) {
|
if (temp.startsWith("ARROW")) {
|
||||||
temp = temp.slice(5);
|
temp = temp.slice(5);
|
||||||
@ -34,6 +70,7 @@ export const parseHotkey = (key: string) => {
|
|||||||
} else if (temp.endsWith("RIGHT")) {
|
} else if (temp.endsWith("RIGHT")) {
|
||||||
temp = temp.slice(0, -5);
|
temp = temp.slice(0, -5);
|
||||||
}
|
}
|
||||||
|
console.log(temp, mapKeyCombination(temp));
|
||||||
|
|
||||||
switch (temp) {
|
switch (temp) {
|
||||||
case "CONTROL":
|
case "CONTROL":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user