debug
This commit is contained in:
49
code/public/template/shikong/huiyuan/js/class/config.js
Normal file
49
code/public/template/shikong/huiyuan/js/class/config.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import EncAndDec from '../public/enc.js'
|
||||
|
||||
/**
|
||||
* 后台-网站配置数据
|
||||
*/
|
||||
class Configs {
|
||||
|
||||
constructor() {
|
||||
// 初始化配置数据
|
||||
this.arrConfigs = this.getAll();
|
||||
|
||||
}
|
||||
|
||||
// 添加或更新配置项
|
||||
set(key, value) {
|
||||
this.arrConfigs[key] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置项
|
||||
* @param {string} strKey
|
||||
* @param {string} strType
|
||||
* @returns string | int | null
|
||||
*/
|
||||
get(strKey,strType=null) {
|
||||
return
|
||||
let intIndex = this.arrConfigs.findIndex((item) => strKey == item.conf_code)
|
||||
let strVal = intIndex != -1 ? this.arrConfigs[intIndex].conf_val : null;
|
||||
if(strType == 'int' && strVal != null)[
|
||||
strVal = parseInt(strVal)
|
||||
]
|
||||
return strVal;
|
||||
}
|
||||
|
||||
// 读取所有配置数据
|
||||
getAll() {
|
||||
return
|
||||
let configEncoded = EncAndDec.decryptData(configEncodedData, configDecData.MIAO_API_ENCRYPT_KEY);
|
||||
configEncoded = JSON.parse(configEncoded)
|
||||
return configEncoded.data;
|
||||
}
|
||||
}
|
||||
export default Configs ;
|
||||
|
||||
|
||||
// 使用示例
|
||||
// var configs = new Configs();
|
||||
// console.log(Configs.get('PLAY_CCTV_OPENING_TIME','int'));
|
||||
// console.log(configs.get('PLAY_CCTV_OPENING_TIME','int')); // 输出特定配置:blue
|
||||
Reference in New Issue
Block a user