refactor: mirrors

pull/180/head
xiaojunnuo 2020-10-27 22:11:43 +08:00
parent aa4f029f62
commit 9b831d3322
5 changed files with 11 additions and 9 deletions

View File

@ -14,7 +14,7 @@
### 3、 github的源代码查看raw/blame查看
通过跳转到国内加速链接上
### 4、 Stack Overflow 加速
将ajax.google.com代理到加速代理上
将ajax.google.com代理到加速代理上 ,recaptcha 加速
### 5、 google cdn 加速
通过代理到加速链接上

View File

@ -34,11 +34,13 @@ const configApi = {
resetDefault () {
configTarget = lodash.cloneDeep(defConfig)
},
getMirrorEnv () {
const envMap = Shell.getEnv()
async getMirrorEnv () {
const envMap = await Shell.getEnv()
const list = []
const mirrors = configTarget.mirrors
console.log('envMap', envMap)
for (const key in mirrors) {
console.log('equale', key, envMap[key])
const exists = envMap[key] != null
list.push({
key,
@ -49,14 +51,14 @@ const configApi = {
console.log('mirrors:', list)
return list
},
setupMirrors () {
const list = configApi.getMirrorEnv()
async setupMirrors () {
const list = await configApi.getMirrorEnv()
const noSetList = list.filter(item => {
return !item.exists
})
console.log('mirrors will set:', noSetList)
if (list.length > 0) {
Shell.setEnv({ list: noSetList })
return Shell.setEnv({ list: noSetList })
}
}
}

View File

@ -1,6 +1,6 @@
const expose = require('./expose.js')
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
// 避免异常崩溃
process.on('uncaughtException', function (err) {

View File

@ -12,7 +12,7 @@ const executor = {
for (const item of lines) {
const kv = item.split('=')
if (kv.length > 1) {
map[kv[0]] = kv[1]
map[kv[0].trim()] = kv[1].trim()
}
}
}