mirror of
https://gitee.com/dromara/go-view.git
synced 2025-10-14 22:42:10 +08:00
refactor: replace the deprecate api 'globEager'
This commit is contained in:
parent
413c17f4cd
commit
41bbbe7c96
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
interface ITextures {
|
interface ITextures {
|
||||||
name: string
|
name: string
|
||||||
url: string
|
url: () => Promise<{ default: string }>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IResources {
|
export interface IResources {
|
||||||
@ -15,14 +15,13 @@ export interface IResources {
|
|||||||
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 = import.meta.glob("../../images/earth/*");
|
||||||
|
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] as () => Promise<{ default: string }>)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,9 @@ export class Resources {
|
|||||||
*/
|
*/
|
||||||
private loadResources(): void {
|
private loadResources(): void {
|
||||||
this.textureLoader = new TextureLoader(this.manager)
|
this.textureLoader = new TextureLoader(this.manager)
|
||||||
resources.textures?.forEach(item => {
|
resources.textures?.forEach(async item => {
|
||||||
this.textureLoader.load(item.url, t => {
|
const url = (await item.url()).default
|
||||||
|
this.textureLoader.load(url, t => {
|
||||||
this.textures[item.name] = t
|
this.textures[item.name] = t
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user