修改ConfigManager,定义配置数据继承体系
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 配置数据类基类
|
||||
* 提供配置数据类的生命周期管理和基础功能
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "f7335af0-3281-4f2e-8f8e-c59e869183f6",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 主题配置
|
||||
*/
|
||||
import { BaseConfig } from "./BaseConfig";
|
||||
import { ConfigManager } from "../manager/ConfigManager";
|
||||
|
||||
export class ThemeConfig extends BaseConfig {
|
||||
|
||||
public reset(): void {
|
||||
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有配置
|
||||
*/
|
||||
protected getAllConfig(): any | null {
|
||||
return ConfigManager.tables.TbThemes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置,根据 id
|
||||
*/
|
||||
protected getConfigById(id: number): any | null {
|
||||
let allData = this.getAllConfig();
|
||||
if (!allData) return null;
|
||||
return allData.get(id);
|
||||
}
|
||||
|
||||
/** 根据主题 id 获取多语言键 */
|
||||
public getLanKeyById(id: number): string | null {
|
||||
let oneData = this.getConfigById(id);
|
||||
if (!oneData) return null;
|
||||
return oneData.key;
|
||||
}
|
||||
|
||||
/** 根据主题 id 获取主题名称 */
|
||||
public getNameById(id: number): string | null {
|
||||
let oneData = this.getConfigById(id);
|
||||
if (!oneData) return null;
|
||||
return oneData.name;
|
||||
}
|
||||
|
||||
/** 根据主题 id 获取主题枚举 */
|
||||
public getCategoryById(id: number): number | null {
|
||||
let oneData = this.getConfigById(id);
|
||||
if (!oneData) return null;
|
||||
return oneData.category;
|
||||
}
|
||||
|
||||
/** 根据主题 id 获取是否解锁 */
|
||||
public getIsReleaseById(id: number): boolean | null {
|
||||
let oneData = this.getConfigById(id);
|
||||
if (!oneData) return null;
|
||||
return oneData.isRelease;
|
||||
}
|
||||
|
||||
/** 根据主题 id 获取图片路径 */
|
||||
public getPathById(id: number): string | null {
|
||||
let oneData = this.getConfigById(id);
|
||||
if (!oneData) return null;
|
||||
return oneData.path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "161d34f2-7ca6-4f19-8dba-1f597dd28c4e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user