try to fix sysproxy

This commit is contained in:
pompurin404 2024-08-29 10:49:13 +08:00
parent 54306ee64b
commit 2429a5f189
No known key found for this signature in database
2 changed files with 24 additions and 12 deletions

View File

@ -63,10 +63,14 @@ export async function enableSysProxy(): Promise<void> {
switch (mode || 'manual') {
case 'auto': {
if (process.platform === 'win32') {
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
'pac',
`http://${host || '127.0.0.1'}:${pacPort}/pac`
])
try {
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
'pac',
`http://${host || '127.0.0.1'}:${pacPort}/pac`
])
} catch {
triggerAutoProxy(true, `http://${host || '127.0.0.1'}:${pacPort}/pac`)
}
} else {
triggerAutoProxy(true, `http://${host || '127.0.0.1'}:${pacPort}/pac`)
}
@ -76,11 +80,15 @@ export async function enableSysProxy(): Promise<void> {
case 'manual': {
if (process.platform === 'win32') {
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
'global',
`${host || '127.0.0.1'}:${port}`,
bypass.join(';')
])
try {
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
'global',
`${host || '127.0.0.1'}:${port}`,
bypass.join(';')
])
} catch {
triggerManualProxy(true, host || '127.0.0.1', port, bypass.join(','))
}
} else {
triggerManualProxy(true, host || '127.0.0.1', port, bypass.join(','))
}

View File

@ -27,9 +27,13 @@ const SysproxySwitcher: React.FC = () => {
})
const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null
const onChange = async (enable: boolean): Promise<void> => {
await triggerSysProxy(enable)
await patchAppConfig({ sysProxy: { enable } })
window.electron.ipcRenderer.send('updateTrayMenu')
try {
await triggerSysProxy(enable)
await patchAppConfig({ sysProxy: { enable } })
window.electron.ipcRenderer.send('updateTrayMenu')
} catch (e) {
alert(e)
}
}
return (