From 1ef2595de3a81d7b9de914468a9a5648a743ac93 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Fri, 13 Sep 2024 15:52:47 +0800 Subject: [PATCH] fix sysproxy --- src/main/sys/sysproxy.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/sys/sysproxy.ts b/src/main/sys/sysproxy.ts index b3e3183..f6b1588 100644 --- a/src/main/sys/sysproxy.ts +++ b/src/main/sys/sysproxy.ts @@ -48,10 +48,10 @@ if (process.platform === 'win32') export async function triggerSysProxy(enable: boolean): Promise { if (enable) { - disableSysProxy() + await disableSysProxy() await enableSysProxy() } else { - disableSysProxy() + await disableSysProxy() } } @@ -97,10 +97,15 @@ export async function enableSysProxy(): Promise { } } -export function disableSysProxy(): void { +export async function disableSysProxy(): Promise { const execFilePromise = promisify(execFile) if (process.platform === 'win32') { - execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), ['set', '1']) + try { + await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), ['set', '1']) + } catch { + triggerAutoProxy(false, '') + triggerManualProxy(false, '', 0, '') + } } else { triggerAutoProxy(false, '') triggerManualProxy(false, '', 0, '')