mirror of
https://github.com/Powerful-517/yys-editor.git
synced 2026-03-05 15:05:27 +00:00
fix(embed): auto-install element-plus and include theme css in lib entry
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// 库入口文件
|
||||
import 'element-plus/dist/index.css'
|
||||
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
|
||||
import YysEditorEmbed from './YysEditorEmbed.vue'
|
||||
|
||||
// 导出组件
|
||||
|
||||
Reference in New Issue
Block a user