mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-02 04:42:09 +08:00
fix(sysproxy): keep the system proxy usable when the core is not ready
This commit is contained in:
@@ -137,7 +137,7 @@ const ProxyControlSwitches = ({
|
||||
const { uninstallServiceAndStartSidecar } = useServiceUninstaller()
|
||||
const { indicator: systemProxyIndicator, toggleSystemProxy } =
|
||||
useSystemProxyState()
|
||||
const { runState, isTunModeAvailable } = useSystemState()
|
||||
const { runState, isTunModeAvailable, isLoading } = useSystemState()
|
||||
// Offer to uninstall only a service that is actually there and working.
|
||||
const isServiceInstallReady = runState.serviceUsable
|
||||
|
||||
@@ -146,6 +146,15 @@ const ProxyControlSwitches = ({
|
||||
|
||||
const { enable_tun_mode } = verge ?? {}
|
||||
|
||||
// Enabling needs a running core; disabling only writes OS state and must stay available.
|
||||
const handleSystemProxyToggle = async (value: boolean) => {
|
||||
if (value && !isLoading && runState.mode === 'NotRunning') {
|
||||
showNotice.error('settings.feedback.errors.sysproxy.coreNotReady')
|
||||
return false
|
||||
}
|
||||
await toggleSystemProxy(value)
|
||||
}
|
||||
|
||||
const handleTunToggle = async (value: boolean) => {
|
||||
if (value && !isTunModeAvailable) {
|
||||
requestService({
|
||||
@@ -178,7 +187,7 @@ const ProxyControlSwitches = ({
|
||||
active={systemProxyIndicator}
|
||||
infoTitle={t('settings.sections.proxyControl.tooltips.systemProxy')}
|
||||
onInfoClick={() => sysproxyRef.current?.open()}
|
||||
onToggle={(value) => toggleSystemProxy(value)}
|
||||
onToggle={handleSystemProxyToggle}
|
||||
onError={onError}
|
||||
highlight={systemProxyIndicator}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user