mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
fix: 修改动态引入逻辑
This commit is contained in:
parent
06b1e40930
commit
b71b7bfd0e
5
src/packages/index.d.ts
vendored
5
src/packages/index.d.ts
vendored
@ -47,6 +47,11 @@ export enum PackagesCategoryName {
|
|||||||
DECORATES = '小组件'
|
DECORATES = '小组件'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取组件
|
||||||
|
export enum FetchComFlagType {
|
||||||
|
VIEW, CONFIG
|
||||||
|
}
|
||||||
|
|
||||||
// 图表包类型
|
// 图表包类型
|
||||||
export type PackagesType = {
|
export type PackagesType = {
|
||||||
[PackagesCategoryEnum.CHARTS]: ConfigType[]
|
[PackagesCategoryEnum.CHARTS]: ConfigType[]
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
import {
|
|
||||||
PackagesCategoryEnum,
|
|
||||||
PackagesType,
|
|
||||||
ConfigType
|
|
||||||
} from '@/packages/index.d'
|
|
||||||
import { ChartList } from '@/packages/components/Charts/index'
|
import { ChartList } from '@/packages/components/Charts/index'
|
||||||
import { DecorateList } from '@/packages/components/Decorates/index'
|
import { DecorateList } from '@/packages/components/Decorates/index'
|
||||||
import { InformationList } from '@/packages/components/Informations/index'
|
import { InformationList } from '@/packages/components/Informations/index'
|
||||||
import { TableList } from '@/packages/components/Tables/index'
|
import { TableList } from '@/packages/components/Tables/index'
|
||||||
|
import {
|
||||||
|
PackagesCategoryEnum,
|
||||||
|
PackagesType,
|
||||||
|
ConfigType,
|
||||||
|
FetchComFlagType
|
||||||
|
} from '@/packages/index.d'
|
||||||
|
|
||||||
|
const configModules = import.meta.globEager("./components/**/config.vue")
|
||||||
|
const indexModules = import.meta.globEager("./components/**/index.vue")
|
||||||
|
|
||||||
// * 所有图表
|
// * 所有图表
|
||||||
export let packagesList: PackagesType = {
|
export let packagesList: PackagesType = {
|
||||||
@ -36,10 +40,35 @@ export const packgeInstall = (app:App) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 获取组件信息
|
* * 获取组件
|
||||||
* * import.meta.globEager 不好使,先从原来的位置拿把
|
* @param {string} chartName 名称
|
||||||
|
* @param {FetchComFlagType} flag 标识 0为展示组件, 1为配置组件
|
||||||
*/
|
*/
|
||||||
export const fetchChartComponent = (dropData: ConfigType | Omit<ConfigType, "node" | 'conNode'>) => {
|
const fetchComponent = (chartName: string, flag: FetchComFlagType) => {
|
||||||
const { key, package:packageName } = dropData
|
chartName = chartName.substring(1)
|
||||||
return packagesList[packageName as PackagesCategoryEnum].filter(e=> e.key === key)[0].node()
|
const module = flag === FetchComFlagType.VIEW ? indexModules: configModules
|
||||||
|
for (const key in module) {
|
||||||
|
const urlSplit = key.split('/')
|
||||||
|
if(urlSplit[urlSplit.length -2 ] === chartName) {
|
||||||
|
return module[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取展示组件
|
||||||
|
* @param {ConfigType} dropData 配置项
|
||||||
|
*/
|
||||||
|
export const fetchChartComponent = (dropData: ConfigType) => {
|
||||||
|
const { key } = dropData
|
||||||
|
return fetchComponent(key, FetchComFlagType.VIEW)?.default
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取配置组件
|
||||||
|
* @param {ConfigType} dropData 配置项
|
||||||
|
*/
|
||||||
|
export const fetchConfigComponent = (dropData: ConfigType) => {
|
||||||
|
const { key } = dropData
|
||||||
|
return fetchComponent(key, FetchComFlagType.CONFIG)?.default
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user