fix(embed): auto-install element-plus and include theme css in lib entry

This commit is contained in:
2026-02-25 00:07:45 +08:00
parent 1173201c30
commit 2e305f889e
2 changed files with 22 additions and 1 deletions

View File

@@ -38,7 +38,8 @@
</template>
<script setup lang="ts">
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick, getCurrentInstance } from 'vue'
import ElementPlus from 'element-plus'
import { createPinia, setActivePinia } from 'pinia'
import LogicFlow from '@logicflow/core'
import '@logicflow/core/lib/style/index.css'
@@ -129,6 +130,24 @@ const emit = defineEmits<{
const localPinia = createPinia()
setActivePinia(localPinia)
const ensureElementPlusInstalled = () => {
const instance = getCurrentInstance()
const app = instance?.appContext?.app as any
if (!app) return
const installedPlugins = app._context?.plugins
if (installedPlugins?.has?.(ElementPlus)) {
return
}
try {
app.use(ElementPlus)
} catch {
// 忽略重复安装或宿主限制导致的异常
}
}
ensureElementPlusInstalled()
// Refs
const flowEditorRef = ref<InstanceType<typeof FlowEditor>>()
const previewContainerRef = ref<HTMLElement | null>(null)

View File

@@ -1,4 +1,6 @@
// 库入口文件
import 'element-plus/dist/index.css'
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
import YysEditorEmbed from './YysEditorEmbed.vue'
// 导出组件