This commit is contained in:
fofolee 2020-06-26 12:41:01 +08:00
parent 38ef4c7d3d
commit 96454183ca

View File

@ -17,7 +17,7 @@ utools.onPluginEnter(async ({ code, type, payload }) => {
// 初始化 // 初始化
$("#options").empty() $("#options").empty()
$("#out").empty() $("#out").empty()
$("#quickselect").remove() $("[id^=quick").remove()
swal.close() swal.close()
if(handleEnter) document.removeEventListener('keydown', handleEnter) if(handleEnter) document.removeEventListener('keydown', handleEnter)
}) })
@ -102,22 +102,25 @@ let runQuickCommand = (cmd, option, output, autoScroll = false, autoHeight = tru
utools.hideMainWindow(); utools.hideMainWindow();
setTimeout(() => { utools.outPlugin(); }, 500); setTimeout(() => { utools.outPlugin(); }, 500);
} }
var outputOpts = { type: output, autoScroll: autoScroll, autoHeight: autoHeight }
if (option == "simulation") { if (option == "simulation") {
// 内置环境 // 内置环境
runCodeInVm(cmd, (stdout, stderr) => { runCodeInVm(cmd, (stdout, stderr) => {
if (cmd.includes("utools.setExpendHeight")) autoHeight = false if (cmd.includes("utools.setExpendHeight")) outputOpts.autoHeight = false
switchQuickCommandResult(stdout, stderr, output, autoScroll, autoHeight) switchQuickCommandResult(stdout, stderr, outputOpts)
}) })
} else { } else {
var terminal = output == 'terminal' ? true : false var terminal = output == 'terminal' ? true : false
outputOpts.scriptPath = getQuickCommandScriptFile(option.ext)
// 执行脚本 // 执行脚本
runCodeFile(cmd, option, terminal, (stdout, stderr) => { runCodeFile(cmd, option, terminal, (stdout, stderr) => {
switchQuickCommandResult(stdout, stderr, output, autoScroll, autoHeight) switchQuickCommandResult(stdout, stderr, outputOpts)
}) })
} }
} }
switchQuickCommandResult = (stdout, stderr, output, autoScroll, autoHeight) => { switchQuickCommandResult = (stdout, stderr, outputOpts) => {
var output = outputOpts.output, autoScroll = outputOpts.autoScroll, autoHeight = outputOpts.autoHeight;
var outputAutoFix = (autoScroll, autoHeight) => { var outputAutoFix = (autoScroll, autoHeight) => {
var outputHeight = $("#out").height() + 26 var outputHeight = $("#out").height() + 26
if (outputHeight > 600) outputHeight = 600 if (outputHeight > 600) outputHeight = 600
@ -136,10 +139,10 @@ switchQuickCommandResult = (stdout, stderr, output, autoScroll, autoHeight) => {
type: 'error', type: 'error',
title: '啊嘞?!', title: '啊嘞?!',
message: stderr, message: stderr,
buttons: ['转至脚本目录', '退出'] buttons: outputOpts.scriptPath ? ['转至脚本目录', '退出'] : ['退出']
}) })
if (index == 0) { if (outputOpts.scriptPath && index == 0) {
locate(getQuickCommandScriptFile(option.ext)); locate(outputOpts.scriptPath );
} }
copyTo(stderr); copyTo(stderr);
message("已复制报错信息"); message("已复制报错信息");