From 7b19a01849cc008f650cb1154cf719b613a66f70 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Fri, 31 Oct 2025 14:14:00 +0800 Subject: [PATCH] =?UTF-8?q?chore(playground):=20adapter=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/src/main.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/playground/src/main.ts b/playground/src/main.ts index fc3d62c7..d2c5e1e4 100644 --- a/playground/src/main.ts +++ b/playground/src/main.ts @@ -24,15 +24,12 @@ import HtmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'; import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'; import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'; -import editorPlugin, { type DesignPluginOptions } from '@tmagic/editor'; -import MagicElementPlusAdapter from '@tmagic/element-plus-adapter'; -import MagicTdesignAdapter from '@tmagic/tdesign-vue-next-adapter'; +import editorPlugin from '@tmagic/editor'; import App from './App.vue'; import router from './route'; import 'element-plus/dist/index.css'; -import 'tdesign-vue-next/es/style/index.css'; import '@tmagic/editor/dist/style.css'; // @ts-ignore @@ -58,12 +55,19 @@ monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true); const adpter = sessionStorage.getItem('tmagic-playground-ui-adapter') || 'element-plus'; -const adpterMap: Record = { - 'element-plus': MagicElementPlusAdapter, - 'tdesign-vue-next': MagicTdesignAdapter, -}; +let adpterModule; -const app = createApp(App); -app.use(router); -app.use(editorPlugin, adpterMap[adpter] || MagicElementPlusAdapter); -app.mount('#app'); +if (adpter === 'tdesign-vue-next') { + import('tdesign-vue-next/es/style/index.css'); + adpterModule = import('@tmagic/tdesign-vue-next-adapter'); +} else { + import('element-plus/dist/index.css'); + adpterModule = import('@tmagic/element-plus-adapter'); +} + +adpterModule.then((module: any) => { + const app = createApp(App); + app.use(router); + app.use(editorPlugin, module.default); + app.mount('#app'); +});