From 4c6257c1453a5dea4bb2de809b056c6404ca8f67 Mon Sep 17 00:00:00 2001 From: Folltoshe Date: Sat, 10 May 2025 10:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=90=86=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=A7=84=E5=88=99=EF=BC=8C=E7=8E=B0=E5=9C=A8=E4=B8=8D?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E4=BB=A3=E7=90=86=E6=97=B6=EF=BC=8C=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E3=80=81=E9=9F=B3=E9=A2=91=E5=8A=A0=E8=BD=BD=E5=B0=86?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E8=B5=B0=E7=B3=BB=E7=BB=9F=E4=BB=A3=E7=90=86?= =?UTF-8?q?=20(#2382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 完善代理设置 * 更新 * update --------- Co-authored-by: lyswhut --- publish/changeLog.md | 4 ++++ src/main/modules/winMain/main.ts | 28 +++++++++++----------- src/renderer/core/useApp/useSettingSync.ts | 3 --- 3 files changed, 18 insertions(+), 17 deletions(-) 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 })