fix: 更新提交
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-console */
|
||||
import { _decorator, assetManager, AssetManager, Component, director } from "cc";
|
||||
|
||||
import HotupdateConfig from "@max-studio/hotupdate/HotupdateConfig";
|
||||
@@ -15,6 +14,7 @@ const { ccclass, property } = _decorator;
|
||||
export class Startup extends Component {
|
||||
@property(HotupdateLoading)
|
||||
private loading!: HotupdateLoading;
|
||||
private loadingStartAt = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
HotupdateInstance.getInstance().register(this.onHotupdateEvent.bind(this));
|
||||
@@ -107,7 +107,8 @@ export class Startup extends Component {
|
||||
}
|
||||
|
||||
async start() {
|
||||
this.loading.updateProgressText("正在检查更新...");
|
||||
this.loadingStartAt = Date.now();
|
||||
this.loading.updateProgressText("正在检查更新", true);
|
||||
void HotupdateInstance.getInstance().checkUpdate(new HotupdateConfig("main"));
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ export class Startup extends Component {
|
||||
* 重新尝试热更新
|
||||
*/
|
||||
private tryHotUpdate(): void {
|
||||
this.loading.updateProgressText("正在检查更新...");
|
||||
this.loading.updateProgressText("正在检查更新", true);
|
||||
void HotupdateInstance.getInstance().checkUpdate(new HotupdateConfig("main"));
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ export class Startup extends Component {
|
||||
* 开始热更新
|
||||
*/
|
||||
private startHotUpdate(): void {
|
||||
this.loading.updateProgressText("正在更新...");
|
||||
this.loading.updateProgressText("正在更新", true);
|
||||
HotupdateInstance.getInstance().hotUpdate();
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ export class Startup extends Component {
|
||||
* 重试更新
|
||||
*/
|
||||
private retryUpdate(): void {
|
||||
this.loading.updateProgressText("正在更新...");
|
||||
this.loading.updateProgressText("正在更新", true);
|
||||
HotupdateInstance.getInstance().hotUpdate();
|
||||
}
|
||||
|
||||
@@ -139,6 +140,7 @@ export class Startup extends Component {
|
||||
* 进入游戏
|
||||
*/
|
||||
private async enterHall() {
|
||||
this.loading.updateProgressText("热更新完成, 即将进入游戏");
|
||||
try {
|
||||
await this.loadBundles("max-core", "max-res", "configs");
|
||||
const hallBundle = await this.loadBundle("hall");
|
||||
@@ -147,10 +149,13 @@ export class Startup extends Component {
|
||||
console.error("加载场景失败:", err);
|
||||
return;
|
||||
}
|
||||
this.loading.node.destroy();
|
||||
console.log("加载场景成功", data);
|
||||
// 切换到 Hall 场景
|
||||
director.runScene(data);
|
||||
const elapsed = Date.now() - this.loadingStartAt;
|
||||
const delay = Math.max(2000 - elapsed, 0);
|
||||
setTimeout(() => {
|
||||
this.loading.node.destroy();
|
||||
console.log("加载场景成功", data);
|
||||
director.runScene(data);
|
||||
}, delay);
|
||||
});
|
||||
} catch (err) {
|
||||
console.log("err", err);
|
||||
|
||||
Reference in New Issue
Block a user