diff --git a/src/background.js b/src/background.js index 6468a6095a..91e1d8ca64 100644 --- a/src/background.js +++ b/src/background.js @@ -72,25 +72,39 @@ async function getProxySetting() { } // Set the proxy - if (proxySetting.proxyServer && proxySetting.enableProxy) { + if (proxySetting.enableProxy) { if (proxySetting.proxyMode === "normal") { - app.commandLine.appendSwitch( - "proxy-server", - proxySetting.proxyServer, - ); - app.commandLine.appendSwitch( - "proxy-bypass-list", - proxySetting.proxyBypassList ?? "", - ); - } else if ( - proxySetting.proxyMode === "pacFile" && - proxySetting.pacFile - ) { - // Note: proxy-pac-url can not load file via 'file://' , we need to change to base64 format - let data = getBase64(proxySetting.pacFile); - app.commandLine.appendSwitch("proxy-pac-url", data); - } else if (proxySetting.proxyMode === "pacUrl" && proxySetting.pacUrl) { - app.commandLine.appendSwitch("proxy-pac-url", proxySetting.pacUrl); + console.log("Set.proxySetting.normal"); + if (proxySetting.proxyServer) { + app.commandLine.appendSwitch( + "proxy-server", + proxySetting.proxyServer, + ); + app.commandLine.appendSwitch( + "proxy-bypass-list", + proxySetting.proxyBypassList ?? "", + ); + } else { + console.log("Proxy enable but no set any proxy."); + } + } else if (proxySetting.proxyMode === "pacFile") { + if (proxySetting.pacFile) { + console.log("Set.proxySetting.pacFile"); + let data = getBase64(proxySetting.pacFile); + console.log(data); + app.commandLine.appendSwitch("proxy-pac-url", data); + } else { + console.log( + "Proxy enable and pacFile mode set but no set any file.", + ); + } + } else if (proxySetting.proxyMode === "pacUrl") { + console.log("Set.proxySetting.pacUrl"); + if (proxySetting.pacUrl) { + app.commandLine.appendSwitch("proxy-pac-url", proxySetting.pacUrl); + } else { + console.log("Proxy enable and pacUrl mode set but no set any url."); + } } } } catch (err) { diff --git a/src/components/ProxySetting.vue b/src/components/ProxySetting.vue index 53dcb2dda2..e4beb80c44 100644 --- a/src/components/ProxySetting.vue +++ b/src/components/ProxySetting.vue @@ -66,7 +66,7 @@ {{ $t("proxy.pacFile") }} @@ -246,9 +246,9 @@ async function reload() { async function onlySave() { console.log(proxySettings.value); - const oldPacFile = proxySettings.value.PACfile; + const oldPacFile = proxySettings.value.pacFile; if (newInputfile.value) { - proxySettings.value.PACfile = newInputfile.value; + proxySettings.value.pacFile = newInputfile.value; } const data = JSON.parse(JSON.stringify(proxySettings.value)); const reply = await ipcRenderer.invoke("save-proxy-setting", { data }); @@ -258,7 +258,7 @@ async function onlySave() { snackbar.color = "success"; snackbar.timeout = 1000; } else { - proxySettings.value.PACfile = oldPacFile; + proxySettings.value.pacFile = oldPacFile; // snackbar.text = `Save failed: ${reply.error}`; snackbar.text = `${i18n.global.t("proxy.saveFailed")}: ${reply.error}`; snackbar.color = "error";