import { useRef } from "react"; import { useTranslation } from "react-i18next"; import { TextField, Switch, Select, MenuItem, Typography, IconButton, } from "@mui/material"; import { ArrowForward, Settings } from "@mui/icons-material"; import { DialogRef } from "@/components/base"; import { useClash } from "@/hooks/use-clash"; import { GuardState } from "./mods/guard-state"; import { WebUIViewer } from "./mods/web-ui-viewer"; import { ClashFieldViewer } from "./mods/clash-field-viewer"; import { ClashPortViewer } from "./mods/clash-port-viewer"; import { ControllerViewer } from "./mods/controller-viewer"; import { SettingList, SettingItem } from "./mods/setting-comp"; import { ClashCoreViewer } from "./mods/clash-core-viewer"; import { invoke_uwp_tool } from "@/services/cmds"; import getSystem from "@/utils/get-system"; const isWIN = getSystem() === "windows"; interface Props { onError: (err: Error) => void; } const SettingClash = ({ onError }: Props) => { const { t } = useTranslation(); const { clash, version, mutateClash, patchClash } = useClash(); const { ipv6, "allow-lan": allowLan, "log-level": logLevel, "mixed-port": mixedPort, } = clash ?? {}; const webRef = useRef(null); const fieldRef = useRef(null); const portRef = useRef(null); const ctrlRef = useRef(null); const coreRef = useRef(null); const onSwitchFormat = (_e: any, value: boolean) => value; const onChangeData = (patch: Partial) => { mutateClash((old) => ({ ...(old! || {}), ...patch }), false); }; return ( onChangeData({ "allow-lan": e })} onGuard={(e) => patchClash({ "allow-lan": e })} > onChangeData({ ipv6: e })} onGuard={(e) => patchClash({ ipv6: e })} > e.target.value} onChange={(e) => onChangeData({ "log-level": e })} onGuard={(e) => patchClash({ "log-level": e })} > { portRef.current?.open(); (e.target as any).blur(); }} /> ctrlRef.current?.open()} > webRef.current?.open()} > fieldRef.current?.open()} > coreRef.current?.open()} > } > {version} {isWIN && ( )} ); }; export default SettingClash;