From 15808f78bbde3cfc18ae63f7e46dd9b99ca37a51 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sun, 4 Apr 2021 09:58:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=A7=E8=A1=8C=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B9=B1=E7=A0=81=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/src/modules/plugin/git/config.js | 1 + .../core/src/modules/plugin/node/config.js | 1 + .../core/src/modules/plugin/node/index.js | 4 ++-- packages/core/src/shell/shell.js | 18 +++++++++++----- packages/gui/package.json | 1 + packages/gui/src/bridge/update/front.js | 2 +- packages/gui/src/view/pages/index.vue | 21 +++++++++++-------- packages/gui/yarn.lock | 4 ++-- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/packages/core/src/modules/plugin/git/config.js b/packages/core/src/modules/plugin/git/config.js index 04e0a9d..c724ed3 100644 --- a/packages/core/src/modules/plugin/git/config.js +++ b/packages/core/src/modules/plugin/git/config.js @@ -1,6 +1,7 @@ module.exports = { name: 'Git.exe代理', enabled: false, + tip: '没有安装git.exe,不需要启动', setting: { sslVerify: true // 是否关闭sslVerify } diff --git a/packages/core/src/modules/plugin/node/config.js b/packages/core/src/modules/plugin/node/config.js index f00e687..fc76a10 100644 --- a/packages/core/src/modules/plugin/node/config.js +++ b/packages/core/src/modules/plugin/node/config.js @@ -1,6 +1,7 @@ module.exports = { name: 'NPM加速', enabled: false, + tip: '没有安装nodejs,不需要启动', startup: { variables: true }, diff --git a/packages/core/src/modules/plugin/node/index.js b/packages/core/src/modules/plugin/node/index.js index 2380b03..1df36b0 100644 --- a/packages/core/src/modules/plugin/node/index.js +++ b/packages/core/src/modules/plugin/node/index.js @@ -119,8 +119,8 @@ const NodePlugin = function (context) { async setProxy (ip, port) { const cmds = [ - `npm config set proxy=http://${ip}:${port}`, - `npm config set https-proxy=http://${ip}:${port}` + `npm1 config set proxy=http://${ip}:${port}`, + `npm1 config set https-proxy=http://${ip}:${port}` ] const env = [] diff --git a/packages/core/src/shell/shell.js b/packages/core/src/shell/shell.js index 7ae7adc..7303733 100644 --- a/packages/core/src/shell/shell.js +++ b/packages/core/src/shell/shell.js @@ -7,6 +7,7 @@ const exec = util.promisify(_exec) const PowerShell = require('node-powershell') const log = require('../utils/util.log') const fixPath = require('fix-path') +const iconv = require('iconv-lite') fixPath() class SystemShell { static async exec (cmds, args) { @@ -63,7 +64,7 @@ class WindowsSystemShell extends SystemShell { ps.dispose() } } else { - let compose = 'chcp 65001 ' + let compose = 'echo "test" ' // 'chcp 65001 ' for (const cmd of cmds) { compose += ' && ' + cmd } @@ -77,14 +78,21 @@ class WindowsSystemShell extends SystemShell { function childExec (composeCmds) { return new Promise((resolve, reject) => { + + var encoding = 'cp936' + var binaryEncoding = 'binary' + const childProcess = require('child_process') - childProcess.exec(composeCmds, function (error, stdout, stderr) { + childProcess.exec(composeCmds, { encoding: binaryEncoding }, function (error, stdout, stderr) { if (error) { - log.error('cmd 命令执行错误:', composeCmds, error, stderr) - reject(error) + // console.log('------', decoder.decode(stderr)) + const message = iconv.decode(Buffer.from(stderr, binaryEncoding), encoding) + log.error('cmd 命令执行错误:', composeCmds, message) + reject(new Error(message)) } else { // log.info('cmd 命令完成:', stdout) - resolve(stdout) + const message = iconv.decode(Buffer.from(stdout, binaryEncoding), encoding) + resolve(message) } // log.info('关闭 cmd') // ps.kill('SIGINT') diff --git a/packages/gui/package.json b/packages/gui/package.json index 0c1d3d4..490e28c 100644 --- a/packages/gui/package.json +++ b/packages/gui/package.json @@ -28,6 +28,7 @@ "electron-updater": "^4.3.5", "es-abstract": "^1.17.7", "extract-zip": "^2.0.1", + "iconv-lite": "^0.6.2", "json5": "^2.1.3", "lodash": "^4.17.20", "log4js": "^6.3.0", diff --git a/packages/gui/src/bridge/update/front.js b/packages/gui/src/bridge/update/front.js index 228543d..8f7f319 100644 --- a/packages/gui/src/bridge/update/front.js +++ b/packages/gui/src/bridge/update/front.js @@ -1,6 +1,6 @@ function install (app, api) { - const updateParams = app.$global.update = { fromUser: false, autoDownload: true, progress: 0, downloading: false, newVersion: false, isFullUpdate: true } + const updateParams = app.$global.update = { fromUser: false, autoDownload: false, progress: 0, downloading: false, newVersion: false, isFullUpdate: true } api.ipc.on('update', (event, message) => { console.log('on message', event, message) handleUpdateMessage(message, app) diff --git a/packages/gui/src/view/pages/index.vue b/packages/gui/src/view/pages/index.vue index 0a15b43..9963ff9 100644 --- a/packages/gui/src/view/pages/index.vue +++ b/packages/gui/src/view/pages/index.vue @@ -54,10 +54,12 @@ - - - - + + + + + + @@ -76,7 +78,7 @@ - +
* 如果觉得好用,请给我一点鼓励,感谢。
@@ -246,15 +248,16 @@ export default { btns.server = this.createSwitchBtn('server', '代理服务', this.$api.server, status) btns.proxy = this.createSwitchBtn('proxy', '系统代理', this.$api.proxy, status) lodash.forEach(status.plugin, (item, key) => { - btns[key] = this.createSwitchBtn(key, this.config.plugin[key].name, this.$api.plugin[key], status.plugin) + btns[key] = this.createSwitchBtn(key, this.config.plugin[key].name, this.$api.plugin[key], status.plugin, this.config.plugin[key].tip) }) return btns }, - createSwitchBtn (key, label, apiTarget, statusParent) { + createSwitchBtn (key, label, apiTarget, statusParent, tip) { return { loading: false, - key: key, - label: label, + key, + label, + tip, status: () => { return statusParent[key].enabled }, diff --git a/packages/gui/yarn.lock b/packages/gui/yarn.lock index bea652d..c695155 100644 --- a/packages/gui/yarn.lock +++ b/packages/gui/yarn.lock @@ -6237,8 +6237,8 @@ iconv-lite@^0.5.0: iconv-lite@^0.6.2: version "0.6.2" - resolved "https://registry.npm.taobao.org/iconv-lite/download/iconv-lite-0.6.2.tgz" - integrity sha1-zhPRh1sMOmdL1qBLf3awGxtt7QE= + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01" + integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ== dependencies: safer-buffer ">= 2.1.2 < 3.0.0"