Skip to content

Commit 924765f

Browse files
author
pompurin404
committed
fix tun switcher
1 parent 938802d commit 924765f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/core/tray.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ const buildContextMenu = (): Menu => {
8686
checked: getControledMihomoConfig().tun?.enable ?? false,
8787
click: (item): void => {
8888
const enable = item.checked
89-
setControledMihomoConfig({ tun: { enable } })
89+
if (enable) {
90+
setControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
91+
} else {
92+
setControledMihomoConfig({ tun: { enable } })
93+
}
9094
patchMihomoConfig({ tun: { enable } })
9195
window?.webContents.send('controledMihomoConfigUpdated')
9296
updateTrayMenu()

src/renderer/src/components/sider/tun-switcher.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const TunSwitcher: React.FC = () => {
3434
if (enable) {
3535
await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
3636
} else {
37-
await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
38-
await patchMihomoConfig({ tun: { enable } })
37+
await patchControledMihomoConfig({ tun: { enable } })
3938
}
39+
await patchMihomoConfig({ tun: { enable } })
4040
}
4141

4242
return (

0 commit comments

Comments
 (0)