mirror of
https://gitee.com/dromara/go-view.git
synced 2024-12-02 03:38:27 +08:00
build: 升级 vite 到4.x版本, 修改不兼容的代码
This commit is contained in:
parent
9fd408e8ef
commit
47d1dcbc04
@ -75,7 +75,7 @@
|
||||
"sass": "^1.49.11",
|
||||
"sass-loader": "^12.6.0",
|
||||
"typescript": "4.6.3",
|
||||
"vite": "2.9.9",
|
||||
"vite": "4.2.1",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-importer": "^0.2.5",
|
||||
"vite-plugin-mock": "^2.9.6",
|
||||
|
2831
pnpm-lock.yaml
2831
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,34 +1,34 @@
|
||||
/**
|
||||
* 资源文件
|
||||
* 把模型和图片分开进行加载
|
||||
*/
|
||||
|
||||
interface ITextures {
|
||||
name: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface IResources {
|
||||
textures?: ITextures[]
|
||||
}
|
||||
|
||||
const fileSuffix = ['earth', 'gradient', 'redCircle', 'label', 'aperture', 'glow', 'light_column', 'aircraft']
|
||||
const textures: ITextures[] = []
|
||||
|
||||
const modules = import.meta.globEager("../../images/earth/*");
|
||||
|
||||
for(let item in modules) {
|
||||
const n = item.split('/').pop()
|
||||
if(n) {
|
||||
textures.push({
|
||||
name: n.split('.')[0],
|
||||
url: modules[item].default
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const resources: IResources = {
|
||||
textures
|
||||
}
|
||||
|
||||
export { resources }
|
||||
/**
|
||||
* 资源文件
|
||||
* 把模型和图片分开进行加载
|
||||
*/
|
||||
|
||||
interface ITextures {
|
||||
name: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface IResources {
|
||||
textures?: ITextures[]
|
||||
}
|
||||
|
||||
const fileSuffix = ['earth', 'gradient', 'redCircle', 'label', 'aperture', 'glow', 'light_column', 'aircraft']
|
||||
const textures: ITextures[] = []
|
||||
|
||||
const modules: Record<string, { default: string }> = import.meta.glob("../../images/earth/*", { eager: true })
|
||||
|
||||
for(let item in modules) {
|
||||
const n = item.split('/').pop()
|
||||
if(n) {
|
||||
textures.push({
|
||||
name: n.split('.')[0],
|
||||
url: modules[item].default
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const resources: IResources = {
|
||||
textures
|
||||
}
|
||||
|
||||
export { resources }
|
||||
|
@ -1,81 +1,87 @@
|
||||
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'
|
||||
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')
|
||||
const imagesModules = import.meta.globEager('../assets/images/chart/**')
|
||||
|
||||
// * 所有图表
|
||||
export let packagesList: PackagesType = {
|
||||
[PackagesCategoryEnum.CHARTS]: ChartList,
|
||||
[PackagesCategoryEnum.INFORMATIONS]: InformationList,
|
||||
[PackagesCategoryEnum.TABLES]: TableList,
|
||||
[PackagesCategoryEnum.DECORATES]: DecorateList
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取目标组件配置信息
|
||||
* @param targetData
|
||||
*/
|
||||
export const createComponent = async (targetData: ConfigType) => {
|
||||
const { category, key } = targetData
|
||||
const chart = await import(`./components/${targetData.package}/${category}/${key}/config.ts`)
|
||||
return new chart.default()
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取组件
|
||||
* @param {string} chartName 名称
|
||||
* @param {FetchComFlagType} flag 标识 0为展示组件, 1为配置组件
|
||||
*/
|
||||
const fetchComponent = (chartName: string, flag: FetchComFlagType) => {
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取图片内容
|
||||
* @param {ConfigType} targetData 配置项
|
||||
*/
|
||||
export const fetchImages = async (targetData?: ConfigType) => {
|
||||
if (!targetData) return ''
|
||||
// 新数据动态处理
|
||||
const { image, package: targetDataPackage } = targetData
|
||||
// 兼容旧数据
|
||||
if (image.includes('@') || image.includes('base64')) return image
|
||||
|
||||
const imageName = image.substring(image.lastIndexOf('/') + 1)
|
||||
for (const key in imagesModules) {
|
||||
const urlSplit = key.split('/')
|
||||
if (urlSplit[urlSplit.length - 1] === imageName) {
|
||||
return imagesModules[key]?.default
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
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'
|
||||
import { PackagesCategoryEnum, PackagesType, ConfigType, FetchComFlagType } from '@/packages/index.d'
|
||||
|
||||
const configModules: Record<string, { default: string }> = import.meta.glob('./components/**/config.vue', {
|
||||
eager: true
|
||||
})
|
||||
const indexModules: Record<string, { default: string }> = import.meta.glob('./components/**/index.vue', {
|
||||
eager: true
|
||||
})
|
||||
const imagesModules: Record<string, { default: string }> = import.meta.glob('../assets/images/chart/**', {
|
||||
eager: true
|
||||
})
|
||||
|
||||
// * 所有图表
|
||||
export let packagesList: PackagesType = {
|
||||
[PackagesCategoryEnum.CHARTS]: ChartList,
|
||||
[PackagesCategoryEnum.INFORMATIONS]: InformationList,
|
||||
[PackagesCategoryEnum.TABLES]: TableList,
|
||||
[PackagesCategoryEnum.DECORATES]: DecorateList
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取目标组件配置信息
|
||||
* @param targetData
|
||||
*/
|
||||
export const createComponent = async (targetData: ConfigType) => {
|
||||
const { category, key } = targetData
|
||||
const chart = await import(`./components/${targetData.package}/${category}/${key}/config.ts`)
|
||||
return new chart.default()
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取组件
|
||||
* @param {string} chartName 名称
|
||||
* @param {FetchComFlagType} flag 标识 0为展示组件, 1为配置组件
|
||||
*/
|
||||
const fetchComponent = (chartName: string, flag: FetchComFlagType) => {
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取图片内容
|
||||
* @param {ConfigType} targetData 配置项
|
||||
*/
|
||||
export const fetchImages = async (targetData?: ConfigType) => {
|
||||
if (!targetData) return ''
|
||||
// 新数据动态处理
|
||||
const { image, package: targetDataPackage } = targetData
|
||||
// 兼容旧数据
|
||||
if (image.includes('@') || image.includes('base64')) return image
|
||||
|
||||
const imageName = image.substring(image.lastIndexOf('/') + 1)
|
||||
for (const key in imagesModules) {
|
||||
const urlSplit = key.split('/')
|
||||
if (urlSplit[urlSplit.length - 1] === imageName) {
|
||||
return imagesModules[key]?.default
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user