From 0aac4efa1b2b7f864d62ed01322c4d7797256026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Tue, 9 Aug 2022 21:06:09 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=A4=84=E7=90=86=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E5=88=86=E7=BB=84=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chart/hooks/useSync.hook.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index fe58cb3a..3f782eb4 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -3,7 +3,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore import { ChartEditStoreEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index' -import { CreateComponentType } from '@/packages/index.d' +import { CreateComponentType, CreateComponentGroupType, ConfigType } from '@/packages/index.d' // 请求处理 export const useSync = () => { @@ -25,15 +25,18 @@ export const useSync = () => { chartHistoryStore.clearForwardStack() } // 列表组件注册 - projectData.componentList.forEach(async (e: CreateComponentType) => { - if (!window['$vue'].component(e.chartConfig.chartKey)) { + projectData.componentList.forEach(async (e: CreateComponentType | CreateComponentGroupType) => { + // 排除分组 + if (e.isGroup) return + const target = e as CreateComponentType + if (!window['$vue'].component(target.chartConfig.chartKey)) { window['$vue'].component( - e.chartConfig.chartKey, - fetchChartComponent(e.chartConfig) + target.chartConfig.chartKey, + fetchChartComponent(target.chartConfig) ) window['$vue'].component( - e.chartConfig.conKey, - fetchConfigComponent(e.chartConfig) + target.chartConfig.conKey, + fetchConfigComponent(target.chartConfig) ) } }) @@ -44,7 +47,7 @@ export const useSync = () => { for (const comItem of projectData[key]) { // 补充 class 上的方法 let newComponent: CreateComponentType = await createComponent( - comItem.chartConfig + comItem.chartConfig as ConfigType ) chartEditStore.addComponentList( Object.assign(newComponent, {...comItem, id: getUUID()}),