This commit is contained in:
make
2025-04-21 17:49:17 +08:00
parent 7ef217c1b9
commit 2337ab4f7d
942 changed files with 209166 additions and 0 deletions

View 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