feat: 新增组件预览

This commit is contained in:
MTrun
2022-03-07 12:33:05 +08:00
parent fb89f9b85b
commit b0f5fd826c
32 changed files with 102 additions and 93 deletions
+15 -10
View File
@@ -10,18 +10,25 @@ import { InformationList } from '@/packages/components/Informations/index'
import { TableList } from '@/packages/components/Tables/index'
// * 所有图表
let packagesList: PackagesType = {
export let packagesList: PackagesType = {
[PackagesCategoryEnum.CHARTS]: ChartList,
[PackagesCategoryEnum.INFORMATION]: InformationList,
[PackagesCategoryEnum.TABLES]: TableList,
[PackagesCategoryEnum.DECORATES]: DecorateList
}
export const packgeInstall = (app:App) => {
ChartList.forEach(e=>{
console.log(e)
app.component(e.key, e.node)
})
}
/**
* * 获取目标拖拽组件信息
* * 获取目标拖拽组件配置信息
* @param dropData
*/
const createComponent = async (dropData: ConfigType) => {
export const createComponent = async (dropData: ConfigType) => {
const { category } = dropData
const key = dropData.key.substring(1)
const chart = await import(`./components/${dropData.package}/${category}/${key}/config.ts`)
@@ -30,11 +37,9 @@ const createComponent = async (dropData: ConfigType) => {
/**
* * 获取组件信息
* * import.meta.globEager 不好使,先从原来的位置拿把
*/
const fetchChartComponent = async (dropData: ConfigType | Omit<ConfigType, "node">) => {
const key = dropData.key.substring(1)
const { category } = dropData
return await import(`../packages/components/${dropData.package}/${category}/${key}/index.vue`)
}
export { packagesList, createComponent, fetchChartComponent }
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()
}