fixed an issue with enabling tun and system proxy if profiles are missing

This commit is contained in:
coolcoala
2025-08-05 19:05:44 +03:00
parent d2d26cc822
commit ffd32426b5
4 changed files with 49 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { useRef, useState } from "react";
import {useMemo, useRef, useState} from "react";
import { useTranslation } from "react-i18next";
import { useLockFn } from "ahooks";
import { mutate } from "swr";
@@ -56,6 +56,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import {useProfiles} from "@/hooks/use-profiles";
const isWIN = getSystem() === "windows";
interface Props {
@@ -106,6 +107,12 @@ const SettingSystem = ({ onError }: Props) => {
const { verge, patchVerge, mutateVerge } = useVerge();
const { installServiceAndRestartCore } = useServiceInstaller();
const { profiles } = useProfiles();
const hasProfiles = useMemo(() => {
const items = profiles?.items ?? [];
return items.some(p => p.type === 'local' || p.type === 'remote');
}, [profiles]);
const {
actualState: systemProxyActualState,
indicator: systemProxyIndicator,
@@ -261,7 +268,7 @@ const SettingSystem = ({ onError }: Props) => {
}}
onCatch={onError}
>
<Switch disabled={!isTunAvailable} />
<Switch disabled={!isTunAvailable || !hasProfiles} />
</GuardState>
</SettingRow>
@@ -297,7 +304,7 @@ const SettingSystem = ({ onError }: Props) => {
}}
onCatch={onError}
>
<Switch />
<Switch disabled={!hasProfiles} />
</GuardState>
</SettingRow>