Merge branch 'fix-migrate-tauri2-errors'

* fix-migrate-tauri2-errors: (288 commits)

# Conflicts:
#	.github/ISSUE_TEMPLATE/bug_report.yml
This commit is contained in:
huzibaca
2024-11-24 00:14:46 +08:00
123 changed files with 8721 additions and 5789 deletions

9
src/utils/helper.ts Normal file
View File

@@ -0,0 +1,9 @@
export const isValidUrl = (url: string) => {
try {
new URL(url);
return true;
} catch (e) {
console.log(e);
return false;
}
};

View File

@@ -1,27 +1,63 @@
const KEY_MAP: Record<string, string> = {
'"': "'",
":": ";",
"?": "/",
">": ".",
"<": ",",
"{": "[",
"}": "]",
"|": "\\",
"!": "1",
"@": "2",
"#": "3",
$: "4",
"%": "5",
"^": "6",
"&": "7",
"*": "8",
"(": "9",
")": "0",
"~": "`",
// 特殊字符映射
"-": "Minus",
"=": "Equal",
"[": "BracketLeft",
"]": "BracketRight",
"\\": "Backslash",
";": "Semicolon",
"'": "Quote",
",": "Comma",
".": "Period",
"/": "Slash",
// Option + 特殊字符映射
"": "Minus", // Option + -
"": "Equal", // Option + =
"\u201C": "BracketLeft", // Option + [
"\u2019": "BracketRight", // Option + ]
"«": "Backslash", // Option + \
"": "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) => {
let temp = key.toUpperCase();
console.log(temp);
if (temp.startsWith("ARROW")) {
temp = temp.slice(5);
@@ -34,6 +70,7 @@ export const parseHotkey = (key: string) => {
} else if (temp.endsWith("RIGHT")) {
temp = temp.slice(0, -5);
}
console.log(temp, mapKeyCombination(temp));
switch (temp) {
case "CONTROL":

View File

@@ -6,7 +6,7 @@ import Sockette, { type SocketteOptions } from "sockette";
export const createSockette = (
url: string,
opt: SocketteOptions,
maxError = 10
maxError = 10,
) => {
let remainRetryCount = maxError;
@@ -23,8 +23,10 @@ export const createSockette = (
remainRetryCount -= 1;
if (remainRetryCount >= 0) {
this.close();
this.reconnect();
if (this instanceof Sockette) {
this.close();
this.reconnect();
}
} else {
opt.onerror?.call(this, ev);
}