From 94b19dce5d6c4265896ff5653fdc63867933824f Mon Sep 17 00:00:00 2001 From: fofolee Date: Sat, 9 Apr 2022 16:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=89=A7=E8=A1=8C=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=8A=9F=E8=83=BD=2080%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/preload.js | 36 ++++++------- src/components/CommandEditor.vue | 4 +- src/components/CommandRunResult.vue | 80 +++++++++++++++++++---------- src/js/options/outputTypes.js | 38 ++++++++++---- 4 files changed, 102 insertions(+), 56 deletions(-) diff --git a/public/preload.js b/public/preload.js index f1d6e74..003fe2b 100644 --- a/public/preload.js +++ b/public/preload.js @@ -195,22 +195,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline, } let getCommandToLaunchTerminal = (cmdline, dir) => { - let cd = '' - if (utools.isWindows()) { - let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/') - // 直接 existsSync wt.exe 无效 - if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) { - cmdline = cmdline.replace(/"/g, `\\"`) - if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"` - command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"` + let cd = '' + if (utools.isWindows()) { + let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/') + // 直接 existsSync wt.exe 无效 + if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) { + cmdline = cmdline.replace(/"/g, `\\"`) + if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"` + command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"` + } else { + cmdline = cmdline.replace(/"/g, `^"`) + if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&` + command = `${cd} start "" cmd /k "${cmdline}"` + } } else { - cmdline = cmdline.replace(/"/g, `^"`) - if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&` - command = `${cd} start "" cmd /k "${cmdline}"` - } - } else { - cmdline = cmdline.replace(/"/g, `\\"`) - if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&` + cmdline = cmdline.replace(/"/g, `\\"`) + if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&` if (fs.existsSync('/Applications/iTerm.app')) { command = `osascript -e 'tell application "iTerm" create window with default profile @@ -473,8 +473,8 @@ getNodeJsCommand = () => { return obj } -htmlEncode = (value, raw = true) => { - return raw ? String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/ { + return String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/ Buffer.from(text, 'utf8').toString('hex') @@ -690,4 +690,4 @@ runCodeFile = (cmd, option, terminal, callback) => { // let stderr = err_chunks.join(""); // callback(stdout, stderr) // }) -} +} \ No newline at end of file diff --git a/src/components/CommandEditor.vue b/src/components/CommandEditor.vue index 0d04d6f..42b5f25 100644 --- a/src/components/CommandEditor.vue +++ b/src/components/CommandEditor.vue @@ -352,7 +352,9 @@ export default { }, // 运行 runCurrentCommand() { - this.quickcommandInfo.output = this.$refs.menu?.currentCommand.output; + // 如果 action 是 run 则输出一律为 text + this.quickcommandInfo.output = + this.$refs.menu?.currentCommand.output || "text"; this.$refs.result.runCurrentCommand(this.quickcommandInfo); }, }, diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index d312962..397caec 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -1,6 +1,6 @@