mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-29 01:52:08 +08:00
fix(setting): mount only reachable proxy control viewers
ProxyControlSwitches unconditionally mounted both SysproxyViewer and TunViewer while its switch rows are mutually exclusive, so every instance carried a dialog that could never open, each firing getEmbeddedServerPort or a clash query subscription on mount. Mount each viewer under the same condition as the switch row that opens it. SettingSystem also mounted its own SysproxyViewer and TunViewer whose refs were never opened there; the reachable entries are the ProxyControlSwitches rows, so the dead pair is removed. Viewer mounts across the app drop from eight (setting-system: two own + two per instance, proxy-tun-card: two) to three (one per rendered switch variant).
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import React, { useRef } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { DialogRef, Switch, TooltipIcon } from '@/components/base'
|
||||
import { Switch, TooltipIcon } from '@/components/base'
|
||||
import ProxyControlSwitches from '@/components/shared/proxy-control-switches'
|
||||
import { useVerge } from '@/hooks/use-verge'
|
||||
|
||||
import { GuardState } from './mods/guard-state'
|
||||
import { SettingList, SettingItem } from './mods/setting-comp'
|
||||
import { SysproxyViewer } from './mods/sysproxy-viewer'
|
||||
import { TunViewer } from './mods/tun-viewer'
|
||||
|
||||
interface Props {
|
||||
onError?: (err: Error) => void
|
||||
@@ -21,9 +19,6 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
|
||||
const { enable_auto_launch, enable_silent_start } = verge ?? {}
|
||||
|
||||
const sysproxyRef = useRef<DialogRef>(null)
|
||||
const tunRef = useRef<DialogRef>(null)
|
||||
|
||||
const onSwitchFormat = (
|
||||
_e: React.ChangeEvent<HTMLInputElement>,
|
||||
value: boolean,
|
||||
@@ -34,9 +29,6 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
|
||||
return (
|
||||
<SettingList title={t('settings.sections.system.title')}>
|
||||
<SysproxyViewer ref={sysproxyRef} />
|
||||
<TunViewer ref={tunRef} />
|
||||
|
||||
<ProxyControlSwitches
|
||||
label={t('settings.sections.system.toggles.tunMode')}
|
||||
onError={onError}
|
||||
|
||||
@@ -229,8 +229,8 @@ const ProxyControlSwitches = ({
|
||||
/>
|
||||
)}
|
||||
|
||||
<SysproxyViewer ref={sysproxyRef} />
|
||||
<TunViewer ref={tunRef} />
|
||||
{isSystemProxyMode && <SysproxyViewer ref={sysproxyRef} />}
|
||||
{isTunMode && <TunViewer ref={tunRef} />}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user