refactor: Remove clash field filter

This commit is contained in:
MystiPanda
2024-02-05 16:47:40 +08:00
parent 45f863a72a
commit e990530ada
14 changed files with 182 additions and 352 deletions

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");