diff --git a/src/main/config/controledMihomo.ts b/src/main/config/controledMihomo.ts index ab26822..038d9b9 100644 --- a/src/main/config/controledMihomo.ts +++ b/src/main/config/controledMihomo.ts @@ -38,10 +38,6 @@ export async function patchControledMihomoConfig(patch: Partial): controledMihomoConfig.sniffer = defaultControledMihomoConfig.sniffer } - if (process.platform === 'darwin') { - delete controledMihomoConfig?.tun?.device - } - await generateProfile() await writeFile(controledMihomoConfigPath(), yaml.stringify(controledMihomoConfig), 'utf-8') } diff --git a/src/main/utils/init.ts b/src/main/utils/init.ts index d8a0162..ce4f69b 100644 --- a/src/main/utils/init.ts +++ b/src/main/utils/init.ts @@ -250,7 +250,8 @@ async function migration(): Promise { authentication, 'bind-address': bindAddress, 'lan-allowed-ips': lanAllowedIps, - 'lan-disallowed-ips': lanDisallowedIps + 'lan-disallowed-ips': lanDisallowedIps, + tun } = await getControledMihomoConfig() // add substore sider card if (useSubStore && !siderOrder.includes('substore')) { @@ -276,6 +277,16 @@ async function migration(): Promise { if (!lanDisallowedIps) { await patchControledMihomoConfig({ 'lan-disallowed-ips': [] }) } + // default tun device + if (!tun?.device || (process.platform === 'darwin' && tun.device === 'Mihomo')) { + const defaultDevice = process.platform === 'darwin' ? 'utun1500' : 'Mihomo' + await patchControledMihomoConfig({ + tun: { + ...tun, + device: defaultDevice + } + }) + } // remove custom app theme if (!['system', 'light', 'dark'].includes(appTheme)) { await patchAppConfig({ appTheme: 'system' })