fix: 解决导入时顺序不对的问题

This commit is contained in:
奔跑的面条 2022-10-14 14:33:14 +08:00
parent e6b7a868a2
commit 5a981109de

View File

@ -66,12 +66,8 @@ export const useSync = () => {
intComponent(e as CreateComponentType) intComponent(e as CreateComponentType)
} }
}) })
// 数据赋值
for (const key in projectData) { // 创建函数-重新创建是为了处理类种方法消失的问题
// 组件
if (key === ChartEditStoreEnum.COMPONENT_LIST) {
for (const comItem of projectData[key]) {
// 重新创建是为了处理类种方法消失的问题
const create = async ( const create = async (
_componentInstance: CreateComponentType, _componentInstance: CreateComponentType,
callBack?: (componentInstance: CreateComponentType) => void callBack?: (componentInstance: CreateComponentType) => void
@ -97,6 +93,11 @@ export const useSync = () => {
} }
} }
// 数据赋值
for (const key in projectData) {
// 组件
if (key === ChartEditStoreEnum.COMPONENT_LIST) {
for (const comItem of projectData[key]) {
if (comItem.isGroup) { if (comItem.isGroup) {
// 创建分组 // 创建分组
let groupClass = new PublicGroupConfigClass() let groupClass = new PublicGroupConfigClass()
@ -106,19 +107,19 @@ export const useSync = () => {
groupClass = componentMerge(groupClass, comItem) groupClass = componentMerge(groupClass, comItem)
} }
// 注册子应用 // 异步注册子应用
const targetList: CreateComponentType[] = [] const targetList: CreateComponentType[] = []
;(comItem as CreateComponentGroupType).groupList.forEach(groupItem => { for (const groupItem of (comItem as CreateComponentGroupType).groupList) {
create(groupItem, e => { await create(groupItem, e => {
targetList.push(e) targetList.push(e)
}) })
}) }
groupClass.groupList = targetList groupClass.groupList = targetList
// 分组插入到列表 // 分组插入到列表
chartEditStore.addComponentList(groupClass, false, true) chartEditStore.addComponentList(groupClass, false, true)
} else { } else {
create(comItem as CreateComponentType) await create(comItem as CreateComponentType)
} }
} }
} else { } else {