Skip to main content

get 获取文件

get

类型: MethodDeclaration

定义位置: loader.ts

描述

获取文件

参数 descriptor: 文件描述器

返回值:文件数据

参数

参数名类型描述默认值
descriptor`{
/** 文件路径 */
path?: string
/** 文件GUID */
guid?: string
/** 资源类型 */
type: 'text' | 'json' | 'blob' | 'arraybuffer' | 'image'
}`--

返回值

类型: Promise<any>

文件数据

源代码

位置: 第 117 行

public async get(descriptor: {
/** 文件路径 */
path?: string
/** 文件GUID */
guid?: string
/** 资源类型 */
type: 'text' | 'json' | 'blob' | 'arraybuffer' | 'image'
}): Promise<any> {
// 可以指定路径或GUID来加载文件
const guid = descriptor.guid ?? ''
const path = descriptor.path ?? this.getPathByGUID(guid)
const type = descriptor.type
switch (type) {
case 'image':
return this.loadImage({guid, path})
default:
return /\.dat$/.test(path)
? this.decrypt({path, type})
: this.xhr({path, type})
}
}

文档生成时间:2025/7/7 12:07:06