fix: disable tun mode menu on tray when tun mode is unavailable (#4975)

* fix: check if service installed when toggle tun mode on tray

* chore: cargo fmt

* fix: auto disable tun mode

* docs: update UPDATELOG.md

* fix: init Tun mode status

* chore: update

* feat: disable tun mode tray menu when tun mode is unavailable

* fix: restart core when uninstall service is canceled

* chore: remove check notification when toggle tun mode

* chore: fix updatelog

---------

Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com>
This commit is contained in:
oomeow
2025-10-31 17:31:40 +08:00
committed by GitHub
co-authored by Tunglies
parent 5187712a71
commit 8c734a5a35
11 changed files with 175 additions and 197 deletions
+22 -29
View File
@@ -117,13 +117,8 @@ const ProxyControlSwitches = ({
const { uninstallServiceAndRestartCore } = useServiceUninstaller();
const { actualState: systemProxyActualState, toggleSystemProxy } =
useSystemProxyState();
const {
isServiceMode,
isTunModeAvailable,
mutateRunningMode,
mutateServiceOk,
mutateTunModeAvailable,
} = useSystemState();
const { isServiceOk, isTunModeAvailable, mutateSystemState } =
useSystemState();
const sysproxyRef = useRef<DialogRef>(null);
const tunRef = useRef<DialogRef>(null);
@@ -148,9 +143,7 @@ const ProxyControlSwitches = ({
const onInstallService = useLockFn(async () => {
try {
await installServiceAndRestartCore();
await mutateRunningMode();
await mutateServiceOk();
await mutateTunModeAvailable();
await mutateSystemState();
} catch (err) {
showNotice("error", (err as Error).message || String(err));
}
@@ -158,11 +151,11 @@ const ProxyControlSwitches = ({
const onUninstallService = useLockFn(async () => {
try {
await handleTunToggle(false);
if (verge?.enable_tun_mode) {
await handleTunToggle(false);
}
await uninstallServiceAndRestartCore();
await mutateRunningMode();
await mutateServiceOk();
await mutateTunModeAvailable();
await mutateSystemState();
} catch (err) {
showNotice("error", (err as Error).message || String(err));
}
@@ -198,22 +191,22 @@ const ProxyControlSwitches = ({
extraIcons={
<>
{!isTunModeAvailable && (
<TooltipIcon
title={t("TUN requires Service Mode or Admin Mode")}
icon={WarningRounded}
sx={{ color: "warning.main", ml: 1 }}
/>
<>
<TooltipIcon
title={t("TUN requires Service Mode or Admin Mode")}
icon={WarningRounded}
sx={{ color: "warning.main", ml: 1 }}
/>
<TooltipIcon
title={t("Install Service")}
icon={BuildRounded}
color="primary"
onClick={onInstallService}
sx={{ ml: 1 }}
/>
</>
)}
{!isTunModeAvailable && (
<TooltipIcon
title={t("Install Service")}
icon={BuildRounded}
color="primary"
onClick={onInstallService}
sx={{ ml: 1 }}
/>
)}
{isServiceMode && (
{isServiceOk && (
<TooltipIcon
title={t("Uninstall Service")}
icon={DeleteForeverRounded}