大侠
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

88 lines
1.8 KiB

import { IBaseConfigContainer, IConfigContainer, IConstContainer } from "./ConfigT";
/**
* 数据代理基类
*/
export class _BaseConfigProxy {
/** 配置表模板 */
protected configTemplate: IBaseConfigContainer;
}
/**
* Config数据代理基类
*/
export default class BaseConfigProxy<Data> extends _BaseConfigProxy {
// /** 配置表模板 */
protected override configTemplate: IConfigContainer;
//配置数据列表
protected m_dataList: Data[];
/** 配置数据列表 */
public get dataList(): Data[] {
return this.m_dataList;
}
//初始化
public constructor() {
super();
this.initData();
}
/** 初始化后执行 */
protected _initData() { }
protected initLogic(){};
/**
* 初始化 使用时覆盖
*/
protected initData() {
if (!this.configTemplate) {
this.configTemplate = this.constructor.prototype.configTemplate
}
this.m_dataList = this.configTemplate.datas;
this._initData();
}
}
/**
* Const数据代理基类
*/
export class BaseConstProxy<Data> extends _BaseConfigProxy {
/** 配置表模板 */
protected configTemplate: IConstContainer;
//配置数据
protected m_data:{[key:string]:Data};
/** 配置数据 */
public get data(): {[key:string]:Data} {
return this.m_data;
}
//初始化
public constructor() {
super();
this.initData();
}
/** 初始化后执行 */
protected _initData() { }
protected initLogic(){};
/**
* 初始化 使用时覆盖
*/
protected initData() {
if (!this.configTemplate) {
this.configTemplate = this.constructor.prototype.configTemplate
}
this.m_data = this.configTemplate.data;
this._initData();
}
}