Feat: may setup proxy (#238)

* add https proxy

* remove proxy in renderer

* proxy work for openai request

* use proxyAgent to enable system proxy

* add proxy setting

* tweak proxy setting
This commit is contained in:
an-lee
2024-02-01 15:33:37 +08:00
committed by GitHub
parent 93dea4ad54
commit 51a810fdfd
17 changed files with 470 additions and 32 deletions

View File

@@ -0,0 +1,21 @@
import settings from "@main/settings";
import { HttpsProxyAgent } from "https-proxy-agent";
import { ProxyAgent } from "proxy-agent";
import fetch from "node-fetch";
export default function () {
const proxyConfig = settings.getSync("proxy") as ProxyConfigType;
let proxyAgent = new ProxyAgent();
if (proxyConfig.enabled && proxyConfig.url) {
proxyAgent = new ProxyAgent({
httpAgent: new HttpsProxyAgent(proxyConfig.url),
httpsAgent: new HttpsProxyAgent(proxyConfig.url),
});
}
return {
httpAgent: proxyAgent,
fetch,
};
}