2015-11-15 08:23:16 +08:00
|
|
|
|
|
|
|
import {window} from 'common';
|
|
|
|
import Utils from 'Common/Utils';
|
|
|
|
|
|
|
|
class SettingsStorage
|
|
|
|
{
|
2016-04-30 07:42:18 +08:00
|
|
|
settings = {};
|
|
|
|
appSettings = {};
|
|
|
|
|
2015-11-15 08:23:16 +08:00
|
|
|
constructor() {
|
2016-05-20 08:04:15 +08:00
|
|
|
this.settings = window.__rlah_data() || {};
|
2016-04-21 01:12:51 +08:00
|
|
|
this.settings = Utils.isNormal(this.settings) ? this.settings : {};
|
2016-04-30 07:42:18 +08:00
|
|
|
|
2016-05-07 03:06:16 +08:00
|
|
|
this.appSettings = this.settings.System || null;
|
2016-04-30 07:42:18 +08:00
|
|
|
this.appSettings = Utils.isNormal(this.appSettings) ? this.appSettings : {};
|
2015-11-15 08:23:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
|
|
|
* @return {*}
|
|
|
|
*/
|
|
|
|
settingsGet(name) {
|
|
|
|
return Utils.isUnd(this.settings[name]) ? null : this.settings[name];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
|
|
|
* @param {*} value
|
|
|
|
*/
|
|
|
|
settingsSet(name, value) {
|
|
|
|
this.settings[name] = value;
|
|
|
|
}
|
|
|
|
|
2016-04-30 07:42:18 +08:00
|
|
|
/**
|
|
|
|
* @param {string} name
|
|
|
|
* @return {*}
|
|
|
|
*/
|
|
|
|
appSettingsGet(name) {
|
|
|
|
return Utils.isUnd(this.appSettings[name]) ? null : this.appSettings[name];
|
|
|
|
}
|
|
|
|
|
2015-11-15 08:23:16 +08:00
|
|
|
/**
|
|
|
|
* @param {string} name
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
capa(name) {
|
|
|
|
const values = this.settingsGet('Capa');
|
|
|
|
return Utils.isArray(values) && Utils.isNormal(name) && -1 < Utils.inArray(name, values);
|
2016-04-21 01:12:51 +08:00
|
|
|
}
|
2015-11-15 08:23:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = new SettingsStorage();
|