-
某些库需要自己设置代理环境变量,才能安装,比如:electron
+
某些库需要自己设置镜像变量,才能下载,比如:electron
-
+
启动后自动检查设置
- 立即设置
+ 立即设置
-
+
@@ -121,7 +122,7 @@ export default {
return {
targetConfig: {},
dnsMappings: [],
- mirrorEnvs: []
+ npmVariables: []
}
},
created () {
@@ -139,8 +140,8 @@ export default {
})
}
- api.config.getMirrorEnv().then(ret => {
- this.mirrorEnvs = ret
+ api.config.getVariables('npm').then(ret => {
+ this.npmVariables = ret
})
},
onJsonChange (config) {
@@ -159,6 +160,8 @@ export default {
this.$confirm({
title: '提示',
content: '是否需要保存?',
+ cancelText: '取消',
+ okText: '确定',
onOk: () => {
this.doSave()
},
@@ -175,11 +178,11 @@ export default {
}
this.targetConfig.dns.mapping = mapping
- const mirrors = {}
- for (const item of this.mirrorEnvs) {
- mirrors[item.key] = item.value
+ const variables = {}
+ for (const item of this.npmVariables) {
+ variables[item.key] = item.value
}
- this.targetConfig.mirrors = mirrors
+ this.targetConfig.variables.npm = variables
},
isChanged () {
this.syncTargetConfig()
@@ -197,22 +200,22 @@ export default {
},
addDnsMapping () {
- this.dnsMappings.push({ key: '', value: 'usa' })
+ this.dnsMappings.unshift({ key: '', value: 'usa' })
},
- doSetMirrorEnvNow () {
+ doSetNpmVariablesNow () {
this.syncTargetConfig()
this.doSave().then(() => {
- return api.config.setupMirrors()
+ return api.config.setVariables('npm')
}).then(() => {
- return api.config.getMirrorEnv().then(ret => {
- this.mirrorEnvs = ret
+ return api.config.getVariables('npm').then(ret => {
+ this.npmVariables = ret
})
}).then(() => {
this.$message.info('设置成功')
})
},
- addMirrors () {
- this.mirrorEnvs.push({ key: '', value: '', exists: false })
+ addNpmVariable () {
+ this.npmVariables.push({ key: '', value: '', exists: false })
}
}
}