Skip to content

Commit

Permalink
fix: pac file not work
Browse files Browse the repository at this point in the history
fix #532
  • Loading branch information
sunner committed Sep 13, 2023
1 parent 56bd840 commit 30ab813
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
50 changes: 32 additions & 18 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "<local>",
);
} 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) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ProxySetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<v-list-item v-if="proxySettings.proxyMode == 'pacFile'">
<v-list-item-title>{{ $t("proxy.pacFile") }}</v-list-item-title>
<v-text-field
v-model="proxySettings.PACfile"
v-model="proxySettings.pacFile"
:label="$t('proxy.pacFileUsing')"
disabled
></v-text-field>
Expand Down Expand Up @@ -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 });
Expand All @@ -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";
Expand Down

0 comments on commit 30ab813

Please sign in to comment.