From ea8ea38cd4ac9aa6041cc9f84a8de5061f3f4aa1 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 26 Oct 2020 22:50:42 +0800 Subject: [PATCH] refactor: proxy --- packages/core/src/switch/proxy/impl/npm-proxy.js | 16 ++++++++-------- .../core/src/switch/proxy/impl/yarn-proxy.js | 15 ++++++++------- packages/gui/src/view/api.js | 3 ++- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/core/src/switch/proxy/impl/npm-proxy.js b/packages/core/src/switch/proxy/impl/npm-proxy.js index 31400de9..8748f0ab 100644 --- a/packages/core/src/switch/proxy/impl/npm-proxy.js +++ b/packages/core/src/switch/proxy/impl/npm-proxy.js @@ -28,11 +28,11 @@ class WindowsSystemProxy extends SystemProxy { ret = await winExec(`npm config set https-proxy=http://${ip}:${port}`) console.log('npm https proxy set success', ret) - // ret = await winExec(`npm config set cafile ${config.getDefaultCAKeyPath()}`) - // console.log('npm cafile set success', ret) + ret = await winExec(`npm config set ca ${config.getDefaultCAKeyPath()}`) + console.log('npm cafile set success', ret) - ret = await winExec('npm config set strict-ssl false') - console.log('npm strict-ssl false success', ret) + // ret = await winExec('npm config set strict-ssl false') + // console.log('npm strict-ssl false success', ret) } static async unsetProxy () { @@ -41,10 +41,10 @@ class WindowsSystemProxy extends SystemProxy { await winExec('npm config delete https-proxy') console.log('npm https proxy unset success') - await winExec('npm config delete cafile') - console.log('npm cafile unset success') - await winExec(' npm config delete strict-ssl') - console.log('npm strict-ssl true success') + await winExec('npm config delete ca') + console.log('npm ca unset success') + // await winExec(' npm config delete strict-ssl') + // console.log('npm strict-ssl true success') } static _asyncRegSet (regKey, name, type, value) { diff --git a/packages/core/src/switch/proxy/impl/yarn-proxy.js b/packages/core/src/switch/proxy/impl/yarn-proxy.js index 73c94426..e65ba832 100644 --- a/packages/core/src/switch/proxy/impl/yarn-proxy.js +++ b/packages/core/src/switch/proxy/impl/yarn-proxy.js @@ -29,11 +29,11 @@ class WindowsSystemProxy extends SystemProxy { ret = await winExec(`yarn config set https-proxy=http://${ip}:${port}`) console.log('yarn https proxy set success', ret) - // ret = await winExec(`yarn config set cafile ${config.getDefaultCAKeyPath()}`) - // console.log('yarn cafile set success', ret) + ret = await winExec(`yarn config set ca ${config.getDefaultCAKeyPath()}`) + console.log('yarn cafile set success', ret) - ret = await winExec('yarn config set strict-ssl false') - console.log('yarn strict-ssl false success', ret) + // ret = await winExec('yarn config set strict-ssl false') + // console.log('yarn strict-ssl false success', ret) } static async unsetProxy () { @@ -42,10 +42,11 @@ class WindowsSystemProxy extends SystemProxy { await winExec('yarn config delete https-proxy') console.log('yarn https proxy unset success') - await winExec('yarn config delete cafile') + await winExec('yarn config delete ca') console.log('yarn cafile unset success') - await winExec(' yarn config delete strict-ssl') - console.log('yarn strict-ssl true success') + + // await winExec(' yarn config delete strict-ssl') + // console.log('yarn strict-ssl true success') } static _asyncRegSet (regKey, name, type, value) { diff --git a/packages/gui/src/view/api.js b/packages/gui/src/view/api.js index d94f0742..331202fc 100644 --- a/packages/gui/src/view/api.js +++ b/packages/gui/src/view/api.js @@ -29,8 +29,9 @@ bindApi('server.close') bindApi('proxy.system.open') bindApi('proxy.system.close') - bindApi('proxy.npm.open') bindApi('proxy.npm.close') +bindApi('proxy.yarn.open') +bindApi('proxy.yarn.close') export default apiObj