fix sysproxy

This commit is contained in:
pompurin404 2024-09-13 15:52:47 +08:00
parent 3eabb15efb
commit 1ef2595de3
No known key found for this signature in database

View File

@ -48,10 +48,10 @@ if (process.platform === 'win32')
export async function triggerSysProxy(enable: boolean): Promise<void> { export async function triggerSysProxy(enable: boolean): Promise<void> {
if (enable) { if (enable) {
disableSysProxy() await disableSysProxy()
await enableSysProxy() await enableSysProxy()
} else { } else {
disableSysProxy() await disableSysProxy()
} }
} }
@ -97,10 +97,15 @@ export async function enableSysProxy(): Promise<void> {
} }
} }
export function disableSysProxy(): void { export async function disableSysProxy(): Promise<void> {
const execFilePromise = promisify(execFile) const execFilePromise = promisify(execFile)
if (process.platform === 'win32') { 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 { } else {
triggerAutoProxy(false, '') triggerAutoProxy(false, '')
triggerManualProxy(false, '', 0, '') triggerManualProxy(false, '', 0, '')