import { _decorator, Component } from 'cc'; const { ccclass, property } = _decorator; /** * ConfigManager 读取本地 JSON/Bundle 配置,并在登录后拉取服务端远程配置。 */ @ccclass('ConfigManager') export class ConfigManager extends Component { @property public remoteConfigUrl: string = '/api/v1/configs'; private _local: Map = new Map(); private _remote: Map = new Map(); onLoad() { this._loadLocalConfig(); } private _loadLocalConfig(): void { // TODO: 从本地 resources/config 加载基础配置 this._local.set('ui', {}); } /** * 从服务端拉取 Nacos 热更配置 */ public async fetchRemote(): Promise { // TODO: 调用 HTTP 接口或 Nacos 配置接口 this._remote.set('event', {}); } public get(key: string, defaultValue?: T): T | undefined { if (this._remote.has(key)) { return this._remote.get(key); } if (this._local.has(key)) { return this._local.get(key); } return defaultValue; } public setRemote(key: string, value: any): void { this._remote.set(key, value); } }