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

This commit is contained in:
MTrun
2022-03-10 14:34:26 +08:00
parent 87b033c633
commit 5694f61e4d
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)
}
})
}
}
/**
* 全局注册自定义组件
+1 -1
View File
@@ -1,4 +1,4 @@
export { setupNaive } from '@/plugins/naive'
export { setupDirectives } from '@/plugins/directives'
export { setupCustomComponents, setupPreviewPackages } from '@/plugins/customComponents'
export { setupCustomComponents } from '@/plugins/customComponents'
export { icon } from '@/plugins/icon'