diff --git a/package.json b/package.json index b50d922..346a8a0 100644 --- a/package.json +++ b/package.json @@ -4,5 +4,8 @@ "license": "MPL-2.0", "devDependencies": { "lerna": "^3.22.1" + }, + "dependencies": { + "sqlite3": "^5.0.0" } } diff --git a/packages/core/package-lock.json b/packages/core/package-lock.json index 82bfaa1..89eafb9 100644 --- a/packages/core/package-lock.json +++ b/packages/core/package-lock.json @@ -1795,7 +1795,6 @@ "thread-loader": "^2.1.3", "url-loader": "^2.2.0", "vue-loader": "^15.9.2", - "vue-loader-v16": "npm:vue-loader@^16.0.0-beta.7", "vue-style-loader": "^4.1.2", "webpack": "^4.0.0", "webpack-bundle-analyzer": "^3.8.0", @@ -12415,63 +12414,6 @@ } } }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.0.0-beta.9", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.9.tgz", - "integrity": "sha512-mu9pg6554GbXDSO8LlxkQM6qUJzUkb/A0FJc9LgRqnU9MCnhzEXwCt1Zx5NObvFpzs2mH2dH/uUCDwL8Qaz9sA==", - "dev": true, - "optional": true, - "requires": { - "chalk": "^4.1.0", - "hash-sum": "^2.0.0", - "loader-utils": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "optional": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "optional": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", - "dev": true, - "optional": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - } - } - } - }, "vue-style-loader": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz", diff --git a/packages/core/src/config.js b/packages/core/src/config.js index d4162e3..01ea17a 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -34,31 +34,29 @@ const configApi = { resetDefault () { configTarget = lodash.cloneDeep(defConfig) }, - async getMirrorEnv () { - const envMap = await Shell.getEnv() + async getVariables (type) { + const method = type === 'npm' ? Shell.getNpmEnv : Shell.getSystemEnv + const currentMap = await method() 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 + const map = configTarget.variables[type] + for (const key in map) { + const exists = currentMap[key] != null list.push({ key, - value: mirrors[key], + value: map[key], exists }) } - console.log('mirrors:', list) return list }, - async setupMirrors () { - const list = await configApi.getMirrorEnv() + async setVariables (type) { + const list = await configApi.getVariables(type) const noSetList = list.filter(item => { return !item.exists }) - console.log('mirrors will set:', noSetList) if (list.length > 0) { - return Shell.setEnv({ list: noSetList }) + const method = type === 'npm' ? Shell.setNpmEnv : Shell.setSystemEnv + return method({ list: noSetList }) } } } diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js index 36c9acb..b741115 100644 --- a/packages/core/src/config/index.js +++ b/packages/core/src/config/index.js @@ -82,6 +82,13 @@ module.exports = { { abort: true } + ], + // https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-win32-x64.tar.gz + '*.s3.amazonaws.com': [ + { + regexp: '/sqlite3/.*', + redirect: 'http://npm.taobao.org/mirrors' + } ] }, dns: { @@ -104,11 +111,18 @@ module.exports = { // "avatars*.githubusercontent.com": "usa" } }, - mirrors: { - SASS_BINARY_SITE: 'https://npm.taobao.org/mirrors/node-sass/', - PHANTOMJS_CDNURL: 'https://npm.taobao.org/mirrors/phantomjs/', - ELECTRON_MIRROR: 'https://npm.taobao.org/mirrors/electron/', - CYPRESS_DOWNLOAD_MIRROR: 'https://cdn.cypress.io' + variables: { + npm: { + SASS_BINARY_SITE: 'https://npm.taobao.org/mirrors/node-sass/', + PHANTOMJS_CDNURL: 'https://npm.taobao.org/mirrors/phantomjs/', + ELECTRON_MIRROR: 'https://npm.taobao.org/mirrors/electron/', + CYPRESS_DOWNLOAD_MIRROR: 'https://cdn.cypress.io', + NVM_NODEJS_ORG_MIRROR: 'http://npm.taobao.org/mirrors/node', + CHROMEDRIVER_CDNURL: 'http://npm.taobao.org/mirrors/chromedriver', + OPERADRIVER: 'http://npm.taobao.org/mirrors/operadriver', + ELECTRON_BUILDER_BINARIES_MIRROR: 'http://npm.taobao.org/mirrors/electron-builder-binaries/', + PYTHON_MIRROR: 'http://npm.taobao.org/mirrors/python' + } }, setting: { startup: { // 开机启动 @@ -118,8 +132,8 @@ module.exports = { npm: true, yarn: true }, - mirrors: { - set: true + variables: { + npm: true } } } diff --git a/packages/core/src/expose.js b/packages/core/src/expose.js index 2bcfdf3..844f407 100644 --- a/packages/core/src/expose.js +++ b/packages/core/src/expose.js @@ -36,8 +36,8 @@ module.exports = { } await proxyStartup({ ip: '127.0.0.1', port: config.get().server.port }) - if (startup.mirrors.set) { - await config.setupMirrors() + if (startup.variables.npm) { + await config.setVariables('npm') } } catch (error) { console.log(error) diff --git a/packages/core/src/shell/index.js b/packages/core/src/shell/index.js index 56c4713..009b33b 100644 --- a/packages/core/src/shell/index.js +++ b/packages/core/src/shell/index.js @@ -1,10 +1,14 @@ const killByPort = require('./scripts/kill-by-port') const setupCa = require('./scripts/setup-ca') -const getEnv = require('./scripts/get-env') -const setEnv = require('./scripts/set-env') +const getSystemEnv = require('./scripts/get-system-env') +const setSystemEnv = require('./scripts/set-system-env') +const getNpmEnv = require('./scripts/get-npm-env') +const setNpmEnv = require('./scripts/set-npm-env') module.exports = { killByPort, setupCa, - getEnv, - setEnv + getSystemEnv, + setSystemEnv, + getNpmEnv, + setNpmEnv } diff --git a/packages/core/src/shell/scripts/get-npm-env.js b/packages/core/src/shell/scripts/get-npm-env.js new file mode 100644 index 0000000..c6af3a6 --- /dev/null +++ b/packages/core/src/shell/scripts/get-npm-env.js @@ -0,0 +1,25 @@ +/** + * 获取环境变量 + */ +const Shell = require('../shell') +const execute = Shell.execute +const executor = { + async windows (exec) { + const ret = await exec(['npm config list --json'], { type: 'cmd' }) + if (ret != null) { + const json = ret.substring(ret.indexOf('{')) + return JSON.parse(json) + } + return {} + }, + async linux (exec, { port }) { + throw Error('暂未实现此功能') + }, + async mac (exec, { port }) { + throw Error('暂未实现此功能') + } +} + +module.exports = async function (args) { + return execute(executor, args) +} diff --git a/packages/core/src/shell/scripts/get-env.js b/packages/core/src/shell/scripts/get-system-env.js similarity index 100% rename from packages/core/src/shell/scripts/get-env.js rename to packages/core/src/shell/scripts/get-system-env.js diff --git a/packages/core/src/shell/scripts/set-npm-env.js b/packages/core/src/shell/scripts/set-npm-env.js new file mode 100644 index 0000000..daef7f8 --- /dev/null +++ b/packages/core/src/shell/scripts/set-npm-env.js @@ -0,0 +1,25 @@ +/** + * 设置环境变量 + */ +const Shell = require('../shell') +const execute = Shell.execute +const executor = { + async windows (exec, { list }) { + const cmds = [] + for (const item of list) { + cmds.push(`npm config set ${item.key} ${item.value}`) + } + const ret = await exec(cmds, { type: 'cmd' }) + return ret + }, + async linux (exec, { port }) { + throw Error('暂未实现此功能') + }, + async mac (exec, { port }) { + throw Error('暂未实现此功能') + } +} + +module.exports = async function (args) { + return execute(executor, args) +} diff --git a/packages/core/src/shell/scripts/set-env.js b/packages/core/src/shell/scripts/set-system-env.js similarity index 71% rename from packages/core/src/shell/scripts/set-env.js rename to packages/core/src/shell/scripts/set-system-env.js index f157d7f..37179ff 100644 --- a/packages/core/src/shell/scripts/set-env.js +++ b/packages/core/src/shell/scripts/set-system-env.js @@ -11,6 +11,14 @@ const executor = { cmds.push(`[Environment]::SetEnvironmentVariable('${item.key}', '${item.value}', 'Machine')`) } const ret = await exec(cmds, { type: 'ps' }) + + const cmds2 = [] + for (const item of list) { + // [Environment]::SetEnvironmentVariable('FOO', 'bar', 'Machine') + cmds2.push(`set ${item.key}=""`) + } + // eslint-disable-next-line no-unused-vars + const ret2 = await exec(cmds2, { type: 'cmd' }) return ret }, async linux (exec, { port }) { diff --git a/packages/core/src/shell/shell.js b/packages/core/src/shell/shell.js index 6c80563..2b0acb0 100644 --- a/packages/core/src/shell/shell.js +++ b/packages/core/src/shell/shell.js @@ -34,7 +34,8 @@ class DarwinSystemShell extends SystemShell { } class WindowsSystemShell extends SystemShell { - static async exec (cmds, { type = 'ps' }) { + static async exec (cmds, args = { type: 'ps' }) { + const { type } = args if (cmds instanceof String) { cmds = [cmds] } @@ -45,12 +46,11 @@ class WindowsSystemShell extends SystemShell { }) for (const cmd of cmds) { - console.log('ps:', cmd) ps.addCommand(cmd) } const ret = await ps.invoke() - console.log('ps complete:', ret) + console.log('ps complete:', cmds, ret) return ret } else { let compose = 'chcp 65001 ' diff --git a/packages/core/src/switch/proxy/impl/npm-proxy.js b/packages/core/src/switch/proxy/impl/npm-proxy.js index 8748f0a..ecf95e0 100644 --- a/packages/core/src/switch/proxy/impl/npm-proxy.js +++ b/packages/core/src/switch/proxy/impl/npm-proxy.js @@ -28,7 +28,7 @@ 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 ca ${config.getDefaultCAKeyPath()}`) + ret = await winExec(`npm config set ca ${config.getDefaultCACertPath()}`) console.log('npm cafile set success', ret) // ret = await winExec('npm config set strict-ssl false') diff --git a/packages/core/src/switch/proxy/impl/system-proxy.js b/packages/core/src/switch/proxy/impl/system-proxy.js index d18d490..76a03b2 100644 --- a/packages/core/src/switch/proxy/impl/system-proxy.js +++ b/packages/core/src/switch/proxy/impl/system-proxy.js @@ -4,7 +4,6 @@ const childProcess = require('child_process') const _exec = childProcess.exec const Registry = require('winreg') // const cmd = require('node-cmd') -console.log('childProcess', childProcess) const exec = util.promisify(_exec) const refreshInternetPs = require('./refresh-internet') const Shell = require('node-powershell') diff --git a/packages/core/src/switch/proxy/impl/yarn-proxy.js b/packages/core/src/switch/proxy/impl/yarn-proxy.js index 9dafd34..ebe493e 100644 --- a/packages/core/src/switch/proxy/impl/yarn-proxy.js +++ b/packages/core/src/switch/proxy/impl/yarn-proxy.js @@ -29,7 +29,7 @@ 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 ca ${config.getDefaultCAKeyPath()}`) + ret = await winExec(`yarn config set ca ${config.getDefaultCACertPath()}`) console.log('yarn cafile set success', ret) // ret = await winExec('yarn config set strict-ssl false') diff --git a/packages/gui/build/icons/1024x1024.png b/packages/gui/build/icons/1024x1024.png deleted file mode 100644 index dd5e84a..0000000 Binary files a/packages/gui/build/icons/1024x1024.png and /dev/null differ diff --git a/packages/gui/build/icons/128x128.png b/packages/gui/build/icons/128x128.png deleted file mode 100644 index 429bd4a..0000000 Binary files a/packages/gui/build/icons/128x128.png and /dev/null differ diff --git a/packages/gui/build/icons/16x16.png b/packages/gui/build/icons/16x16.png deleted file mode 100644 index c6326de..0000000 Binary files a/packages/gui/build/icons/16x16.png and /dev/null differ diff --git a/packages/gui/build/icons/24x24.png b/packages/gui/build/icons/24x24.png deleted file mode 100644 index d36fe0d..0000000 Binary files a/packages/gui/build/icons/24x24.png and /dev/null differ diff --git a/packages/gui/build/icons/256x256.png b/packages/gui/build/icons/256x256.png deleted file mode 100644 index 4faba19..0000000 Binary files a/packages/gui/build/icons/256x256.png and /dev/null differ diff --git a/packages/gui/build/icons/32x32.png b/packages/gui/build/icons/32x32.png deleted file mode 100644 index 3d6223b..0000000 Binary files a/packages/gui/build/icons/32x32.png and /dev/null differ diff --git a/packages/gui/build/icons/48x48.png b/packages/gui/build/icons/48x48.png deleted file mode 100644 index 2f12e03..0000000 Binary files a/packages/gui/build/icons/48x48.png and /dev/null differ diff --git a/packages/gui/build/icons/512x512.png b/packages/gui/build/icons/512x512.png deleted file mode 100644 index 8baf365..0000000 Binary files a/packages/gui/build/icons/512x512.png and /dev/null differ diff --git a/packages/gui/build/icons/64x64.png b/packages/gui/build/icons/64x64.png deleted file mode 100644 index 195211d..0000000 Binary files a/packages/gui/build/icons/64x64.png and /dev/null differ diff --git a/packages/gui/build/icons/icon.icns b/packages/gui/build/icons/icon.icns deleted file mode 100644 index 76a76c0..0000000 Binary files a/packages/gui/build/icons/icon.icns and /dev/null differ diff --git a/packages/gui/build/icons/icon.ico b/packages/gui/build/icons/icon.ico deleted file mode 100644 index 83bc44f..0000000 Binary files a/packages/gui/build/icons/icon.ico and /dev/null differ diff --git a/packages/gui/package-lock.json b/packages/gui/package-lock.json index 2ddf0fd..79dd1f8 100644 --- a/packages/gui/package-lock.json +++ b/packages/gui/package-lock.json @@ -2372,6 +2372,16 @@ "integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=", "dev": true }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-4.3.0.tgz?cache=0&sync_timestamp=1601839122515&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-4.3.0.tgz", + "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, "cacache": { "version": "13.0.1", "resolved": "https://registry.npm.taobao.org/cacache/download/cacache-13.0.1.tgz", @@ -2398,6 +2408,34 @@ "unique-filename": "^1.1.1" } }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npm.taobao.org/chalk/download/chalk-4.1.0.tgz", + "integrity": "sha1-ThSHCmGNni7dl92DRf2dncMVZGo=", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz", + "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npm.taobao.org/color-name/download/color-name-1.1.4.tgz", + "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", + "dev": true, + "optional": true + }, "find-cache-dir": { "version": "3.3.1", "resolved": "https://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-3.3.1.tgz", @@ -2419,6 +2457,25 @@ "path-exists": "^4.0.0" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npm.taobao.org/has-flag/download/has-flag-4.0.0.tgz", + "integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=", + "dev": true, + "optional": true + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npm.taobao.org/loader-utils/download/loader-utils-2.0.0.tgz", + "integrity": "sha1-5MrOW4FtQloWa18JfhDNErNgZLA=", + "dev": true, + "optional": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npm.taobao.org/locate-path/download/locate-path-5.0.0.tgz", @@ -2483,6 +2540,16 @@ "minipass": "^3.1.1" } }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npm.taobao.org/supports-color/download/supports-color-7.2.0.tgz?cache=0&sync_timestamp=1598611709087&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-7.2.0.tgz", + "integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=", + "dev": true, + "optional": true, + "requires": { + "has-flag": "^4.0.0" + } + }, "terser-webpack-plugin": { "version": "2.3.8", "resolved": "https://registry.npm.taobao.org/terser-webpack-plugin/download/terser-webpack-plugin-2.3.8.tgz?cache=0&sync_timestamp=1602701885709&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fterser-webpack-plugin%2Fdownload%2Fterser-webpack-plugin-2.3.8.tgz", @@ -2499,6 +2566,18 @@ "terser": "^4.6.12", "webpack-sources": "^1.4.3" } + }, + "vue-loader-v16": { + "version": "npm:vue-loader@16.0.0-beta.9", + "resolved": "https://registry.npm.taobao.org/vue-loader/download/vue-loader-16.0.0-beta.9.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-loader%2Fdownload%2Fvue-loader-16.0.0-beta.9.tgz", + "integrity": "sha1-UlEsthwpaCfJnA1UOYvvhL5ESPw=", + "dev": true, + "optional": true, + "requires": { + "chalk": "^4.1.0", + "hash-sum": "^2.0.0", + "loader-utils": "^2.0.0" + } } } }, @@ -16335,87 +16414,6 @@ } } }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.0.0-beta.8", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.8.tgz", - "integrity": "sha512-oouKUQWWHbSihqSD7mhymGPX1OQ4hedzAHyvm8RdyHh6m3oIvoRF+NM45i/bhNOlo8jCnuJhaSUf/6oDjv978g==", - "dev": true, - "optional": true, - "requires": { - "chalk": "^4.1.0", - "hash-sum": "^2.0.0", - "loader-utils": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "optional": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "optional": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "optional": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "optional": true - }, - "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", - "dev": true, - "optional": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "optional": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "vue-ref": { "version": "2.0.0", "resolved": "https://registry.npm.taobao.org/vue-ref/download/vue-ref-2.0.0.tgz", diff --git a/packages/gui/src/bridge/index.js b/packages/gui/src/bridge/index.js index 3cdb9d9..64bed2d 100644 --- a/packages/gui/src/bridge/index.js +++ b/packages/gui/src/bridge/index.js @@ -97,7 +97,6 @@ function _mergeConfig (defObj, newObj) { delete newObj[key] } } - console.log('newObj', newObj) return newObj } diff --git a/packages/gui/src/config.js b/packages/gui/src/config.js deleted file mode 100644 index 7ccb2a6..0000000 --- a/packages/gui/src/config.js +++ /dev/null @@ -1,2 +0,0 @@ -import config from '../../../config/index.json5' -export default config diff --git a/packages/gui/src/view/components/settings.vue b/packages/gui/src/view/components/settings.vue index ad53db9..5a5955b 100644 --- a/packages/gui/src/view/components/settings.vue +++ b/packages/gui/src/view/components/settings.vue @@ -17,19 +17,24 @@ :style="{ height: '100%' }" > - +
某些域名有时候需要通过其他DNS服务器获取到的IP才可以访问
+ + + + + - USA - Aliyun + USA DNS + Aliyun DNS @@ -37,28 +42,24 @@ - - - - - +
- +
-
某些库需要自己设置代理环境变量,才能安装,比如: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 }) } } }