2016-07-02 06:49:59 +08:00
|
|
|
import window from 'window';
|
2020-07-20 20:33:33 +08:00
|
|
|
import { isUnd, isNormal, isArray } from 'Common/Utils';
|
2015-11-15 08:23:16 +08:00
|
|
|
|
2016-06-16 07:36:44 +08:00
|
|
|
let SETTINGS = window.__rlah_data() || null;
|
|
|
|
SETTINGS = isNormal(SETTINGS) ? SETTINGS : {};
|
2015-11-15 08:23:16 +08:00
|
|
|
|
2016-06-16 07:36:44 +08:00
|
|
|
let APP_SETTINGS = SETTINGS.System || null;
|
|
|
|
APP_SETTINGS = isNormal(APP_SETTINGS) ? APP_SETTINGS : {};
|
2015-11-15 08:23:16 +08:00
|
|
|
|
2016-06-16 07:36:44 +08:00
|
|
|
/**
|
|
|
|
* @param {string} name
|
2016-06-30 08:02:45 +08:00
|
|
|
* @returns {*}
|
2016-06-16 07:36:44 +08:00
|
|
|
*/
|
2019-07-05 03:19:24 +08:00
|
|
|
export function settingsGet(name) {
|
2016-06-16 07:36:44 +08:00
|
|
|
return isUnd(SETTINGS[name]) ? null : SETTINGS[name];
|
|
|
|
}
|
2015-11-15 08:23:16 +08:00
|
|
|
|
2016-06-16 07:36:44 +08:00
|
|
|
/**
|
|
|
|
* @param {string} name
|
|
|
|
* @param {*} value
|
|
|
|
*/
|
2019-07-05 03:19:24 +08:00
|
|
|
export function settingsSet(name, value) {
|
2016-06-16 07:36:44 +08:00
|
|
|
SETTINGS[name] = value;
|
|
|
|
}
|
2016-04-30 07:42:18 +08:00
|
|
|
|
2016-06-16 07:36:44 +08:00
|
|
|
/**
|
|
|
|
* @param {string} name
|
2016-06-30 08:02:45 +08:00
|
|
|
* @returns {*}
|
2016-06-16 07:36:44 +08:00
|
|
|
*/
|
2019-07-05 03:19:24 +08:00
|
|
|
export function appSettingsGet(name) {
|
2016-06-16 07:36:44 +08:00
|
|
|
return isUnd(APP_SETTINGS[name]) ? null : APP_SETTINGS[name];
|
2015-11-15 08:23:16 +08:00
|
|
|
}
|
|
|
|
|
2016-06-16 07:36:44 +08:00
|
|
|
/**
|
|
|
|
* @param {string} name
|
2016-06-30 08:02:45 +08:00
|
|
|
* @returns {boolean}
|
2016-06-16 07:36:44 +08:00
|
|
|
*/
|
2019-07-05 03:19:24 +08:00
|
|
|
export function capa(name) {
|
2016-06-16 07:36:44 +08:00
|
|
|
const values = settingsGet('Capa');
|
2020-07-20 20:33:33 +08:00
|
|
|
return isArray(values) && isNormal(name) && values.includes(name);
|
2016-06-16 07:36:44 +08:00
|
|
|
}
|