diff --git a/src/pages/CodeRunner.vue b/src/pages/CodeRunner.vue index ccba805..2ef8249 100644 --- a/src/pages/CodeRunner.vue +++ b/src/pages/CodeRunner.vue @@ -100,8 +100,23 @@ + + + + + 运行结果 + - +

         
@@ -129,6 +144,8 @@ export default { output: "", isResultShow: false, runResult: "", + runResultStatus: true, + resultMaxLength: 10000, }; }, mounted() { @@ -216,7 +233,7 @@ export default { }); } else { let option = globalVars.programs[this.program]; - if (program === "custom") + if (this.program === "custom") option = { bin: this.customOptions.bin, argv: this.customOptions.argv, @@ -259,9 +276,18 @@ export default { }); return cmd; }, - showRunResult(content, raw, success) { + showRunResult(content, raw, isSuccess) { this.isResultShow = true; - this.runResult += content; + this.runResultStatus = isSuccess; + let contlength = content.length; + if (contlength > this.resultMaxLength) + content = + content.slice(0, this.resultMaxLength - 100) + + `\n\n...\n${ + contlength - this.resultMaxLength - 100 + } 字省略\n...\n\n` + + content.slice(contlength - 100); + this.runResult += htmlEncode(content, raw); }, }, };