ef915a121e
可以在项目代码中直接使用 import um = require('UpdateManager') 然后调用相关接口.
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
window.beforeBoot = function () {
|
|
// console.log("游戏正在启动中.")
|
|
if (window.remoteUrl) {
|
|
const settings = window._CCSettings;
|
|
settings.server = window.remoteUrl;
|
|
//cc.log("远程资源地址:", settings.server);
|
|
}
|
|
let url = window.updateUrl || false;
|
|
if (!url) {
|
|
cc.log("未配置版本更新地址,跳过更新.")
|
|
window.boot();
|
|
return;
|
|
}
|
|
|
|
// 请求缓存信息,判断是否需要更新.
|
|
let assetStr = window.localStorage.getItem('cur_ver_info');
|
|
if (!assetStr) {
|
|
window.boot();
|
|
} else {
|
|
// console.log("当前版本信息:", assetStr);
|
|
let asset = JSON.parse(assetStr);
|
|
window.mergeVersion(asset);
|
|
window.boot();
|
|
}
|
|
};
|
|
window.mergeVersion = function (updateInfo) {
|
|
const settings = window._CCSettings;
|
|
const bundleVers = updateInfo.bundles;
|
|
settings.server = updateInfo.server;
|
|
if (bundleVers) {
|
|
for (let b in bundleVers) {
|
|
if (bundleVers[b] != settings.bundleVers[b]) {
|
|
// 配置中的bundleVer版本不一致,则添加到remote列表中去,以供远程加载.
|
|
if (settings.remoteBundles.indexOf(b) < 0) {
|
|
settings.remoteBundles.push(b);
|
|
console.log('bundle 有更新:', b, bundleVers[b]);
|
|
}
|
|
}
|
|
}
|
|
settings.bundleVers = bundleVers;
|
|
}
|
|
};
|
|
|