Skip to content

Commit

Permalink
fix tun switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
pompurin404 committed Aug 10, 2024
1 parent 938802d commit 924765f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/main/core/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ const buildContextMenu = (): Menu => {
checked: getControledMihomoConfig().tun?.enable ?? false,
click: (item): void => {
const enable = item.checked
setControledMihomoConfig({ tun: { enable } })
if (enable) {
setControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
} else {
setControledMihomoConfig({ tun: { enable } })
}
patchMihomoConfig({ tun: { enable } })
window?.webContents.send('controledMihomoConfigUpdated')
updateTrayMenu()
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/components/sider/tun-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const TunSwitcher: React.FC = () => {
if (enable) {
await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
} else {
await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
await patchMihomoConfig({ tun: { enable } })
await patchControledMihomoConfig({ tun: { enable } })
}
await patchMihomoConfig({ tun: { enable } })
}

return (
Expand Down

0 comments on commit 924765f

Please sign in to comment.