From 3f5cd6c26a02739210d3abbcae497c1764d5f85c Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Thu, 7 Aug 2025 02:18:50 +0800 Subject: [PATCH] fix: resolve system proxy status detection and display inconsistency - Fixed getSystemProxyActualState logic to properly check actual system status - Unified system proxy state display across all components - Replaced systemProxyIndicator with actualState for consistent UI display - Updated components: setting-system, ProxyControlSwitches, proxy-tun-card - Added entry to v2.4.0 changelog --- UPDATELOG.md | 1 + src-tauri/Cargo.toml | 2 +- src/components/home/proxy-tun-card.tsx | 8 ++++---- src/components/setting/setting-system.tsx | 9 +++------ src/components/shared/ProxyControlSwitches.tsx | 9 +++------ src/hooks/use-system-proxy-state.ts | 13 +++++++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/UPDATELOG.md b/UPDATELOG.md index 444f22cd5..878befbe2 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -26,6 +26,7 @@ ### 🐞 修复问题 +- 修复系统代理状态检测和显示不一致问题 - 修复系统主题窗口颜色不一致问题 - 修复特殊字符 URL 处理问题 - 修复配置修改后缓存不同步问题 diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index f84d18684..514add624 100755 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -16,7 +16,7 @@ identifier = "io.github.clash-verge-rev.clash-verge-rev" tauri-build = { version = "2.3.1", features = [] } [dependencies] -warp = { version = "0.4.0", features = ["server"]} +warp = { version = "0.4.0", features = ["server"] } anyhow = "1.0.98" dirs = "6.0" open = "5.3.2" diff --git a/src/components/home/proxy-tun-card.tsx b/src/components/home/proxy-tun-card.tsx index 6dcba565a..428d42ef6 100644 --- a/src/components/home/proxy-tun-card.tsx +++ b/src/components/home/proxy-tun-card.tsx @@ -146,7 +146,7 @@ export const ProxyTunCard: FC = () => { const { verge } = useVerge(); const { isAdminMode } = useSystemState(); - const { indicator: systemProxyIndicator } = useSystemProxyState(); + const { actualState: systemProxyActualState } = useSystemProxyState(); const { enable_tun_mode } = verge ?? {}; @@ -182,7 +182,7 @@ export const ProxyTunCard: FC = () => { const tabDescription = useMemo(() => { if (activeTab === "system") { return { - text: systemProxyIndicator + text: systemProxyActualState ? t("System Proxy Enabled") : t("System Proxy Disabled"), tooltip: t("System Proxy Info"), @@ -197,7 +197,7 @@ export const ProxyTunCard: FC = () => { tooltip: t("TUN Mode Intercept Info"), }; } - }, [activeTab, systemProxyIndicator, enable_tun_mode, isTunAvailable, t]); + }, [activeTab, systemProxyActualState, enable_tun_mode, isTunAvailable, t]); return ( @@ -216,7 +216,7 @@ export const ProxyTunCard: FC = () => { onClick={() => handleTabChange("system")} icon={ComputerRounded} label={t("System Proxy")} - hasIndicator={systemProxyIndicator} + hasIndicator={systemProxyActualState} /> { const { verge, mutateVerge, patchVerge } = useVerge(); const { installServiceAndRestartCore } = useServiceInstaller(); - const { - actualState: systemProxyActualState, - indicator: systemProxyIndicator, - toggleSystemProxy, - } = useSystemProxyState(); + const { actualState: systemProxyActualState, toggleSystemProxy } = + useSystemProxyState(); const { isAdminMode, isServiceMode, mutateRunningMode } = useSystemState(); @@ -179,7 +176,7 @@ const SettingSystem = ({ onError }: Props) => { icon={SettingsRounded} onClick={() => sysproxyRef.current?.open()} /> - {systemProxyIndicator ? ( + {systemProxyActualState ? ( ) : ( diff --git a/src/components/shared/ProxyControlSwitches.tsx b/src/components/shared/ProxyControlSwitches.tsx index f96d5cbeb..a8a79b74d 100644 --- a/src/components/shared/ProxyControlSwitches.tsx +++ b/src/components/shared/ProxyControlSwitches.tsx @@ -40,11 +40,8 @@ const ProxyControlSwitches = ({ label, onError }: ProxySwitchProps) => { const theme = useTheme(); const { installServiceAndRestartCore } = useServiceInstaller(); - const { - actualState: systemProxyActualState, - indicator: systemProxyIndicator, - toggleSystemProxy, - } = useSystemProxyState(); + const { actualState: systemProxyActualState, toggleSystemProxy } = + useSystemProxyState(); const { data: runningMode } = useSWR("getRunningMode", getRunningMode); @@ -99,7 +96,7 @@ const ProxyControlSwitches = ({ label, onError }: ProxySwitchProps) => { }} > - {systemProxyIndicator ? ( + {systemProxyActualState ? ( diff --git a/src/hooks/use-system-proxy-state.ts b/src/hooks/use-system-proxy-state.ts index 22f1c7cba..08c37e7c1 100644 --- a/src/hooks/use-system-proxy-state.ts +++ b/src/hooks/use-system-proxy-state.ts @@ -18,13 +18,18 @@ export const useSystemProxyState = () => { const getSystemProxyActualState = () => { const userEnabled = enable_system_proxy ?? false; + // 用户配置状态应该与系统实际状态一致 + // 如果用户启用了系统代理,检查实际的系统状态 if (userEnabled) { - return true; + if (proxy_auto_config) { + return autoproxy?.enable ?? false; + } else { + return sysproxy?.enable ?? false; + } } - return autoproxy?.enable === false && sysproxy?.enable === false - ? false - : userEnabled; + // 用户没有启用时,返回 false + return false; }; const getSystemProxyIndicator = () => {