UNPKG

qm-ui

Version:

千米公有云管理端UI基础组件库

68 lines (57 loc) 5.29 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @author gcy[of1518] * @date 17/02/16 * * @description 常量类 Const */ var _immutable = require('immutable'); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var QMConst = function () { function QMConst() { _classCallCheck(this, QMConst); this.store = {}; var project = typeof $CONST_PROJECT != 'undefined' ? typeof $CONST_PROJECT === 'string' ? JSON.parse($CONST_PROJECT || '{}') : $CONST_PROJECT : {}; var right = typeof $CONST_RIGHT != 'undefined' ? typeof $CONST_RIGHT === 'string' ? JSON.parse($CONST_RIGHT || '{}') : $CONST_RIGHT : {}; var host = typeof $CONST_HOST != 'undefined' ? typeof $CONST_HOST === 'string' ? JSON.parse($CONST_HOST || '{}') : $CONST_HOST : {}; this.store = (0, _immutable.fromJS)({ project: project, right: right, host: host }); this.HOST = host; this.PROJECT = project; this.RIGHT = right; } _createClass(QMConst, [{ key: 'get', value: function get(path) { var result = undefined; if (typeof path === 'string') { path = path.split('.'); if (path.length > 0) { result = this.store.getIn(path); } else { result = this.store.get(path[0]); } } else if (path instanceof Array) { result = this.store.getIn(path); } else { result = this.store; } return result && result.toJS ? result.toJS() : result; } }, { key: 'getIn', value: function getIn(array) { var result = undefined; if (array instanceof Array) { result = this.store.getIn(array); } else { result = this.store; } return result; } }]); return QMConst; }(); exports.default = new QMConst();