Skip to content

Commit 4c6257c

Browse files
folltoshelyswhut
andauthored
更新代理配置规则,现在不启用代理时,图片、音频加载将不再走系统代理 (#2382)
* 完善代理设置 * 更新 * update --------- Co-authored-by: lyswhut <[email protected]>
1 parent 6c5231d commit 4c6257c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

publish/changeLog.md

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

src/main/modules/winMain/main.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ export const createWindow = () => {
6666
const { shouldUseDarkColors, theme } = global.lx.theme
6767
const ses = session.fromPartition('persist:win-main')
6868
const proxy = getProxy()
69-
if (proxy) {
70-
void ses.setProxy({
71-
proxyRules: `http://${proxy.host}:${proxy.port}`,
72-
})
73-
}
69+
setSesProxy(ses, proxy?.host, proxy?.port)
7470

7571
/**
7672
* Initial window options
@@ -131,19 +127,23 @@ export const closeWindow = () => {
131127
browserWindow.close()
132128
}
133129

134-
export const setProxy = () => {
135-
if (!browserWindow) return
136-
const proxy = getProxy()
137-
if (proxy) {
138-
void browserWindow.webContents.session.setProxy({
139-
proxyRules: `http://${proxy.host}:${proxy.port}`,
130+
const setSesProxy = (ses: Electron.Session, host?: string, port?: string | number) => {
131+
if (host) {
132+
void ses.setProxy({
133+
mode: 'fixed_servers',
134+
proxyRules: `http://${host}:${port}`,
140135
})
141136
} else {
142-
void browserWindow.webContents.session.setProxy({
143-
proxyRules: '',
137+
void ses.setProxy({
138+
mode: 'direct',
144139
})
145140
}
146141
}
142+
export const setProxy = () => {
143+
if (!browserWindow) return
144+
const proxy = getProxy()
145+
setSesProxy(browserWindow.webContents.session, proxy?.host, proxy?.port)
146+
}
147147

148148

149149
export const sendEvent = <T = any>(name: string, params?: T) => {

src/renderer/core/useApp/useSettingSync.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ export default () => {
9595
sync.client.host = host
9696
})
9797

98-
watch(() => appSetting['network.proxy.enable'], enable => {
99-
proxy.enable = enable
100-
})
10198
watch(() => appSetting['network.proxy.enable'], enable => {
10299
proxy.enable = enable
103100
})

0 commit comments

Comments
 (0)