2022-01-19 19:59:11 +08:00
|
|
|
|
import type { App } from 'vue'
|
|
|
|
|
import {
|
|
|
|
|
PackagesCategoryEnum,
|
|
|
|
|
PackagesType,
|
|
|
|
|
ConfigType
|
|
|
|
|
} from '@/packages/index.d'
|
2022-01-25 11:09:32 +08:00
|
|
|
|
import { ChartList } from '@/packages/components/Charts/index'
|
|
|
|
|
import { DecorateList } from '@/packages/components/Decorates/index'
|
|
|
|
|
import { InformationList } from '@/packages/components/Informations/index'
|
|
|
|
|
import { TableList } from '@/packages/components/Tables/index'
|
2022-01-14 16:17:14 +08:00
|
|
|
|
|
2022-01-25 18:19:44 +08:00
|
|
|
|
// * 所有图表
|
2022-03-07 12:33:05 +08:00
|
|
|
|
export let packagesList: PackagesType = {
|
2022-01-14 22:07:02 +08:00
|
|
|
|
[PackagesCategoryEnum.CHARTS]: ChartList,
|
2022-01-15 12:50:00 +08:00
|
|
|
|
[PackagesCategoryEnum.INFORMATION]: InformationList,
|
|
|
|
|
[PackagesCategoryEnum.TABLES]: TableList,
|
2022-01-19 19:59:11 +08:00
|
|
|
|
[PackagesCategoryEnum.DECORATES]: DecorateList
|
2022-01-14 16:17:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 12:33:05 +08:00
|
|
|
|
export const packgeInstall = (app:App) => {
|
|
|
|
|
ChartList.forEach(e=>{
|
|
|
|
|
console.log(e)
|
|
|
|
|
app.component(e.key, e.node)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-25 18:19:44 +08:00
|
|
|
|
/**
|
2022-03-07 12:33:05 +08:00
|
|
|
|
* * 获取目标拖拽组件配置信息
|
2022-01-25 18:19:44 +08:00
|
|
|
|
* @param dropData
|
|
|
|
|
*/
|
2022-03-07 12:33:05 +08:00
|
|
|
|
export const createComponent = async (dropData: ConfigType) => {
|
2022-01-25 18:19:44 +08:00
|
|
|
|
const { category } = dropData
|
|
|
|
|
const key = dropData.key.substring(1)
|
|
|
|
|
const chart = await import(`./components/${dropData.package}/${category}/${key}/config.ts`)
|
|
|
|
|
return new chart.default()
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-06 21:26:31 +08:00
|
|
|
|
/**
|
|
|
|
|
* * 获取组件信息
|
2022-03-07 12:33:05 +08:00
|
|
|
|
* * import.meta.globEager 不好使,先从原来的位置拿把
|
2022-03-06 21:26:31 +08:00
|
|
|
|
*/
|
2022-03-07 12:33:05 +08:00
|
|
|
|
export const fetchChartComponent = (dropData: ConfigType | Omit<ConfigType, "node" | 'conNode'>) => {
|
|
|
|
|
const { key, package:packageName } = dropData
|
|
|
|
|
return packagesList[packageName as PackagesCategoryEnum].filter(e=> e.key === key)[0].node()
|
|
|
|
|
}
|