fix: 解决首页注册组件的bug

This commit is contained in:
MTrun 2022-03-07 12:51:50 +08:00
parent e6a99302d6
commit 5b14e3a70f
2 changed files with 4 additions and 1 deletions

View File

@ -10,8 +10,9 @@ import { CreateComponentType } from '@/packages/index.d'
* @param app * @param app
*/ */
export const setupPreviewPackages = (app: App) => { export const setupPreviewPackages = (app: App) => {
if(!document.location.hash.includes('preview')) return
const localStorageInfo = getLocalStorageInfo() const localStorageInfo = getLocalStorageInfo()
if(!document.location.hash.includes('preview') || !localStorageInfo) return if(!localStorageInfo) return
localStorageInfo.componentList.forEach(async (e: CreateComponentType) => { localStorageInfo.componentList.forEach(async (e: CreateComponentType) => {
if (!app.component(e.key)) { if (!app.component(e.key)) {
const chart = fetchChartComponent(e.chartConfig) const chart = fetchChartComponent(e.chartConfig)

View File

@ -15,6 +15,8 @@ export const getLocalStorageInfo = () => {
StorageEnum.GO_CHART_STORAGE_LIST StorageEnum.GO_CHART_STORAGE_LIST
) )
if(!storageList) return
for (let i = 0; i < storageList.length; i++) { for (let i = 0; i < storageList.length; i++) {
if (id.toString() === storageList[i]['id']) { if (id.toString() === storageList[i]['id']) {
return storageList[i] return storageList[i]