mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-21 04:56:24 +08:00
29 lines
826 B
TypeScript
29 lines
826 B
TypeScript
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
|
|
}
|
|
}
|