feat: 动态注册组件,优化首页出现性能

This commit is contained in:
MTrun
2022-02-25 22:10:18 +08:00
parent 4a76e419be
commit 0bf38c032c
5 changed files with 18 additions and 16 deletions
@@ -27,7 +27,7 @@
<script setup lang="ts">
import { AppleControlBtn } from '@/components/AppleControlBtn/index'
import { requireFallbackImg } from '@/utils'
import { requireFallbackImg, componentInstall } from '@/utils'
import { DragKeyEnum } from '@/enums/editPageEnum'
import { ConfigType } from '@/packages/index.d'
import omit from 'lodash/omit'
@@ -41,6 +41,7 @@ defineProps({
// 拖拽处理
const handleDragStart = (e: DragEvent, item: ConfigType) => {
componentInstall(item.key, item.node)
// 将配置项绑定到拖拽属性上
e!.dataTransfer!.setData(DragKeyEnum.DROG_KEY, JSON.stringify(omit(item, ['node', 'image'])))
}