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 @@