fix: 更新提交
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user