mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 11:42:21 +08:00
feat: disable script mode when use clash meta
This commit is contained in:
parent
48e14b36b8
commit
8086b6d78c
|
@ -1,11 +1,13 @@
|
|||
import useSWR from "swr";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button, ButtonGroup, Paper } from "@mui/material";
|
||||
import { getClashConfig, updateConfigs } from "@/services/api";
|
||||
import { patchClashConfig } from "@/services/cmds";
|
||||
import { ProxyGroups } from "@/components/proxy/proxy-groups";
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
import { BasePage } from "@/components/base";
|
||||
import { ProxyGroups } from "@/components/proxy/proxy-groups";
|
||||
|
||||
const ProxyPage = () => {
|
||||
const { t } = useTranslation();
|
||||
|
@ -15,7 +17,15 @@ const ProxyPage = () => {
|
|||
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 onChangeMode = useLockFn(async (mode: string) => {
|
||||
|
@ -24,6 +34,12 @@ const ProxyPage = () => {
|
|||
mutateClash();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (curMode && !modeList.includes(curMode)) {
|
||||
onChangeMode("rule");
|
||||
}
|
||||
}, [curMode]);
|
||||
|
||||
return (
|
||||
<BasePage
|
||||
contentStyle={{ height: "100%" }}
|
||||
|
|
Loading…
Reference in New Issue
Block a user