From 2e4ac605fa4b28d82a300e996dc444b291ec8f26 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 3 Dec 2024 11:13:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=A7=A3=E5=86=B3=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/plugin/src/index.vue | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/core/core-frontend/src/components/plugin/src/index.vue b/core/core-frontend/src/components/plugin/src/index.vue index 915304f1c8..5b56d5a364 100644 --- a/core/core-frontend/src/components/plugin/src/index.vue +++ b/core/core-frontend/src/components/plugin/src/index.vue @@ -108,7 +108,47 @@ defineExpose({ invokeMethod }) onMounted(async () => { - loadComponent() + const key = 'xpack-model-distributed' + let distributed = false + if (wsCache.get(key) === null) { + const res = await xpackModelApi() + const resData = isNull(res.data) ? 'null' : res.data + wsCache.set('xpack-model-distributed', resData) + distributed = res.data + } else { + distributed = wsCache.get(key) + } + if (isNull(distributed)) { + setTimeout(() => { + emits('loadFail') + loading.value = false + }, 1000) + return + } + if (distributed) { + if (window['DEXPack']) { + const xpack = await window['DEXPack'].mapping[attrs.jsname] + plugin.value = xpack.default + } else if (!window._de_xpack_not_loaded) { + window._de_xpack_not_loaded = true + window['VueDe'] = Vue + window['AxiosDe'] = axios + window['PiniaDe'] = Pinia + window['vueRouterDe'] = router + window['MittAllDe'] = useEmitt().emitter.all + window['I18nDe'] = i18n + window['EchartsDE'] = echarts + if (!window.tinymce) { + window.tinymce = tinymce + } + loadDistributed().then(async res => { + new Function(res.data)() + useEmitt().emitter.emit('load-xpack') + }) + } + } else { + loadComponent() + } })