fix: 执行命令返回乱码的bug
parent
be5d04827a
commit
15808f78bb
|
@ -1,6 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'Git.exe代理',
|
name: 'Git.exe代理',
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
tip: '没有安装git.exe,不需要启动',
|
||||||
setting: {
|
setting: {
|
||||||
sslVerify: true // 是否关闭sslVerify
|
sslVerify: true // 是否关闭sslVerify
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'NPM加速',
|
name: 'NPM加速',
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
tip: '没有安装nodejs,不需要启动',
|
||||||
startup: {
|
startup: {
|
||||||
variables: true
|
variables: true
|
||||||
},
|
},
|
||||||
|
|
|
@ -119,8 +119,8 @@ const NodePlugin = function (context) {
|
||||||
|
|
||||||
async setProxy (ip, port) {
|
async setProxy (ip, port) {
|
||||||
const cmds = [
|
const cmds = [
|
||||||
`npm config set proxy=http://${ip}:${port}`,
|
`npm1 config set proxy=http://${ip}:${port}`,
|
||||||
`npm config set https-proxy=http://${ip}:${port}`
|
`npm1 config set https-proxy=http://${ip}:${port}`
|
||||||
]
|
]
|
||||||
|
|
||||||
const env = []
|
const env = []
|
||||||
|
|
|
@ -7,6 +7,7 @@ const exec = util.promisify(_exec)
|
||||||
const PowerShell = require('node-powershell')
|
const PowerShell = require('node-powershell')
|
||||||
const log = require('../utils/util.log')
|
const log = require('../utils/util.log')
|
||||||
const fixPath = require('fix-path')
|
const fixPath = require('fix-path')
|
||||||
|
const iconv = require('iconv-lite')
|
||||||
fixPath()
|
fixPath()
|
||||||
class SystemShell {
|
class SystemShell {
|
||||||
static async exec (cmds, args) {
|
static async exec (cmds, args) {
|
||||||
|
@ -63,7 +64,7 @@ class WindowsSystemShell extends SystemShell {
|
||||||
ps.dispose()
|
ps.dispose()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let compose = 'chcp 65001 '
|
let compose = 'echo "test" ' // 'chcp 65001 '
|
||||||
for (const cmd of cmds) {
|
for (const cmd of cmds) {
|
||||||
compose += ' && ' + cmd
|
compose += ' && ' + cmd
|
||||||
}
|
}
|
||||||
|
@ -77,14 +78,21 @@ class WindowsSystemShell extends SystemShell {
|
||||||
|
|
||||||
function childExec (composeCmds) {
|
function childExec (composeCmds) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
var encoding = 'cp936'
|
||||||
|
var binaryEncoding = 'binary'
|
||||||
|
|
||||||
const childProcess = require('child_process')
|
const childProcess = require('child_process')
|
||||||
childProcess.exec(composeCmds, function (error, stdout, stderr) {
|
childProcess.exec(composeCmds, { encoding: binaryEncoding }, function (error, stdout, stderr) {
|
||||||
if (error) {
|
if (error) {
|
||||||
log.error('cmd 命令执行错误:', composeCmds, error, stderr)
|
// console.log('------', decoder.decode(stderr))
|
||||||
reject(error)
|
const message = iconv.decode(Buffer.from(stderr, binaryEncoding), encoding)
|
||||||
|
log.error('cmd 命令执行错误:', composeCmds, message)
|
||||||
|
reject(new Error(message))
|
||||||
} else {
|
} else {
|
||||||
// log.info('cmd 命令完成:', stdout)
|
// log.info('cmd 命令完成:', stdout)
|
||||||
resolve(stdout)
|
const message = iconv.decode(Buffer.from(stdout, binaryEncoding), encoding)
|
||||||
|
resolve(message)
|
||||||
}
|
}
|
||||||
// log.info('关闭 cmd')
|
// log.info('关闭 cmd')
|
||||||
// ps.kill('SIGINT')
|
// ps.kill('SIGINT')
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
"electron-updater": "^4.3.5",
|
"electron-updater": "^4.3.5",
|
||||||
"es-abstract": "^1.17.7",
|
"es-abstract": "^1.17.7",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
|
"iconv-lite": "^0.6.2",
|
||||||
"json5": "^2.1.3",
|
"json5": "^2.1.3",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"log4js": "^6.3.0",
|
"log4js": "^6.3.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
function install (app, api) {
|
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) => {
|
api.ipc.on('update', (event, message) => {
|
||||||
console.log('on message', event, message)
|
console.log('on message', event, message)
|
||||||
handleUpdateMessage(message, app)
|
handleUpdateMessage(message, app)
|
||||||
|
|
|
@ -54,10 +54,12 @@
|
||||||
<a-form style="margin-top:20px" :label-col="{ span: 12 }" :wrapper-col="{ span: 12 }">
|
<a-form style="margin-top:20px" :label-col="{ span: 12 }" :wrapper-col="{ span: 12 }">
|
||||||
|
|
||||||
<a-form-item v-for=" (item, key) in switchBtns" :key="key" :label="item.label">
|
<a-form-item v-for=" (item, key) in switchBtns" :key="key" :label="item.label">
|
||||||
<a-switch style="margin-left:10px" :loading="item.loading" :checked="item.status()" default-checked @change="item.doClick">
|
<a-tooltip placement="topLeft" :title="item.tip">
|
||||||
<a-icon slot="checkedChildren" type="check"/>
|
<a-switch style="margin-left:10px" :loading="item.loading" :checked="item.status()" default-checked @change="item.doClick">
|
||||||
<a-icon slot="unCheckedChildren" type="close"/>
|
<a-icon slot="checkedChildren" type="check"/>
|
||||||
</a-switch>
|
<a-icon slot="unCheckedChildren" type="close"/>
|
||||||
|
</a-switch>
|
||||||
|
</a-tooltip>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,7 +78,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a-modal title="捐赠" v-model="donateModal" width="550px" cancelText="不了" okText="支持一下" @ok="goDonate">
|
<a-modal title="捐赠" v-model="donateModal" width="550px" cancelText="不了" okText="果断支持" @ok="goDonate">
|
||||||
<div>* 如果觉得好用,请给我一点鼓励,感谢。</div>
|
<div>* 如果觉得好用,请给我一点鼓励,感谢。</div>
|
||||||
<div class="payQrcode">
|
<div class="payQrcode">
|
||||||
<img height="200px" src="/pay.jpg"/>
|
<img height="200px" src="/pay.jpg"/>
|
||||||
|
@ -246,15 +248,16 @@ export default {
|
||||||
btns.server = this.createSwitchBtn('server', '代理服务', this.$api.server, status)
|
btns.server = this.createSwitchBtn('server', '代理服务', this.$api.server, status)
|
||||||
btns.proxy = this.createSwitchBtn('proxy', '系统代理', this.$api.proxy, status)
|
btns.proxy = this.createSwitchBtn('proxy', '系统代理', this.$api.proxy, status)
|
||||||
lodash.forEach(status.plugin, (item, key) => {
|
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
|
return btns
|
||||||
},
|
},
|
||||||
createSwitchBtn (key, label, apiTarget, statusParent) {
|
createSwitchBtn (key, label, apiTarget, statusParent, tip) {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
key: key,
|
key,
|
||||||
label: label,
|
label,
|
||||||
|
tip,
|
||||||
status: () => {
|
status: () => {
|
||||||
return statusParent[key].enabled
|
return statusParent[key].enabled
|
||||||
},
|
},
|
||||||
|
|
|
@ -6237,8 +6237,8 @@ iconv-lite@^0.5.0:
|
||||||
|
|
||||||
iconv-lite@^0.6.2:
|
iconv-lite@^0.6.2:
|
||||||
version "0.6.2"
|
version "0.6.2"
|
||||||
resolved "https://registry.npm.taobao.org/iconv-lite/download/iconv-lite-0.6.2.tgz"
|
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01"
|
||||||
integrity sha1-zhPRh1sMOmdL1qBLf3awGxtt7QE=
|
integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
safer-buffer ">= 2.1.2 < 3.0.0"
|
safer-buffer ">= 2.1.2 < 3.0.0"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue