Files
18xchat/assets/Scripts/chat18x/config/BaseConfig.ts
T

87 lines
1.6 KiB
TypeScript

/**
* 配置数据类基类
* 提供配置数据类的生命周期管理和基础功能
*/
export class BaseConfig {
/** 是否已初始化 */
protected _isInitialized: boolean = false;
/** 是否已销毁 */
protected _isDestroyed: boolean = false;
/** 配置数据ID */
protected _configId: string = '';
/**
* 初始化数据
* @param configId 配置数据ID
*/
public init(configId?: string): void{
if (this._isInitialized) return;
this._isInitialized = true;
if (configId) {
this._configId = configId;
}
}
/**
* 重置数据到初始状态
*/
public reset(): void{
}
/**
* 清空数据内容
*/
public clear(): void{
}
/**
* 销毁数据对象
*/
public destroy(): void{
if (this._isDestroyed) return;
this.clear();
this._isDestroyed = true;
this._isInitialized = null;
this._configId = null;
}
/**
* 获取配置数据ID
*/
public getConfigId(): string {
return this._configId;
}
/**
* 设置配置数据ID
*/
public setConfigId(configId: string): void {
this._configId = configId;
}
/**
* 是否已初始化
*/
public isInitialized(): boolean {
return this._isInitialized;
}
/**
* 是否已销毁
*/
public isDestroyed(): boolean {
return this._isDestroyed;
}
/**
* 获取所有配置
*/
protected getAllConfig(): any | null {
return null;
}
}