Skip to content
Snippets Groups Projects
Unverified Commit 8086b6d7 authored by GyDi's avatar GyDi
Browse files

feat: disable script mode when use clash meta

parent 48e14b36
No related branches found
No related tags found
No related merge requests found
import useSWR from "swr"; import useSWR from "swr";
import { useEffect, useMemo } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Button, ButtonGroup, Paper } from "@mui/material"; import { Button, ButtonGroup, Paper } from "@mui/material";
import { getClashConfig, updateConfigs } from "@/services/api"; import { getClashConfig, updateConfigs } from "@/services/api";
import { patchClashConfig } from "@/services/cmds"; import { patchClashConfig } from "@/services/cmds";
import { ProxyGroups } from "@/components/proxy/proxy-groups"; import { useVerge } from "@/hooks/use-verge";
import { BasePage } from "@/components/base"; import { BasePage } from "@/components/base";
import { ProxyGroups } from "@/components/proxy/proxy-groups";
const ProxyPage = () => { const ProxyPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
...@@ -15,7 +17,15 @@ const ProxyPage = () => { ...@@ -15,7 +17,15 @@ const ProxyPage = () => {
getClashConfig getClashConfig
); );
const modeList = ["rule", "global", "direct", "script"]; const { verge } = useVerge();
const modeList = useMemo(() => {
if (verge?.clash_core === "clash-meta") {
return ["rule", "global", "direct"];
}
return ["rule", "global", "direct", "script"];
}, [verge?.clash_core]);
const curMode = clashConfig?.mode.toLowerCase(); const curMode = clashConfig?.mode.toLowerCase();
const onChangeMode = useLockFn(async (mode: string) => { const onChangeMode = useLockFn(async (mode: string) => {
...@@ -24,6 +34,12 @@ const ProxyPage = () => { ...@@ -24,6 +34,12 @@ const ProxyPage = () => {
mutateClash(); mutateClash();
}); });
useEffect(() => {
if (curMode && !modeList.includes(curMode)) {
onChangeMode("rule");
}
}, [curMode]);
return ( return (
<BasePage <BasePage
contentStyle={{ height: "100%" }} contentStyle={{ height: "100%" }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment