diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index 48cb926..f2ace12 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -16,45 +16,26 @@ > - - -

-          
+
- -

+      
     
@@ -64,30 +45,10 @@ import outputTypes from "../js/options/outputTypes.js"; import specialVars from "../js/options/specialVars.js"; import commandTypes from "../js/options/commandTypes.js"; - -const frameStyle = ` -`; +import ResultArea from "components/ResultArea.vue"; export default { + components: { ResultArea }, data() { return { isResultShow: false, @@ -97,9 +58,7 @@ export default { listener: null, history: [], historyIdx: null, - htmlOutput: false, - frameHeight: 0, - frameStyle: frameStyle, + enableHtml: false, }; }, props: { @@ -133,7 +92,7 @@ export default { }, async fire(currentCommand) { currentCommand.cmd = this.assignSpecialVars(currentCommand.cmd); - this.htmlOutput = currentCommand.output === "html"; + this.enableHtml = currentCommand.output === "html"; let { hideWindow, outPlugin, action } = outputTypes[currentCommand.output]; // 需要隐藏的提前隐藏窗口 @@ -246,7 +205,6 @@ export default { // 显示运行结果 showRunResult(content, isSuccess, action) { this.isResultShow = true; - this.frameInit(); this.runResultStatus = isSuccess; let contlength = content?.length || 0; if (contlength > this.resultMaxLength) @@ -258,11 +216,10 @@ export default { content.slice(contlength - 100); let pretreatment = action(content); pretreatment && (this.runResult += pretreatment); - this.outputAutoHeight(); + this.outputAutoHeight(this.fromUtools); }, // 根据输出自动滚动及调整 utools 高度 - outputAutoHeight(autoScroll = true, autoHeight = true) { - if (!this.fromUtools) return; + outputAutoHeight(autoHeight = true, autoScroll = true) { this.$nextTick(() => { let clientHeight = document.body.clientHeight; let pluginHeight = @@ -284,44 +241,9 @@ export default { document.removeEventListener("keydown", this.listener, true); } }, - // 初始化时覆盖变量 - frameInit() { - this.$nextTick(() => { - let cfw = this.$refs?.iframe?.contentWindow; - if (!cfw) return; - let ctx = { - quickcommand, - utools, - parent: undefined, - }; - Object.assign(cfw, _.cloneDeep(ctx)); - }); - }, - // 加载时更改样式 - frameLoad() { - let cfw = this.$refs?.iframe?.contentWindow; - this.frameHeight = Math.min( - cfw.document.body.scrollHeight, - this.maxHeight - ); - this.outputAutoHeight(); - }, }, unmounted() { this.stopRun(); }, }; - - diff --git a/src/components/ResultArea.vue b/src/components/ResultArea.vue new file mode 100644 index 0000000..55efd9d --- /dev/null +++ b/src/components/ResultArea.vue @@ -0,0 +1,102 @@ + + + + +