From 79ce219c6c6e02554b02337449c1ba96587e6061 Mon Sep 17 00:00:00 2001 From: fofolee Date: Sun, 29 Dec 2024 09:18:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4runcode=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommandEditor.vue | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/components/CommandEditor.vue b/src/components/CommandEditor.vue index 6466f7d..eafc8e3 100644 --- a/src/components/CommandEditor.vue +++ b/src/components/CommandEditor.vue @@ -82,10 +82,25 @@ import CommandSideBar from "components/editor/CommandSideBar"; import CommandLanguageBar from "components/editor/CommandLanguageBar"; import EditorTools from "components/editor/EditorTools"; import CommandRunResult from "components/CommandRunResult"; + +// 预加载 MonacoEditor +const MonacoEditorPromise = import("components/editor/MonacoEditor"); +// 在空闲时预加载 +if (window.requestIdleCallback) { + window.requestIdleCallback(() => { + MonacoEditorPromise; + }); +} else { + setTimeout(() => { + MonacoEditorPromise; + }, 0); +} + // Performance Scripting > 500ms -const MonacoEditor = defineAsyncComponent(() => - import("components/editor/MonacoEditor") -); +const MonacoEditor = defineAsyncComponent({ + loader: () => MonacoEditorPromise, + timeout: 3000, +}); export default { components: { @@ -326,7 +341,7 @@ export default { } .command-editor-container.run-code { - animation: slideDownIn 0.2s cubic-bezier(0.4, 0, 0.2, 1); + animation: none; } .command-editor-container.leaving {