fix: 修改预览页面动态注册方式

This commit is contained in:
MTrun
2022-03-10 14:34:26 +08:00
parent 790cc7b878
commit c29ecc8b0b
7 changed files with 24 additions and 32 deletions
-20
View File
@@ -1,26 +1,6 @@
import type { App } from 'vue'
import { Skeleton } from '@/components/Skeleton'
import { LoadingComponent } from '@/components/LoadingComponent'
import { getLocalStorageInfo } from '@/views/preview/utils/index'
import { fetchChartComponent } from '@/packages/index'
import { CreateComponentType } from '@/packages/index.d'
/**
* * 预览页面动态注册 package 组件
* @param app
*/
export const setupPreviewPackages = (app: App) => {
if (document.location.hash.includes('preview')) {
const localStorageInfo = getLocalStorageInfo()
if (!localStorageInfo) return
localStorageInfo.componentList.forEach(async (e: CreateComponentType) => {
if (!app.component(e.key)) {
const chart = fetchChartComponent(e.chartConfig)
app.component(e.key, chart)
}
})
}
}
/**
* 全局注册自定义组件