diff --git a/publish/changeLog.md b/publish/changeLog.md index 853641dd..bf3e5bf2 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -3,3 +3,7 @@ - 新增「设置 → 其他设置 → 主窗口使用软件内置的圆角及阴影」设置(#2360) *默认启用,关闭后将使用系统原生的窗口样式,该设置重启软件后生效* - 开放API新增播放器声音大小、静音、播放进度控制,详情看接入文档(#2386) + +### 变更 + +- 更新代理配置规则,现在不启用代理时,图片、音频加载将不再走系统代理(#2382 @Folltoshe) diff --git a/src/main/modules/winMain/main.ts b/src/main/modules/winMain/main.ts index fc2d022d..4bc1214e 100644 --- a/src/main/modules/winMain/main.ts +++ b/src/main/modules/winMain/main.ts @@ -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) } diff --git a/src/renderer/core/useApp/useSettingSync.ts b/src/renderer/core/useApp/useSettingSync.ts index 40b26125..665b97ba 100644 --- a/src/renderer/core/useApp/useSettingSync.ts +++ b/src/renderer/core/useApp/useSettingSync.ts @@ -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 })