Add toggle-able system proxy setting

This commit is contained in:
Gold John King
2024-12-24 19:52:22 +08:00
parent 9e9fc14e2b
commit 68c174c29b
5 changed files with 90 additions and 1 deletions
+18 -1
View File
@@ -2,6 +2,9 @@ import log from 'electron-log';
import { RegDwordValue, RegSzValue } from "regedit-rs"
import { execOnOs } from "../helpers/env.helpers";
import { bootstrap } from 'global-agent';
import { StaticConfigurationService } from "../services/static-configuration.service";
const staticConfig = StaticConfigurationService.getInstance();
const { list } = (execOnOs({ win32: () => require("regedit-rs") }, true) ?? {}) as typeof import("regedit-rs");
@@ -51,7 +54,21 @@ async function configureWindowsProxy() : Promise<void> {
export function configureProxy() {
if (process.platform === "win32") {
configureWindowsProxy();
const useSystemProxy = staticConfig.get("use-system-proxy");
if (useSystemProxy === true) {
configureWindowsProxy();
}
log.info(`configureProxy: UseSystemProxy is set to ${useSystemProxy}`);
staticConfig.$watch("use-system-proxy").subscribe((useSystemProxy) => {
if (useSystemProxy === true) {
configureWindowsProxy();
}
log.info(`configureProxy: UseSystemProxy is set to ${useSystemProxy}`);
});
} else {
log.info('configureProxy: Unsupported platform');
}
@@ -88,6 +88,7 @@ export interface StaticConfigKeyValues {
"song-details-cache-etag": string;
"disable-hadware-acceleration": boolean;
"use-symlinks": boolean;
"use-system-proxy": boolean;
// Linux Specific static configs
"proton-folder": string;