fixed an issue with enabling tun and system proxy if profiles are missing
This commit is contained in:
@@ -17,7 +17,8 @@ export const PowerButton = React.forwardRef<HTMLButtonElement, PowerButtonProps>
|
||||
<div
|
||||
className={cn(
|
||||
'absolute h-28 w-28 rounded-full blur-3xl transition-all duration-500',
|
||||
state === 'on' ? 'bg-green-400/60' : 'bg-red-500/40'
|
||||
state === 'on' ? 'bg-green-400/60' : 'bg-red-500/40',
|
||||
props.disabled && 'opacity-0'
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -33,11 +34,18 @@ export const PowerButton = React.forwardRef<HTMLButtonElement, PowerButtonProps>
|
||||
'data-[state=on]:text-green-500 dark:data-[state=on]:text-white',
|
||||
'data-[state=on]:shadow-[0_0_50px_rgba(34,197,94,1)]',
|
||||
'transition-all duration-300 hover:scale-105 active:scale-95 focus:outline-none',
|
||||
'disabled:cursor-not-allowed disabled:scale-100',
|
||||
|
||||
// Стили ТОЛЬКО для отключенного состояния (но не для загрузки)
|
||||
(props.disabled && !loading) && 'grayscale opacity-50 shadow-none bg-slate-100/70 border-slate-300/80',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<Power className="h-20 w-20 transition-transform duration-300 active:scale-90" />
|
||||
<Power className={cn(
|
||||
"h-20 w-20",
|
||||
!props.disabled && "active:scale-90 transition-transform duration-300"
|
||||
)} />
|
||||
</button>
|
||||
|
||||
{loading && (
|
||||
|
||||
@@ -296,7 +296,7 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
||||
</Button>
|
||||
{!isUrlValid && importUrl && (
|
||||
<p className="text-sm text-destructive px-1">
|
||||
{t("Please enter a valid URL")}
|
||||
{t("Invalid Profile URL")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user