diff --git a/src/components/home/proxy-tun-card.tsx b/src/components/home/proxy-tun-card.tsx index 6f4c5d86..60c218a7 100644 --- a/src/components/home/proxy-tun-card.tsx +++ b/src/components/home/proxy-tun-card.tsx @@ -142,13 +142,11 @@ export const ProxyTunCard: FC = () => { ); const { verge } = useVerge(); - const { isAdminMode, isServiceMode } = useSystemState(); + const { isTunModeAvailable } = useSystemState(); const { actualState: systemProxyActualState } = useSystemProxyState(); const { enable_tun_mode } = verge ?? {}; - const isTunAvailable = isServiceMode || isAdminMode; - const handleError = (err: Error) => { showNotice("error", err.message || err.toString()); }; @@ -168,7 +166,7 @@ export const ProxyTunCard: FC = () => { }; } else { return { - text: !isTunAvailable + text: !isTunModeAvailable ? t("TUN Mode Service Required") : enable_tun_mode ? t("TUN Mode Enabled") @@ -176,7 +174,13 @@ export const ProxyTunCard: FC = () => { tooltip: t("TUN Mode Intercept Info"), }; } - }, [activeTab, systemProxyActualState, enable_tun_mode, isTunAvailable, t]); + }, [ + activeTab, + systemProxyActualState, + enable_tun_mode, + isTunModeAvailable, + t, + ]); return ( @@ -202,7 +206,7 @@ export const ProxyTunCard: FC = () => { onClick={() => handleTabChange("tun")} icon={TroubleshootRounded} label={t("Tun Mode")} - hasIndicator={enable_tun_mode && isTunAvailable} + hasIndicator={enable_tun_mode && isTunModeAvailable} /> diff --git a/src/components/shared/ProxyControlSwitches.tsx b/src/components/shared/ProxyControlSwitches.tsx index f1ffe8b1..c775f91e 100644 --- a/src/components/shared/ProxyControlSwitches.tsx +++ b/src/components/shared/ProxyControlSwitches.tsx @@ -189,11 +189,11 @@ const ProxyControlSwitches = ({ onInfoClick={() => tunRef.current?.open()} onToggle={handleTunToggle} onError={onError} - disabled={!isServiceMode} + disabled={!isTunModeAvailable} highlight={!!enable_tun_mode} extraIcons={ <> - {!isServiceMode && ( + {!isTunModeAvailable && ( { const { t } = useTranslation(); - const { isAdminMode, isServiceMode } = useSystemState(); + const { isAdminMode, isServiceOk } = useSystemState(); const { data: verge, mutate: mutateVerge } = useSWR( "getVergeConfig", @@ -23,7 +23,7 @@ export const useVerge = () => { mutateVerge(); }; - const isTunAvailable = isServiceMode || isAdminMode; + const isTunAvailable = isAdminMode || isServiceOk; const { enable_tun_mode } = verge ?? {}; // 当服务不可用且TUN模式开启时自动关闭TUN