refactor: Remove clash field filter

This commit is contained in:
MystiPanda committed 2024-02-05 17:28:36 +08:00
1 parent 1d123996f6
commit 54f9c59d6e
14 files changed
+182 -352

No files matched your search

+26 -1
View File
@@ -48,11 +48,16 @@ export const useClashInfo = () => {
const patchInfo = async (
patch: Partial<
Pick<IConfigData, "mixed-port" | "external-controller" | "secret">
Pick<
IConfigData,
"port" | "socks-port" | "mixed-port" | "external-controller" | "secret"
>
>
) => {
const hasInfo =
patch["mixed-port"] != null ||
patch["socks-port"] != null ||
patch["port"] != null ||
patch["external-controller"] != null ||
patch.secret != null;
@@ -68,6 +73,26 @@ export const useClashInfo = () => {
}
}
if (patch["socks-port"]) {
const port = patch["socks-port"];
if (port < 1000) {
throw new Error("The port should not < 1000");
}
if (port > 65536) {
throw new Error("The port should not > 65536");
}
}
if (patch["port"]) {
const port = patch["port"];
if (port < 1000) {
throw new Error("The port should not < 1000");
}
if (port > 65536) {
throw new Error("The port should not > 65536");
}
}
await patchClashConfig(patch);
mutateInfo();
mutate("getClashConfig");