🎨 设置代理切换时不再需要重启 Fix https://github.com/siyuan-note/siyuan/issues/6680

This commit is contained in:
Liang Ding 2022-11-24 11:25:00 +08:00
parent de529c2edd
commit eb3098bfe9
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
9 changed files with 31 additions and 22 deletions

View file

@ -90,12 +90,18 @@ const hasKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "edito
export const setProxy = () => {
/// #if !BROWSER
const session = getCurrentWindow().webContents.session;
if (window.siyuan.config.system.networkProxy.scheme) {
session.closeAllConnections().then(() => {
session.setProxy({proxyRules: `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}`}).then();
});
if ("" === window.siyuan.config.system.networkProxy.scheme) {
console.log("network proxy [system]");
return
}
const session = getCurrentWindow().webContents.session;
session.closeAllConnections().then(() => {
const proxyURL = `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}`
session.setProxy({proxyRules: proxyURL}).then(
() => console.log("network proxy [" + proxyURL + "]"),
);
});
/// #endif
};