Pre Merge pull request !199 from ly-chn/dev

This commit is contained in:
ly-chn 2023-08-16 09:39:53 +00:00 committed by Gitee
commit f05607b30e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 14 additions and 5 deletions

2
.gitignore vendored
View File

@ -3,4 +3,6 @@ node_modules
dist
dist-ssr
*.local
pnpm-lock.yaml
.vscode
.idea

View File

@ -26,6 +26,15 @@ export let packagesList: PackagesType = {
[PackagesCategoryEnum.ICONS]: IconList
}
// 组件缓存, 可以大幅度提升组件加载速度
const componentCacheMap = new Map<string, any>()
const loadComponent = (filename: string)=>{
if (!componentCacheMap.has(filename)) {
componentCacheMap.set(filename, import(filename))
}
return componentCacheMap.get(filename)
}
/**
* *
* @param targetData
@ -35,10 +44,10 @@ export const createComponent = async (targetData: ConfigType) => {
// redirectComponent 是给图片组件库和图标组件库使用的
if (redirectComponent) {
const [packageName, categoryName, keyName] = redirectComponent.split('/')
const redirectChart = await import(`./components/${packageName}/${categoryName}/${keyName}/config.ts`)
const redirectChart = await loadComponent(`./components/${packageName}/${categoryName}/${keyName}/config.ts`)
return new redirectChart.default()
}
const chart = await import(`./components/${targetData.package}/${category}/${key}/config.ts`)
const chart = await loadComponent(`./components/${targetData.package}/${category}/${key}/config.ts`)
return new chart.default()
}

View File

@ -196,9 +196,7 @@ export const useSync = () => {
chartHistoryStore.clearForwardStack()
}
}
} else {
// 非组件(顺便排除脏数据)
if (key !== 'editCanvasConfig' && key !== 'requestGlobalConfig') return
} else if (key === ChartEditStoreEnum.EDIT_CANVAS_CONFIG || key === ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG) {
componentMerge(chartEditStore[key], projectData[key], true)
}
}