diff --git a/plugin/preload.js b/plugin/preload.js index 53460f6..d5ce128 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -179,6 +179,9 @@ window.runCodeInSandbox = (code, callback, addVars = {}) => { error: (...stderr) => { callback(null, stderr); }, + clear: () => { + callback({ __clearQuickcommandRunResult: true }, null); + }, }; let sandboxWithAD = Object.assign(addVars, sandbox); sandboxWithAD.quickcommand = window.lodashM.cloneDeep(quickcommand); diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index f94bf38..a8c5856 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -301,9 +301,13 @@ export default { }, // 显示运行结果 async showRunResult(content, isSuccess) { - content = await this.handleContent(content); + if (content.__clearQuickcommandRunResult) { + this.runResult = []; + } else { + content = await this.handleContent(content); + this.runResult = this.runResult.concat(content); + } this.runResultStatus = isSuccess; - this.runResult = this.runResult.concat(content); // 刷新组件 this.isResultShow ? (this.timeStamp = new Date().getTime()) diff --git a/src/plugins/monaco/types/common.d.ts b/src/plugins/monaco/types/common.d.ts index e254b83..26864a8 100644 --- a/src/plugins/monaco/types/common.d.ts +++ b/src/plugins/monaco/types/common.d.ts @@ -86,7 +86,8 @@ declare function fetch( // console declare var console: { log(message?: any): void, - error(message?: any): void + error(message?: any): void, + clear(): void, } declare var setTimeout: (callback: () => void, ms: number) => number;