更新代理配置规则,现在不启用代理时,图片、音频加载将不再走系统代理 (#2382)

* 完善代理设置

* 更新

* update

---------

Co-authored-by: lyswhut <lyswhut@qq.com>
beta
Folltoshe 2025-05-10 10:43:58 +08:00 committed by GitHub
parent 6c5231dbff
commit 4c6257c145
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 17 deletions

View File

@ -3,3 +3,7 @@
- 新增「设置 → 其他设置 → 主窗口使用软件内置的圆角及阴影」设置(#2360
*默认启用,关闭后将使用系统原生的窗口样式,该设置重启软件后生效*
- 开放API新增播放器声音大小、静音、播放进度控制详情看接入文档#2386
### 变更
- 更新代理配置规则,现在不启用代理时,图片、音频加载将不再走系统代理(#2382 @Folltoshe

View File

@ -66,11 +66,7 @@ export const createWindow = () => {
const { shouldUseDarkColors, theme } = global.lx.theme
const ses = session.fromPartition('persist:win-main')
const proxy = getProxy()
if (proxy) {
void ses.setProxy({
proxyRules: `http://${proxy.host}:${proxy.port}`,
})
}
setSesProxy(ses, proxy?.host, proxy?.port)
/**
* Initial window options
@ -131,18 +127,22 @@ export const closeWindow = () => {
browserWindow.close()
}
const setSesProxy = (ses: Electron.Session, host?: string, port?: string | number) => {
if (host) {
void ses.setProxy({
mode: 'fixed_servers',
proxyRules: `http://${host}:${port}`,
})
} else {
void ses.setProxy({
mode: 'direct',
})
}
}
export const setProxy = () => {
if (!browserWindow) return
const proxy = getProxy()
if (proxy) {
void browserWindow.webContents.session.setProxy({
proxyRules: `http://${proxy.host}:${proxy.port}`,
})
} else {
void browserWindow.webContents.session.setProxy({
proxyRules: '',
})
}
setSesProxy(browserWindow.webContents.session, proxy?.host, proxy?.port)
}

View File

@ -95,9 +95,6 @@ export default () => {
sync.client.host = host
})
watch(() => appSetting['network.proxy.enable'], enable => {
proxy.enable = enable
})
watch(() => appSetting['network.proxy.enable'], enable => {
proxy.enable = enable
})