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": "^1.49.11",
|
||||||
"sass-loader": "^12.6.0",
|
"sass-loader": "^12.6.0",
|
||||||
"typescript": "4.6.3",
|
"typescript": "4.6.3",
|
||||||
"vite": "2.9.9",
|
"vite": "4.2.1",
|
||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vite-plugin-importer": "^0.2.5",
|
"vite-plugin-importer": "^0.2.5",
|
||||||
"vite-plugin-mock": "^2.9.6",
|
"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 {
|
interface ITextures {
|
||||||
name: string
|
name: string
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IResources {
|
export interface IResources {
|
||||||
textures?: ITextures[]
|
textures?: ITextures[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileSuffix = ['earth', 'gradient', 'redCircle', 'label', 'aperture', 'glow', 'light_column', 'aircraft']
|
const fileSuffix = ['earth', 'gradient', 'redCircle', 'label', 'aperture', 'glow', 'light_column', 'aircraft']
|
||||||
const textures: ITextures[] = []
|
const textures: ITextures[] = []
|
||||||
|
|
||||||
const modules = import.meta.globEager("../../images/earth/*");
|
const modules: Record<string, { default: string }> = import.meta.glob("../../images/earth/*", { eager: true })
|
||||||
|
|
||||||
for(let item in modules) {
|
for(let item in modules) {
|
||||||
const n = item.split('/').pop()
|
const n = item.split('/').pop()
|
||||||
if(n) {
|
if(n) {
|
||||||
textures.push({
|
textures.push({
|
||||||
name: n.split('.')[0],
|
name: n.split('.')[0],
|
||||||
url: modules[item].default
|
url: modules[item].default
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const resources: IResources = {
|
const resources: IResources = {
|
||||||
textures
|
textures
|
||||||
}
|
}
|
||||||
|
|
||||||
export { resources }
|
export { resources }
|
||||||
|
@ -1,81 +1,87 @@
|
|||||||
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'
|
import { PackagesCategoryEnum, PackagesType, ConfigType, FetchComFlagType } from '@/packages/index.d'
|
||||||
|
|
||||||
const configModules = import.meta.globEager('./components/**/config.vue')
|
const configModules: Record<string, { default: string }> = import.meta.glob('./components/**/config.vue', {
|
||||||
const indexModules = import.meta.globEager('./components/**/index.vue')
|
eager: true
|
||||||
const imagesModules = import.meta.globEager('../assets/images/chart/**')
|
})
|
||||||
|
const indexModules: Record<string, { default: string }> = import.meta.glob('./components/**/index.vue', {
|
||||||
// * 所有图表
|
eager: true
|
||||||
export let packagesList: PackagesType = {
|
})
|
||||||
[PackagesCategoryEnum.CHARTS]: ChartList,
|
const imagesModules: Record<string, { default: string }> = import.meta.glob('../assets/images/chart/**', {
|
||||||
[PackagesCategoryEnum.INFORMATIONS]: InformationList,
|
eager: true
|
||||||
[PackagesCategoryEnum.TABLES]: TableList,
|
})
|
||||||
[PackagesCategoryEnum.DECORATES]: DecorateList
|
|
||||||
}
|
// * 所有图表
|
||||||
|
export let packagesList: PackagesType = {
|
||||||
/**
|
[PackagesCategoryEnum.CHARTS]: ChartList,
|
||||||
* * 获取目标组件配置信息
|
[PackagesCategoryEnum.INFORMATIONS]: InformationList,
|
||||||
* @param targetData
|
[PackagesCategoryEnum.TABLES]: TableList,
|
||||||
*/
|
[PackagesCategoryEnum.DECORATES]: DecorateList
|
||||||
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 targetData
|
||||||
|
*/
|
||||||
/**
|
export const createComponent = async (targetData: ConfigType) => {
|
||||||
* * 获取组件
|
const { category, key } = targetData
|
||||||
* @param {string} chartName 名称
|
const chart = await import(`./components/${targetData.package}/${category}/${key}/config.ts`)
|
||||||
* @param {FetchComFlagType} flag 标识 0为展示组件, 1为配置组件
|
return new chart.default()
|
||||||
*/
|
}
|
||||||
const fetchComponent = (chartName: string, flag: FetchComFlagType) => {
|
|
||||||
const module = flag === FetchComFlagType.VIEW ? indexModules : configModules
|
/**
|
||||||
for (const key in module) {
|
* * 获取组件
|
||||||
const urlSplit = key.split('/')
|
* @param {string} chartName 名称
|
||||||
if (urlSplit[urlSplit.length - 2] === chartName) {
|
* @param {FetchComFlagType} flag 标识 0为展示组件, 1为配置组件
|
||||||
return module[key]
|
*/
|
||||||
}
|
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 fetchChartComponent = (dropData: ConfigType) => {
|
||||||
* @param {ConfigType} dropData 配置项
|
const { key } = dropData
|
||||||
*/
|
return fetchComponent(key, FetchComFlagType.VIEW)?.default
|
||||||
export const fetchConfigComponent = (dropData: ConfigType) => {
|
}
|
||||||
const { key } = dropData
|
|
||||||
return fetchComponent(key, FetchComFlagType.CONFIG)?.default
|
/**
|
||||||
}
|
* * 获取配置组件
|
||||||
|
* @param {ConfigType} dropData 配置项
|
||||||
/**
|
*/
|
||||||
* * 获取图片内容
|
export const fetchConfigComponent = (dropData: ConfigType) => {
|
||||||
* @param {ConfigType} targetData 配置项
|
const { key } = dropData
|
||||||
*/
|
return fetchComponent(key, FetchComFlagType.CONFIG)?.default
|
||||||
export const fetchImages = async (targetData?: ConfigType) => {
|
}
|
||||||
if (!targetData) return ''
|
|
||||||
// 新数据动态处理
|
/**
|
||||||
const { image, package: targetDataPackage } = targetData
|
* * 获取图片内容
|
||||||
// 兼容旧数据
|
* @param {ConfigType} targetData 配置项
|
||||||
if (image.includes('@') || image.includes('base64')) return image
|
*/
|
||||||
|
export const fetchImages = async (targetData?: ConfigType) => {
|
||||||
const imageName = image.substring(image.lastIndexOf('/') + 1)
|
if (!targetData) return ''
|
||||||
for (const key in imagesModules) {
|
// 新数据动态处理
|
||||||
const urlSplit = key.split('/')
|
const { image, package: targetDataPackage } = targetData
|
||||||
if (urlSplit[urlSplit.length - 1] === imageName) {
|
// 兼容旧数据
|
||||||
return imagesModules[key]?.default
|
if (image.includes('@') || image.includes('base64')) return image
|
||||||
}
|
|
||||||
}
|
const imageName = image.substring(image.lastIndexOf('/') + 1)
|
||||||
return ''
|
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