fix: 执行命令返回乱码的bug
parent
be5d04827a
commit
15808f78bb
|
@ -1,6 +1,7 @@
|
|||
module.exports = {
|
||||
name: 'Git.exe代理',
|
||||
enabled: false,
|
||||
tip: '没有安装git.exe,不需要启动',
|
||||
setting: {
|
||||
sslVerify: true // 是否关闭sslVerify
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module.exports = {
|
||||
name: 'NPM加速',
|
||||
enabled: false,
|
||||
tip: '没有安装nodejs,不需要启动',
|
||||
startup: {
|
||||
variables: true
|
||||
},
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -54,10 +54,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-switch style="margin-left:10px" :loading="item.loading" :checked="item.status()" default-checked @change="item.doClick">
|
||||
<a-icon slot="checkedChildren" type="check"/>
|
||||
<a-icon slot="unCheckedChildren" type="close"/>
|
||||
</a-switch>
|
||||
<a-tooltip placement="topLeft" :title="item.tip">
|
||||
<a-switch style="margin-left:10px" :loading="item.loading" :checked="item.status()" default-checked @change="item.doClick">
|
||||
<a-icon slot="checkedChildren" type="check"/>
|
||||
<a-icon slot="unCheckedChildren" type="close"/>
|
||||
</a-switch>
|
||||
</a-tooltip>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
|
@ -76,7 +78,7 @@
|
|||
</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 class="payQrcode">
|
||||
<img height="200px" src="/pay.jpg"/>
|
||||
|
@ -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
|
||||
},
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue