2021-02-01 16:11:00 +00:00
|
|
|
window.beforeBoot = function () {
|
2021-02-03 13:34:58 +00:00
|
|
|
// console.log("游戏正在启动中.")
|
2021-02-01 16:11:00 +00:00
|
|
|
if (window.remoteUrl) {
|
|
|
|
const settings = window._CCSettings;
|
|
|
|
settings.server = window.remoteUrl;
|
2021-02-03 13:34:58 +00:00
|
|
|
//cc.log("远程资源地址:", settings.server);
|
2021-02-01 16:11:00 +00:00
|
|
|
}
|
|
|
|
let url = window.updateUrl || false;
|
|
|
|
if (!url) {
|
|
|
|
cc.log("未配置版本更新地址,跳过更新.")
|
|
|
|
window.boot();
|
|
|
|
return;
|
|
|
|
}
|
2021-02-02 14:20:01 +00:00
|
|
|
|
|
|
|
// 请求缓存信息,判断是否需要更新.
|
2021-02-03 13:34:58 +00:00
|
|
|
let assetStr = window.localStorage.getItem('cur_ver_info');
|
2021-02-02 14:20:01 +00:00
|
|
|
if (!assetStr) {
|
|
|
|
window.boot();
|
|
|
|
} else {
|
2021-02-03 13:34:58 +00:00
|
|
|
// console.log("当前版本信息:", assetStr);
|
2021-02-02 14:20:01 +00:00
|
|
|
let asset = JSON.parse(assetStr);
|
|
|
|
window.mergeVersion(asset);
|
|
|
|
window.boot();
|
|
|
|
}
|
2021-02-01 16:11:00 +00:00
|
|
|
};
|
|
|
|
window.mergeVersion = function (updateInfo) {
|
|
|
|
const settings = window._CCSettings;
|
2021-02-02 14:20:01 +00:00
|
|
|
const bundleVers = updateInfo.bundles;
|
2021-02-03 13:34:58 +00:00
|
|
|
settings.server = updateInfo.server;
|
2021-02-01 16:11:00 +00:00
|
|
|
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);
|
2021-02-03 13:34:58 +00:00
|
|
|
console.log('bundle 有更新:', b, bundleVers[b]);
|
2021-02-01 16:11:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
settings.bundleVers = bundleVers;
|
|
|
|
}
|
2021-02-03 13:34:58 +00:00
|
|
|
};
|
2021-02-01 16:11:00 +00:00
|
|
|
|