UNPKG

laya-coreui-es

Version:

laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改

30 lines (29 loc) 1.27 kB
import { Loader } from "./Loader"; import { URL } from "./URL"; import { Handler } from "../utils/Handler"; import { ILaya } from "../../ILaya"; export class ResourceVersion { static enable(manifestFile, callback, type = 2) { ResourceVersion.type = type; ILaya.loader.load(manifestFile, Handler.create(null, ResourceVersion.onManifestLoaded, [callback]), null, Loader.JSON); } static onManifestLoaded(callback, data) { ResourceVersion.manifest = data; URL.customFormat = ResourceVersion.addVersionPrefix; callback.run(); if (!data) { console.warn("资源版本清单文件不存在,不使用资源版本管理。忽略ERR_FILE_NOT_FOUND错误。"); } } static addVersionPrefix(originURL) { if (ResourceVersion.manifest && ResourceVersion.manifest[originURL]) { if (ResourceVersion.type == ResourceVersion.FILENAME_VERSION) return ResourceVersion.manifest[originURL]; return ResourceVersion.manifest[originURL] + "/" + originURL; } return originURL; } } ResourceVersion.FOLDER_VERSION = 1; ResourceVersion.FILENAME_VERSION = 2; ResourceVersion.type = ResourceVersion.FOLDER_VERSION;