@@ -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
149149export const sendEvent = < T = any > ( name : string , params ?: T ) => {
0 commit comments