antd-management-fast-framework 1.12.40 → 1.12.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/utils/Authorized.js +5 -3
- package/es/utils/appConfiguration.d.ts +1 -0
- package/es/utils/appConfiguration.js +7 -0
- package/es/utils/authority.js +4 -2
- package/es/utils/cacheAssist.js +12 -8
- package/es/utils/developAssist.d.ts +41 -0
- package/es/utils/developAssist.js +224 -0
- package/es/utils/globalStorageAssist.js +16 -14
- package/es/utils/localStorageAssist.d.ts +47 -0
- package/es/utils/localStorageAssist.js +114 -0
- package/es/utils/mediaDefault.d.ts +1 -1
- package/es/utils/mediaDefault.js +2 -2
- package/es/utils/sessionStorageAssist.d.ts +47 -0
- package/es/utils/sessionStorageAssist.js +114 -0
- package/es/utils/tools.d.ts +7 -108
- package/es/utils/tools.js +40 -394
- package/es/utils/typeCheck.d.ts +13 -0
- package/es/utils/typeCheck.js +37 -0
- package/package.json +2 -2
package/es/utils/Authorized.js
CHANGED
|
@@ -11,12 +11,14 @@ var _Authorized = _interopRequireDefault(require("../customComponents/Authorized
|
|
|
11
11
|
|
|
12
12
|
var _globalStorageAssist = require("./globalStorageAssist");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _localStorageAssist = require("./localStorageAssist");
|
|
15
|
+
|
|
16
|
+
var _typeCheck = require("./typeCheck");
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
20
|
function getAuthority(str) {
|
|
19
|
-
var authorityString = typeof str === 'undefined' ? (0,
|
|
21
|
+
var authorityString = typeof str === 'undefined' ? (0, _localStorageAssist.getStringFromLocalStorage)(_globalStorageAssist.storageKeyCollection.authorityCollection) : str;
|
|
20
22
|
var authority;
|
|
21
23
|
|
|
22
24
|
try {
|
|
@@ -31,7 +33,7 @@ function getAuthority(str) {
|
|
|
31
33
|
return [authority];
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
if ((0,
|
|
36
|
+
if ((0, _typeCheck.isArray)(authority)) {
|
|
35
37
|
return authority;
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -31,6 +31,7 @@ export function getAppInitConfigData(): {
|
|
|
31
31
|
tinymceApiKey: string;
|
|
32
32
|
tinymceImagesUploadUrl: string;
|
|
33
33
|
};
|
|
34
|
+
export function logShowInConsole(): boolean;
|
|
34
35
|
export function getTinymceImagesUploadUrl(): string;
|
|
35
36
|
export function getTinymceApiKey(): string;
|
|
36
37
|
export function getUseNprogress(): boolean;
|
|
@@ -34,6 +34,7 @@ exports.getTitle = getTitle;
|
|
|
34
34
|
exports.getUseNprogress = getUseNprogress;
|
|
35
35
|
exports.getUseVirtualRequest = getUseVirtualRequest;
|
|
36
36
|
exports.getVideoUploadMaxSize = getVideoUploadMaxSize;
|
|
37
|
+
exports.logShowInConsole = logShowInConsole;
|
|
37
38
|
|
|
38
39
|
var _constants = require("./constants");
|
|
39
40
|
|
|
@@ -61,6 +62,12 @@ function getAppInitConfigData() {
|
|
|
61
62
|
return appInitConfig;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
function logShowInConsole() {
|
|
66
|
+
var appInit = getAppInitConfigData();
|
|
67
|
+
var result = !!(appInit.showLogInConsole || false);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
function getTinymceImagesUploadUrl() {
|
|
65
72
|
var appInit = getAppInitConfigData();
|
|
66
73
|
|
package/es/utils/authority.js
CHANGED
|
@@ -13,6 +13,8 @@ var _cacheAssist = require("./cacheAssist");
|
|
|
13
13
|
|
|
14
14
|
var _globalStorageAssist = require("./globalStorageAssist");
|
|
15
15
|
|
|
16
|
+
var _localStorageAssist = require("./localStorageAssist");
|
|
17
|
+
|
|
16
18
|
var _tools = require("./tools");
|
|
17
19
|
|
|
18
20
|
var authorityCollectionCache = 'authorityCollectionCache';
|
|
@@ -34,7 +36,7 @@ function getAllAuthorityCore() {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
var authorityString = (0,
|
|
39
|
+
var authorityString = (0, _localStorageAssist.getStringFromLocalStorage)(_globalStorageAssist.storageKeyCollection.authorityCollection);
|
|
38
40
|
var authority;
|
|
39
41
|
|
|
40
42
|
try {
|
|
@@ -250,7 +252,7 @@ function checkHasAuthority(auth) {
|
|
|
250
252
|
|
|
251
253
|
function setAuthority(authority) {
|
|
252
254
|
var authorityCollection = typeof authority === 'string' ? [authority] : authority;
|
|
253
|
-
(0,
|
|
255
|
+
(0, _localStorageAssist.saveJsonToLocalStorage)(_globalStorageAssist.storageKeyCollection.authorityCollection, authorityCollection);
|
|
254
256
|
(0, _cacheAssist.flushAllCache)(); // auto reload
|
|
255
257
|
|
|
256
258
|
(0, _Authorized.reloadAuthorized)();
|
package/es/utils/cacheAssist.js
CHANGED
|
@@ -20,7 +20,11 @@ exports.takeCache = takeCache;
|
|
|
20
20
|
|
|
21
21
|
var _nodeCache = _interopRequireDefault(require("node-cache"));
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _core = require("./core");
|
|
24
|
+
|
|
25
|
+
var _developAssist = require("./developAssist");
|
|
26
|
+
|
|
27
|
+
var _typeCheck = require("./typeCheck");
|
|
24
28
|
|
|
25
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
30
|
|
|
@@ -31,12 +35,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
31
35
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
36
|
|
|
33
37
|
function checkKey(key) {
|
|
34
|
-
if ((0,
|
|
38
|
+
if ((0, _core.stringIsNullOrWhiteSpace)(key)) {
|
|
35
39
|
throw new Error('cache key is null or empty');
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
if (!((0,
|
|
39
|
-
(0,
|
|
42
|
+
if (!((0, _typeCheck.isString)(key) || (0, _typeCheck.isNumber)(key))) {
|
|
43
|
+
(0, _developAssist.recordError)(key);
|
|
40
44
|
throw new Error('cache key must be string or number,you can check it in console');
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -100,7 +104,7 @@ function setCache(_ref2) {
|
|
|
100
104
|
|
|
101
105
|
|
|
102
106
|
function setMultiCache(list) {
|
|
103
|
-
if (!(0,
|
|
107
|
+
if (!(0, _typeCheck.isArray)(list)) {
|
|
104
108
|
throw new Error('setMultiCache: list must be array');
|
|
105
109
|
}
|
|
106
110
|
|
|
@@ -119,7 +123,7 @@ function setMultiCache(list) {
|
|
|
119
123
|
value = _key$value$expiration.value,
|
|
120
124
|
expiration = _key$value$expiration.expiration;
|
|
121
125
|
|
|
122
|
-
if (!(0,
|
|
126
|
+
if (!(0, _core.stringIsNullOrWhiteSpace)(key)) {
|
|
123
127
|
checkKey(key);
|
|
124
128
|
listData.push({
|
|
125
129
|
key: key,
|
|
@@ -203,7 +207,7 @@ function getCache(_ref5) {
|
|
|
203
207
|
|
|
204
208
|
|
|
205
209
|
function getMultiCache(list) {
|
|
206
|
-
if (!(0,
|
|
210
|
+
if (!(0, _typeCheck.isArray)(list)) {
|
|
207
211
|
throw new Error('getMultiCache: list must be array');
|
|
208
212
|
}
|
|
209
213
|
|
|
@@ -258,7 +262,7 @@ function deleteCache(_ref7) {
|
|
|
258
262
|
|
|
259
263
|
|
|
260
264
|
function deleteMultiCache(list) {
|
|
261
|
-
if (!(0,
|
|
265
|
+
if (!(0, _typeCheck.isArray)(list)) {
|
|
262
266
|
throw new Error('deleteMultiCache: list must be array');
|
|
263
267
|
}
|
|
264
268
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记录日志
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @param {*} str
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export function recordLog(record: any, showMode: any, level?: string): void;
|
|
9
|
+
export function recordWarn(record: any): void;
|
|
10
|
+
export function recordInfo(record: any): void;
|
|
11
|
+
export function recordDebug(record: any): void;
|
|
12
|
+
/**
|
|
13
|
+
* 记录错误信息
|
|
14
|
+
*/
|
|
15
|
+
export function recordError(record: any): void;
|
|
16
|
+
/**
|
|
17
|
+
* 记录日志
|
|
18
|
+
*
|
|
19
|
+
* @export
|
|
20
|
+
* @param {*} str
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function recordText(record: any, level?: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* 记录日志
|
|
26
|
+
*
|
|
27
|
+
* @export
|
|
28
|
+
* @param {*} str
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export function recordObject(record: any, level?: string): void;
|
|
32
|
+
export function getNearestLocalhostNotifyCache(): any;
|
|
33
|
+
export function setNearestLocalhostNotifyCache(): void;
|
|
34
|
+
export function removeNearestLocalhostNotifyCache(): void;
|
|
35
|
+
/**
|
|
36
|
+
* 占位函数
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export function empty(): {};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.empty = empty;
|
|
7
|
+
exports.getNearestLocalhostNotifyCache = getNearestLocalhostNotifyCache;
|
|
8
|
+
exports.recordDebug = recordDebug;
|
|
9
|
+
exports.recordError = recordError;
|
|
10
|
+
exports.recordInfo = recordInfo;
|
|
11
|
+
exports.recordLog = recordLog;
|
|
12
|
+
exports.recordObject = recordObject;
|
|
13
|
+
exports.recordText = recordText;
|
|
14
|
+
exports.recordWarn = recordWarn;
|
|
15
|
+
exports.removeNearestLocalhostNotifyCache = removeNearestLocalhostNotifyCache;
|
|
16
|
+
exports.setNearestLocalhostNotifyCache = setNearestLocalhostNotifyCache;
|
|
17
|
+
|
|
18
|
+
var _appConfiguration = require("./appConfiguration");
|
|
19
|
+
|
|
20
|
+
var _constants = require("./constants");
|
|
21
|
+
|
|
22
|
+
var _core = require("./core");
|
|
23
|
+
|
|
24
|
+
var _localStorageAssist = require("./localStorageAssist");
|
|
25
|
+
|
|
26
|
+
var _typeCheck = require("./typeCheck");
|
|
27
|
+
|
|
28
|
+
var storageKeyCollection = {
|
|
29
|
+
nearestLocalhostNotify: 'nearestLocalhostNotify'
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 记录日志
|
|
33
|
+
*
|
|
34
|
+
* @export
|
|
35
|
+
* @param {*} str
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
function recordLog(record, showMode) {
|
|
40
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _constants.logLevel.debug;
|
|
41
|
+
var showModeModified = (showMode || null) == null || (0, _core.stringIsNullOrWhiteSpace)(showMode) ? _constants.logShowMode.unknown : showMode;
|
|
42
|
+
|
|
43
|
+
if (!inCollection([_constants.logShowMode.unknown, _constants.logShowMode.text, _constants.logShowMode.object], showModeModified)) {
|
|
44
|
+
throw new Error("\u65E0\u6548\u7684\u65E5\u5FD7\u663E\u793A\u6A21\u5F0F:".concat(showModeModified));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (showModeModified === _constants.logShowMode.unknown) {
|
|
48
|
+
if ((0, _typeCheck.isString)(record)) {
|
|
49
|
+
showModeModified = _constants.logShowMode.text;
|
|
50
|
+
} else {
|
|
51
|
+
showModeModified = _constants.logShowMode.object;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if ((0, _appConfiguration.logShowInConsole)() && level === _constants.logLevel.debug) {
|
|
56
|
+
if (showModeModified === _constants.logShowMode.text) {
|
|
57
|
+
var data = {
|
|
58
|
+
record: record,
|
|
59
|
+
level: level
|
|
60
|
+
};
|
|
61
|
+
console.log('%c%s', 'color:#00768f;', JSON.stringify(data));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (showModeModified === _constants.logShowMode.object) {
|
|
65
|
+
console.log({
|
|
66
|
+
record: record,
|
|
67
|
+
level: level
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if ((0, _appConfiguration.logShowInConsole)() && level === _constants.logLevel.warn) {
|
|
73
|
+
if (showModeModified === _constants.logShowMode.text) {
|
|
74
|
+
var _data = {
|
|
75
|
+
record: record,
|
|
76
|
+
level: level
|
|
77
|
+
};
|
|
78
|
+
console.log('%c%s', 'color:#ff4f49;', JSON.stringify(_data));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (showModeModified === _constants.logShowMode.object) {
|
|
82
|
+
console.log({
|
|
83
|
+
record: record,
|
|
84
|
+
level: level
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ((0, _appConfiguration.logShowInConsole)() && level === _constants.logLevel.info) {
|
|
90
|
+
if (showModeModified === _constants.logShowMode.text) {
|
|
91
|
+
var _data2 = {
|
|
92
|
+
record: record,
|
|
93
|
+
level: level
|
|
94
|
+
};
|
|
95
|
+
console.log('%c%s', 'color:#89ca78;', JSON.stringify(_data2));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (showModeModified === _constants.logShowMode.object) {
|
|
99
|
+
console.log({
|
|
100
|
+
record: record,
|
|
101
|
+
level: level
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (level === _constants.logLevel.error) {
|
|
107
|
+
if (showModeModified === _constants.logShowMode.text) {
|
|
108
|
+
var _data3 = {
|
|
109
|
+
record: record,
|
|
110
|
+
level: level
|
|
111
|
+
};
|
|
112
|
+
console.error(JSON.stringify(_data3));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (showModeModified === _constants.logShowMode.object) {
|
|
116
|
+
console.error({
|
|
117
|
+
record: record,
|
|
118
|
+
level: level
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function recordWarn(record) {
|
|
125
|
+
if ((0, _typeCheck.isString)(record)) {
|
|
126
|
+
recordText(record, _constants.logLevel.warn);
|
|
127
|
+
} else {
|
|
128
|
+
recordObject(record, _constants.logLevel.warn);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function recordInfo(record) {
|
|
133
|
+
if ((0, _typeCheck.isString)(record)) {
|
|
134
|
+
recordText(record, _constants.logLevel.info);
|
|
135
|
+
} else {
|
|
136
|
+
recordObject(record, _constants.logLevel.info);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function recordDebug(record) {
|
|
141
|
+
if ((0, _typeCheck.isString)(record)) {
|
|
142
|
+
recordText(record, _constants.logLevel.debug);
|
|
143
|
+
} else {
|
|
144
|
+
recordObject(record, _constants.logLevel.debug);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 记录错误信息
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
function recordError(record) {
|
|
153
|
+
if ((0, _typeCheck.isString)(record)) {
|
|
154
|
+
recordText(record, _constants.logLevel.error);
|
|
155
|
+
} else {
|
|
156
|
+
recordObject(record, _constants.logLevel.error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* 记录日志
|
|
161
|
+
*
|
|
162
|
+
* @export
|
|
163
|
+
* @param {*} str
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
function recordText(record) {
|
|
169
|
+
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.logLevel.debug;
|
|
170
|
+
recordLog(record, _constants.logShowMode.text, level);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 记录日志
|
|
174
|
+
*
|
|
175
|
+
* @export
|
|
176
|
+
* @param {*} str
|
|
177
|
+
* @returns
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
function recordObject(record) {
|
|
182
|
+
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.logLevel.debug;
|
|
183
|
+
recordLog(record, _constants.logShowMode.object, level);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function getNearestLocalhostNotifyCache() {
|
|
187
|
+
var key = storageKeyCollection.nearestLocalhostNotify;
|
|
188
|
+
var d = (0, _localStorageAssist.getJsonFromLocalStorage)(key);
|
|
189
|
+
|
|
190
|
+
if ((d || null) == null) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if ((d.nearestTime || null) == null) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return d || null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function setNearestLocalhostNotifyCache() {
|
|
202
|
+
var key = storageKeyCollection.nearestLocalhostNotify;
|
|
203
|
+
var now = parseInt(new Date().getTime() / 1000, 10);
|
|
204
|
+
var d = {
|
|
205
|
+
nearestTime: now
|
|
206
|
+
};
|
|
207
|
+
return (0, _localStorageAssist.saveJsonToLocalStorage)(key, d);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function removeNearestLocalhostNotifyCache() {
|
|
211
|
+
var key = storageKeyCollection.nearestLocalhostNotify;
|
|
212
|
+
(0, _localStorageAssist.removeLocalStorage)(key);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 占位函数
|
|
216
|
+
*
|
|
217
|
+
* @export
|
|
218
|
+
* @returns
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
function empty() {
|
|
223
|
+
return {};
|
|
224
|
+
}
|
|
@@ -23,7 +23,9 @@ var _cacheAssist = require("./cacheAssist");
|
|
|
23
23
|
|
|
24
24
|
var _constants = require("./constants");
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _localStorageAssist = require("./localStorageAssist");
|
|
27
|
+
|
|
28
|
+
var _typeCheck = require("./typeCheck");
|
|
27
29
|
|
|
28
30
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
31
|
|
|
@@ -41,7 +43,7 @@ exports.storageKeyCollection = storageKeyCollection;
|
|
|
41
43
|
|
|
42
44
|
function getNearestLocalhostNotifyCache() {
|
|
43
45
|
var key = storageKeyCollection.nearestLocalhostNotify;
|
|
44
|
-
var d = (0,
|
|
46
|
+
var d = (0, _localStorageAssist.getJsonFromLocalStorage)(key);
|
|
45
47
|
|
|
46
48
|
if ((d || null) == null) {
|
|
47
49
|
return null;
|
|
@@ -60,12 +62,12 @@ function setNearestLocalhostNotifyCache() {
|
|
|
60
62
|
var d = {
|
|
61
63
|
nearestTime: now
|
|
62
64
|
};
|
|
63
|
-
return (0,
|
|
65
|
+
return (0, _localStorageAssist.saveJsonToLocalStorage)(key, d);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
function removeNearestLocalhostNotifyCache() {
|
|
67
69
|
var key = storageKeyCollection.nearestLocalhostNotify;
|
|
68
|
-
(0,
|
|
70
|
+
(0, _localStorageAssist.removeLocalStorage)(key);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
function getAccessWayCollectionCache() {
|
|
@@ -80,12 +82,12 @@ function getAccessWayCollectionCache() {
|
|
|
80
82
|
key: key
|
|
81
83
|
});
|
|
82
84
|
|
|
83
|
-
if ((0,
|
|
85
|
+
if ((0, _typeCheck.isArray)(result)) {
|
|
84
86
|
return result;
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
var d = (0,
|
|
90
|
+
var d = (0, _localStorageAssist.getJsonFromLocalStorage)(key);
|
|
89
91
|
|
|
90
92
|
if ((d || null) == null) {
|
|
91
93
|
return _objectSpread({}, _constants.accessWaySpecialCollection || {});
|
|
@@ -101,7 +103,7 @@ function getAccessWayCollectionCache() {
|
|
|
101
103
|
|
|
102
104
|
function setAccessWayCollectionCache(o) {
|
|
103
105
|
var key = storageKeyCollection.accessWayCollection;
|
|
104
|
-
(0,
|
|
106
|
+
(0, _localStorageAssist.saveJsonToLocalStorage)(key, o || {});
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
107
109
|
* 获取useParamsData缓存
|
|
@@ -113,7 +115,7 @@ function setAccessWayCollectionCache(o) {
|
|
|
113
115
|
|
|
114
116
|
|
|
115
117
|
function getParamsDataCache(key) {
|
|
116
|
-
var d = (0,
|
|
118
|
+
var d = (0, _localStorageAssist.getJsonFromLocalStorage)(key);
|
|
117
119
|
|
|
118
120
|
if ((d || null) == null) {
|
|
119
121
|
removeParamsDataCache(key);
|
|
@@ -149,7 +151,7 @@ function setParamsDataCache(key, o) {
|
|
|
149
151
|
useParamsData: o || null,
|
|
150
152
|
dataVersion: now
|
|
151
153
|
};
|
|
152
|
-
return (0,
|
|
154
|
+
return (0, _localStorageAssist.saveJsonToLocalStorage)(key, d);
|
|
153
155
|
}
|
|
154
156
|
/**
|
|
155
157
|
* 移除信息
|
|
@@ -161,7 +163,7 @@ function setParamsDataCache(key, o) {
|
|
|
161
163
|
|
|
162
164
|
|
|
163
165
|
function removeParamsDataCache(key) {
|
|
164
|
-
(0,
|
|
166
|
+
(0, _localStorageAssist.removeLocalStorage)(key);
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* 获取Token键名
|
|
@@ -186,7 +188,7 @@ function getTokenKeyName() {
|
|
|
186
188
|
|
|
187
189
|
function getToken() {
|
|
188
190
|
var key = storageKeyCollection.token;
|
|
189
|
-
return (0,
|
|
191
|
+
return (0, _localStorageAssist.getStringFromLocalStorage)(key);
|
|
190
192
|
}
|
|
191
193
|
/**
|
|
192
194
|
* Set Token
|
|
@@ -199,7 +201,7 @@ function getToken() {
|
|
|
199
201
|
|
|
200
202
|
function setToken(v) {
|
|
201
203
|
var key = storageKeyCollection.token;
|
|
202
|
-
return (0,
|
|
204
|
+
return (0, _localStorageAssist.saveStringToLocalStorage)(key, v);
|
|
203
205
|
}
|
|
204
206
|
/**
|
|
205
207
|
* 移除Token
|
|
@@ -212,7 +214,7 @@ function setToken(v) {
|
|
|
212
214
|
|
|
213
215
|
function removeToken() {
|
|
214
216
|
var key = storageKeyCollection.token;
|
|
215
|
-
return (0,
|
|
217
|
+
return (0, _localStorageAssist.removeLocalStorage)(key);
|
|
216
218
|
}
|
|
217
219
|
|
|
218
220
|
function getTokenObject() {
|
|
@@ -228,5 +230,5 @@ function getTokenObject() {
|
|
|
228
230
|
|
|
229
231
|
|
|
230
232
|
function clearCustomData() {
|
|
231
|
-
(0,
|
|
233
|
+
(0, _localStorageAssist.clearLocalStorage)();
|
|
232
234
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取LocalStorage数据
|
|
3
|
+
* @export
|
|
4
|
+
* @param {*} key
|
|
5
|
+
* @param {*} value
|
|
6
|
+
*/
|
|
7
|
+
export function getStringFromLocalStorage(key: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* 获取LocalStorage数据
|
|
10
|
+
* @export
|
|
11
|
+
* @param {*} key
|
|
12
|
+
* @param {*} value
|
|
13
|
+
*/
|
|
14
|
+
export function getJsonFromLocalStorage(key: any): any;
|
|
15
|
+
/**
|
|
16
|
+
* 存储本地数据
|
|
17
|
+
* @export
|
|
18
|
+
* @param {*} key
|
|
19
|
+
* @param {*} value
|
|
20
|
+
*/
|
|
21
|
+
export function saveStringToLocalStorage(key: any, value: any): void;
|
|
22
|
+
/**
|
|
23
|
+
* 存储本地数据
|
|
24
|
+
* @export
|
|
25
|
+
* @param {*} key
|
|
26
|
+
* @param {*} value
|
|
27
|
+
*/
|
|
28
|
+
export function saveJsonToLocalStorage(key: any, json: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* 移除LocalStorage数据
|
|
31
|
+
* @export
|
|
32
|
+
* @param {*} key
|
|
33
|
+
*/
|
|
34
|
+
export function removeLocalStorage(key: any): void;
|
|
35
|
+
/**
|
|
36
|
+
* 清空LocalStorage数据
|
|
37
|
+
* @export
|
|
38
|
+
* @param {*} key
|
|
39
|
+
*/
|
|
40
|
+
export function clearLocalStorage(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 占位函数
|
|
43
|
+
*
|
|
44
|
+
* @export
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
export function empty(): {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clearLocalStorage = clearLocalStorage;
|
|
7
|
+
exports.empty = empty;
|
|
8
|
+
exports.getJsonFromLocalStorage = getJsonFromLocalStorage;
|
|
9
|
+
exports.getStringFromLocalStorage = getStringFromLocalStorage;
|
|
10
|
+
exports.removeLocalStorage = removeLocalStorage;
|
|
11
|
+
exports.saveJsonToLocalStorage = saveJsonToLocalStorage;
|
|
12
|
+
exports.saveStringToLocalStorage = saveStringToLocalStorage;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 获取LocalStorage数据
|
|
16
|
+
* @export
|
|
17
|
+
* @param {*} key
|
|
18
|
+
* @param {*} value
|
|
19
|
+
*/
|
|
20
|
+
function getStringFromLocalStorage(key) {
|
|
21
|
+
var storage = window.localStorage;
|
|
22
|
+
var value = storage.getItem(key);
|
|
23
|
+
|
|
24
|
+
if (process.env.NODE_ENV === 'development') {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var decode = decodeBase64(value);
|
|
29
|
+
var v = encodeBase64(decode);
|
|
30
|
+
|
|
31
|
+
if (value !== v) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return decode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 获取LocalStorage数据
|
|
39
|
+
* @export
|
|
40
|
+
* @param {*} key
|
|
41
|
+
* @param {*} value
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function getJsonFromLocalStorage(key) {
|
|
46
|
+
var jsonString = getStringFromLocalStorage(key);
|
|
47
|
+
|
|
48
|
+
if (jsonString) {
|
|
49
|
+
return JSON.parse(jsonString || '{}');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 存储本地数据
|
|
56
|
+
* @export
|
|
57
|
+
* @param {*} key
|
|
58
|
+
* @param {*} value
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
function saveStringToLocalStorage(key, value) {
|
|
63
|
+
var storage = window.localStorage;
|
|
64
|
+
|
|
65
|
+
if (process.env.NODE_ENV === 'development') {
|
|
66
|
+
storage.setItem(key, value);
|
|
67
|
+
} else {
|
|
68
|
+
storage.setItem(key, encodeBase64(value));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 存储本地数据
|
|
73
|
+
* @export
|
|
74
|
+
* @param {*} key
|
|
75
|
+
* @param {*} value
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
function saveJsonToLocalStorage(key, json) {
|
|
80
|
+
saveStringToLocalStorage(key, JSON.stringify(json || {}));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 移除LocalStorage数据
|
|
84
|
+
* @export
|
|
85
|
+
* @param {*} key
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
function removeLocalStorage(key) {
|
|
90
|
+
var storage = window.localStorage;
|
|
91
|
+
storage.removeItem(key);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 清空LocalStorage数据
|
|
95
|
+
* @export
|
|
96
|
+
* @param {*} key
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
function clearLocalStorage() {
|
|
101
|
+
var storage = window.localStorage;
|
|
102
|
+
storage.clear();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 占位函数
|
|
106
|
+
*
|
|
107
|
+
* @export
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function empty() {
|
|
113
|
+
return {};
|
|
114
|
+
}
|