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