mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 预览页改成hook写法
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { ref } from 'vue'
|
||||
import { ChartEditStorageType } from '../index.d'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { fetchChartComponent } from '@/packages/index'
|
||||
|
||||
export const useComInstall = (localStorageInfo: ChartEditStorageType) => {
|
||||
const show = ref(false)
|
||||
|
||||
// 注册组件(一开始无法获取window['$vue'])
|
||||
const intervalTiming = setInterval(() => {
|
||||
if (window['$vue'].component) {
|
||||
clearInterval(intervalTiming)
|
||||
show.value = true
|
||||
localStorageInfo.componentList.forEach(async (e: CreateComponentType) => {
|
||||
if (!window['$vue'].component(e.chartConfig.chartKey)) {
|
||||
window['$vue'].component(
|
||||
e.chartConfig.chartKey,
|
||||
fetchChartComponent(e.chartConfig)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 200)
|
||||
|
||||
return {
|
||||
show
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user