From aba4d123027fc5b1785d5239c675f7e985ed47e6 Mon Sep 17 00:00:00 2001 From: buvta <12312540+buvta@users.noreply.github.com> Date: Sat, 5 Dec 2020 23:54:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E4=B8=8D=E4=BC=9A=E6=84=8F?= =?UTF-8?q?=E5=A4=96=E5=BC=95=E5=85=A5=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/site/tools.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index 9dfefeb..5a30943 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -393,17 +393,15 @@ const zy = { async proxy () { return new Promise((resolve, reject) => { setting.find().then(db => { - if (db.proxy) { - if (db.proxy.type === 'none') { - session.setProxy({ proxyRules: 'direct://' }) + if (db && db.proxy && db.proxy.type === 'manual') { + if (db.proxy.scheme && db.proxy.url && db.proxy.port) { + const proxyURL = db.proxy.scheme + '://' + db.proxy.url.trim() + ':' + db.proxy.port.trim() + session.setProxy({ proxyRules: proxyURL }) http.globalAgent = https.globalAgent = new ElectronProxyAgent(session) - } else if (db.proxy.type === 'manual') { - if (db.proxy.scheme && db.proxy.url && db.proxy.port) { - const proxyURL = db.proxy.scheme + '://' + db.proxy.url.trim() + ':' + db.proxy.port.trim() - session.setProxy({ proxyRules: proxyURL }) - http.globalAgent = https.globalAgent = new ElectronProxyAgent(session) - } } + } else { + session.setProxy({ proxyRules: 'direct://' }) + http.globalAgent = https.globalAgent = new ElectronProxyAgent(session) } // 不要删了,留着测试用 // axios.get('https://api.my-ip.io/ip').then(res => console.log(res))