fix(sysproxy): keep the system proxy usable when the core is not ready

This commit is contained in:
wonfen
2026-08-24 19:32:52 +08:00
parent 9085d907cd
commit 8df8edb6dd
21 changed files with 108 additions and 30 deletions
@@ -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}
/>