fix: 更新提交
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-console */
|
||||
import { _decorator, Component, director } from "cc";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -30,9 +29,7 @@ export class DontDestroy extends Component {
|
||||
*/
|
||||
private makePersistent(): void {
|
||||
if (this._isPersistent) {
|
||||
console.warn(
|
||||
`DontDestroy: 节点 ${this.node.name} 已经是常驻节点,无需重复设置`,
|
||||
);
|
||||
console.warn(`DontDestroy: 节点 ${this.node.name} 已经是常驻节点,无需重复设置`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,9 +46,7 @@ export class DontDestroy extends Component {
|
||||
*/
|
||||
public removePersistent(): void {
|
||||
if (!this._isPersistent) {
|
||||
console.warn(
|
||||
`DontDestroy: 节点 ${this.node.name} 不是常驻节点,无需移除`,
|
||||
);
|
||||
console.warn(`DontDestroy: 节点 ${this.node.name} 不是常驻节点,无需移除`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,9 +54,7 @@ export class DontDestroy extends Component {
|
||||
director.removePersistRootNode(this.node);
|
||||
this._isPersistent = false;
|
||||
|
||||
console.log(
|
||||
`DontDestroy: 节点 ${this.node.name} 已从常驻节点列表中移除`,
|
||||
);
|
||||
console.log(`DontDestroy: 节点 ${this.node.name} 已从常驻节点列表中移除`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
/* eslint-disable no-console */
|
||||
/**
|
||||
* 全局 Proto 初始化
|
||||
*/
|
||||
|
||||
// import ProtoDefinitionsModule from "../protos/ProtoDefinitions.js";
|
||||
|
||||
import { EDITOR } from "cc/env";
|
||||
import ProtoDefinitionsModule from "../protos/ProtoDefinitions.js";
|
||||
|
||||
// @ts-ignore
|
||||
|
||||
/**
|
||||
* 初始化全局 ProtoDefinitions
|
||||
*/
|
||||
export class GlobalProtoInit {
|
||||
// ProtoDefinitionsModule.
|
||||
private static _initialized = false;
|
||||
|
||||
/**
|
||||
@@ -26,25 +21,15 @@ export class GlobalProtoInit {
|
||||
|
||||
try {
|
||||
// 将 ProtoDefinitions 挂载到全局对象
|
||||
|
||||
(globalThis as any).ProtoDefinitions = ProtoDefinitionsModule;
|
||||
|
||||
// 同时挂载到 window 对象(浏览器环境)
|
||||
if (typeof window !== "undefined") {
|
||||
(window as any).ProtoDefinitions = ProtoDefinitionsModule;
|
||||
window.ProtoDefinitions = ProtoDefinitionsModule;
|
||||
}
|
||||
|
||||
this._initialized = true;
|
||||
console.log(
|
||||
"GlobalProtoInit",
|
||||
"ProtoDefinitions 已成功挂载到全局对象",
|
||||
);
|
||||
console.log("GlobalProtoInit", "ProtoDefinitions 已成功挂载到全局对象");
|
||||
} catch (err) {
|
||||
console.error(
|
||||
"GlobalProtoInit",
|
||||
"初始化 ProtoDefinitions 失败:",
|
||||
err,
|
||||
);
|
||||
console.error("GlobalProtoInit", "初始化 ProtoDefinitions 失败:", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,3 +40,7 @@ export class GlobalProtoInit {
|
||||
return this._initialized;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EDITOR) {
|
||||
GlobalProtoInit.init();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var $protobuf = require("protobufjs/minimal");
|
||||
|
||||
Reference in New Issue
Block a user