From 4325c77b4ccce3d72c1f0e019027c01f61af845e Mon Sep 17 00:00:00 2001 From: ezequielnick <107352853+ezequielnick@users.noreply.github.com> Date: Wed, 20 Aug 2025 20:06:24 +0800 Subject: [PATCH] fix: default tun device name doesn't work --- src/main/config/controledMihomo.ts | 4 ---- src/main/utils/init.ts | 13 ++++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) 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' })