mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
try to fix sysproxy
This commit is contained in:
parent
54306ee64b
commit
2429a5f189
@ -63,10 +63,14 @@ export async function enableSysProxy(): Promise<void> {
|
|||||||
switch (mode || 'manual') {
|
switch (mode || 'manual') {
|
||||||
case 'auto': {
|
case 'auto': {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
|
try {
|
||||||
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
|
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
|
||||||
'pac',
|
'pac',
|
||||||
`http://${host || '127.0.0.1'}:${pacPort}/pac`
|
`http://${host || '127.0.0.1'}:${pacPort}/pac`
|
||||||
])
|
])
|
||||||
|
} catch {
|
||||||
|
triggerAutoProxy(true, `http://${host || '127.0.0.1'}:${pacPort}/pac`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
triggerAutoProxy(true, `http://${host || '127.0.0.1'}:${pacPort}/pac`)
|
triggerAutoProxy(true, `http://${host || '127.0.0.1'}:${pacPort}/pac`)
|
||||||
}
|
}
|
||||||
@ -76,11 +80,15 @@ export async function enableSysProxy(): Promise<void> {
|
|||||||
|
|
||||||
case 'manual': {
|
case 'manual': {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
|
try {
|
||||||
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
|
await execFilePromise(path.join(resourcesFilesDir(), 'sysproxy.exe'), [
|
||||||
'global',
|
'global',
|
||||||
`${host || '127.0.0.1'}:${port}`,
|
`${host || '127.0.0.1'}:${port}`,
|
||||||
bypass.join(';')
|
bypass.join(';')
|
||||||
])
|
])
|
||||||
|
} catch {
|
||||||
|
triggerManualProxy(true, host || '127.0.0.1', port, bypass.join(','))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
triggerManualProxy(true, host || '127.0.0.1', port, bypass.join(','))
|
triggerManualProxy(true, host || '127.0.0.1', port, bypass.join(','))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,9 +27,13 @@ const SysproxySwitcher: React.FC = () => {
|
|||||||
})
|
})
|
||||||
const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null
|
const transform = tf ? { x: tf.x, y: tf.y, scaleX: 1, scaleY: 1 } : null
|
||||||
const onChange = async (enable: boolean): Promise<void> => {
|
const onChange = async (enable: boolean): Promise<void> => {
|
||||||
|
try {
|
||||||
await triggerSysProxy(enable)
|
await triggerSysProxy(enable)
|
||||||
await patchAppConfig({ sysProxy: { enable } })
|
await patchAppConfig({ sysProxy: { enable } })
|
||||||
window.electron.ipcRenderer.send('updateTrayMenu')
|
window.electron.ipcRenderer.send('updateTrayMenu')
|
||||||
|
} catch (e) {
|
||||||
|
alert(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user