1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| const EE = require('../ee');
|
| const conf = {
|
| /**
| * 获取 内存中的config
| */
| _getConfig(withError = true) {
| const { CoreApp } = EE;
| if (!CoreApp && withError) {
| throw new Error(`[ee-core] [config] Frame initialization is not complete !`);
| }
| if (!CoreApp) {
| return null;
| }
|
| return CoreApp.config;
| },
|
| /**
| * all
| */
| all(withError = true) {
| return this._getConfig(withError);
| },
|
| /**
| * getValue
| */
| getValue(key) {
| const v = this._objectGet(this._getConfig(), key);
| return v;
| },
|
| _objectGet(object, path, defaultValue) {
| const pathParts = Array.isArray(path) ? path : path.split('.');
| const value = pathParts.reduce((obj, key) => obj && key in obj ? obj[key] : undefined, object);
| return value === undefined ? defaultValue : value;
| }
| };
|
| module.exports = conf;
|
|