添加默认配置

This commit is contained in:
zpc 2025-03-24 04:20:41 +08:00
parent 6f5e1e1790
commit 4c15cabee2

View File

@ -8,6 +8,10 @@ import RequestManager from '@/common/request.js'
let configData = null;
let isLoading = false;
let loadPromise = null;
const defaultConfig = {
"good_type": [{ "value": 0, "sort_order": 0, "is_show": 1, "name": "全部", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 1, "sort_order": 1, "is_show": 0, "name": "一番赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 2, "sort_order": 2, "is_show": 1, "name": "无限赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 3, "sort_order": 3, "is_show": 0, "name": "擂台赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 5, "sort_order": 4, "is_show": 0, "name": "积分赏", "pay_wechat": 0, "pay_balance": 0, "pay_currency": 0, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 0 }, { "value": 6, "sort_order": 5, "is_show": 1, "name": "全局赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 8, "sort_order": 6, "is_show": 1, "name": "领主赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 9, "sort_order": 7, "is_show": 1, "name": "连击赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 10, "sort_order": 8, "is_show": 0, "name": "商城赏", "pay_wechat": 1, "pay_balance": 0, "pay_currency": 0, "pay_currency2": 1, "pay_coupon": 0, "is_deduction": 0 }, { "value": 11, "sort_order": 9, "is_show": 0, "name": "自制赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }],
"app_setting": { "key": "app_setting", "app_name": "友达赏", "purchase_popup": "1", "exchange_times": "2", "balance_name": "钻石", "balance_icon": "https://mh.shhuanmeng.com/app/icons/20250322/3d823aaa01e96aeeafc39cbb2d579612.jpg", "currency1_name": "货币", "currency1_icon": "https://mh.shhuanmeng.com/app/icons/20250322/8188634352e7f9edf5a2a42329b7c2c9.jpg", "currency2_name": "积分1", "currency2_icon": "", "win_audio": "https://mh.shhuanmeng.com/static/web/static/mp3/open.mp3", "update_time": 1742716262 }
};
// 配置类
class ConfigManager {
@ -77,14 +81,22 @@ class ConfigManager {
* @param {any} defaultValue 默认值当键不存在时返回
* @returns {any} 配置值
*/
static get(key, defaultValue = null) {
static get(key) {
if (!configData) {
console.warn('配置数据尚未加载,获取本地缓存中。。。');
configData = uni.getStorageSync("configData");
if (configData != null) {
if (configData != null && configData != "") {
return configData;
}
return defaultValue;
configData = defaultConfig;
// wx.restartMiniProgram({
// success(res) {
// console.log('重启小程序成功', res);
// },
// fail(err) {
// console.error('重启小程序失败', err);
// }
// });
}
return key in configData ? configData[key] : defaultValue;
}