fix tun switcher

This commit is contained in:
pompurin404 2024-08-10 19:17:02 +08:00
parent 938802d0bf
commit 924765fa80
No known key found for this signature in database
2 changed files with 7 additions and 3 deletions

View File

@ -86,7 +86,11 @@ const buildContextMenu = (): Menu => {
checked: getControledMihomoConfig().tun?.enable ?? false, checked: getControledMihomoConfig().tun?.enable ?? false,
click: (item): void => { click: (item): void => {
const enable = item.checked const enable = item.checked
setControledMihomoConfig({ tun: { enable } }) if (enable) {
setControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
} else {
setControledMihomoConfig({ tun: { enable } })
}
patchMihomoConfig({ tun: { enable } }) patchMihomoConfig({ tun: { enable } })
window?.webContents.send('controledMihomoConfigUpdated') window?.webContents.send('controledMihomoConfigUpdated')
updateTrayMenu() updateTrayMenu()

View File

@ -34,9 +34,9 @@ const TunSwitcher: React.FC = () => {
if (enable) { if (enable) {
await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } }) await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
} else { } else {
await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } }) await patchControledMihomoConfig({ tun: { enable } })
await patchMihomoConfig({ tun: { enable } })
} }
await patchMihomoConfig({ tun: { enable } })
} }
return ( return (