refactor(proxy): update proxy handling logic in useAppInit and GeneralSettings (#9081)

- Simplified proxy setting logic by removing unnecessary dispatches for 'system' and 'none' modes.
- Updated useAppInit to set proxy to undefined for 'system' mode and clarified direct mode handling with comments.
This commit is contained in:
beyondkmp 2025-08-12 11:21:47 +08:00 committed by GitHub
parent 4fd00af273
commit 207f2e1689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 8 deletions

View File

@ -86,11 +86,12 @@ export function useAppInit() {
useEffect(() => {
if (proxyMode === 'system') {
window.api.setProxy('system', proxyBypassRules)
window.api.setProxy('system', undefined)
} else if (proxyMode === 'custom') {
proxyUrl && window.api.setProxy(proxyUrl, proxyBypassRules)
} else {
window.api.setProxy('')
// set proxy to none for direct mode
window.api.setProxy('', undefined)
}
}, [proxyUrl, proxyMode, proxyBypassRules])

View File

@ -113,12 +113,6 @@ const GeneralSettings: FC = () => {
const onProxyModeChange = (mode: 'system' | 'custom' | 'none') => {
dispatch(setProxyMode(mode))
if (mode === 'system') {
dispatch(_setProxyUrl(undefined))
} else if (mode === 'none') {
dispatch(_setProxyUrl(undefined))
dispatch(_setProxyBypassRules(undefined))
}
}
const languagesOptions: { value: LanguageVarious; label: string; flag: string }[] = [