@lambo-design/shared 1.0.0-beta.222 → 1.0.0-beta.224
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/config/themes/atrovirens/atrovirens.css +2 -1
- package/config/themes/atrovirens/atrovirens.less +2 -1
- package/config/themes/atrovirens/var.less +2 -1
- package/config/themes/blue/blue.css +2 -1
- package/config/themes/blue/blue.less +2 -1
- package/config/themes/blue/var.less +2 -0
- package/config/themes/blue-white/blue-white.css +2 -1
- package/config/themes/blue-white/blue-white.less +2 -1
- package/config/themes/blue-white/var.less +2 -0
- package/config/themes/blue-white-tight/blue-white-tight.css +2 -1
- package/config/themes/blue-white-tight/blue-white-tight.less +2 -0
- package/config/themes/blue-white-tight/var.less +2 -0
- package/config/themes/danqing/danqing.css +2 -1
- package/config/themes/danqing/danqing.less +3 -1
- package/config/themes/danqing/var.less +3 -1
- package/config/themes/deep/deep.css +2 -1
- package/config/themes/deep/deep.less +2 -0
- package/config/themes/deep/var.less +2 -0
- package/config/themes/default/default.css +2 -1
- package/config/themes/default/default.less +2 -0
- package/config/themes/default/var.less +2 -0
- package/config/themes/eap/eap.css +2 -1
- package/config/themes/eap/eap.less +2 -0
- package/config/themes/eap/var.less +2 -0
- package/config/themes/gold/gold.css +2 -1
- package/config/themes/gold/gold.less +2 -0
- package/config/themes/gold/var.less +2 -0
- package/config/themes/lime/lime.css +2 -1
- package/config/themes/lime/lime.less +2 -0
- package/config/themes/lime/var.less +2 -0
- package/config/themes/orange/orange.css +2 -1
- package/config/themes/orange/orange.less +2 -0
- package/config/themes/orange/var.less +2 -0
- package/config/themes/red/red.css +2 -1
- package/config/themes/red/red.less +2 -0
- package/config/themes/red/var.less +2 -0
- package/config/themes/theme-atrovirens.js +2 -0
- package/config/themes/theme-blue.js +2 -0
- package/config/themes/theme-bw.js +2 -0
- package/config/themes/theme-bwt.js +2 -0
- package/config/themes/theme-danqing.js +2 -0
- package/config/themes/theme-deep.js +2 -0
- package/config/themes/theme-default.js +2 -0
- package/config/themes/theme-eap.js +2 -0
- package/config/themes/theme-gold.js +2 -0
- package/config/themes/theme-lime.js +2 -0
- package/config/themes/theme-orange.js +2 -0
- package/config/themes/theme-red.js +2 -0
- package/package.json +1 -1
- package/utils/dict/index.js +22 -14
- package/utils/storage.js +198 -198
- package/utils/style.js +24 -24
- package/utils/transfer-queue.js +7 -7
- package/utils/type.js +102 -102
- package/utils/crypto/aes.js +0 -23
- package/utils/crypto/rsa.js +0 -16
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(62, 175, 124, 0.2);
|
|
220
220
|
--input-focus-border-color: #3EAF7C;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(48, 107, 227, 0.2);
|
|
220
220
|
--input-focus-border-color: #306BE3;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(72, 138, 255, 0.2);
|
|
220
220
|
--input-focus-border-color: #488aff;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -220,6 +220,7 @@ export default {
|
|
|
220
220
|
--input-hover-border-color-fade-20: rgba(72, 138, 255, 0.2);
|
|
221
221
|
--input-focus-border-color: #488aff;
|
|
222
222
|
--input-disabled-bg: #f3f3f3;
|
|
223
|
+
--input-disabled-color: #ccc;
|
|
223
224
|
--tag-font-size: 12px;
|
|
224
225
|
--screen-xs: 480px;
|
|
225
226
|
--screen-xs-min: 480px;
|
|
@@ -298,6 +299,7 @@ export default {
|
|
|
298
299
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
299
300
|
--form-item-detail-bg-color: #fff;
|
|
300
301
|
--form-item-error-tip-top: 100%;
|
|
302
|
+
--form-item-tip-font-size: 14px;
|
|
301
303
|
--input-wrapper-width: 95%;
|
|
302
304
|
--select-width: 95%;
|
|
303
305
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(37, 139, 115, 0.2);
|
|
220
220
|
--input-focus-border-color: #258b73;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #999;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: #666666;
|
|
298
299
|
--form-item-detail-bg-color: #F9FBFA;
|
|
299
300
|
--form-item-error-tip-top: calc(100% - 20px);
|
|
301
|
+
--form-item-tip-font-size: 12px;
|
|
300
302
|
--input-wrapper-width: 100%;
|
|
301
303
|
--select-width: 100%;
|
|
302
304
|
--date-picker-width: 100%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(34, 91, 176, 0.2);
|
|
220
220
|
--input-focus-border-color: #225bb0;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(0, 145, 255, 0.2);
|
|
220
220
|
--input-focus-border-color: #0091ff;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(0, 145, 255, 0.2);
|
|
220
220
|
--input-focus-border-color: #0091FF;
|
|
221
221
|
--input-disabled-bg: #f8f8f8;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 100%;
|
|
301
303
|
--select-width: 100%;
|
|
302
304
|
--date-picker-width: 200px;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(250, 140, 22, 0.2);
|
|
220
220
|
--input-focus-border-color: #fa8c16;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(82, 196, 26, 0.2);
|
|
220
220
|
--input-focus-border-color: #52c41a;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-error-tip-top: 100%;
|
|
299
300
|
--form-item-detail-bg-color: #fff;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(238, 84, 20, 0.2);
|
|
220
220
|
--input-focus-border-color: #ee5414;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-error-tip-top: 100%;
|
|
299
300
|
--form-item-detail-bg-color: #fff;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
|
@@ -219,6 +219,7 @@ export default {
|
|
|
219
219
|
--input-hover-border-color-fade-20: rgba(255, 52, 87, 0.2);
|
|
220
220
|
--input-focus-border-color: #ff3457;
|
|
221
221
|
--input-disabled-bg: #f3f3f3;
|
|
222
|
+
--input-disabled-color: #ccc;
|
|
222
223
|
--tag-font-size: 12px;
|
|
223
224
|
--screen-xs: 480px;
|
|
224
225
|
--screen-xs-min: 480px;
|
|
@@ -297,6 +298,7 @@ export default {
|
|
|
297
298
|
--form-item-label-text-color: rgba(0, 0, 0, 0.85);
|
|
298
299
|
--form-item-detail-bg-color: #fff;
|
|
299
300
|
--form-item-error-tip-top: 100%;
|
|
301
|
+
--form-item-tip-font-size: 14px;
|
|
300
302
|
--input-wrapper-width: 95%;
|
|
301
303
|
--select-width: 95%;
|
|
302
304
|
--date-picker-width: 95%;
|
package/package.json
CHANGED
package/utils/dict/index.js
CHANGED
|
@@ -5,24 +5,32 @@ import { setSessionStorage, getSessionStorage} from "../platform";
|
|
|
5
5
|
import { axiosN as axios } from '../n/reuqest/axiosN'
|
|
6
6
|
const CONTEXT = '/user-manage-server'
|
|
7
7
|
|
|
8
|
-
export async function getServiceUrlDict(
|
|
9
|
-
if (
|
|
8
|
+
export async function getServiceUrlDict(serviceKeyList,serviceUrlList) {
|
|
9
|
+
if (serviceUrlList.length > 0) {
|
|
10
10
|
try {
|
|
11
|
-
const { data } = await ajax.get(res.serviceUrl)
|
|
12
11
|
let result = {}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
let requests = []
|
|
13
|
+
for (const url of serviceUrlList) {
|
|
14
|
+
requests.push(ajax.get(url))
|
|
15
|
+
}
|
|
16
|
+
const response = await Promise.all(requests);
|
|
17
|
+
// 处理每个响应
|
|
18
|
+
response.forEach((item, index) => {
|
|
19
|
+
if (item.data.code === 1) {
|
|
20
|
+
let dictList = item.data.data;
|
|
21
|
+
result[serviceKeyList[index]] = {};
|
|
22
|
+
if (dictList.length > 0) {
|
|
23
|
+
result[serviceKeyList[index]]['enumList'] = dictList;
|
|
24
|
+
setSessionStorage(serviceKeyList[index] + '_LIST', dictList);
|
|
25
|
+
let dictMap = {};
|
|
26
|
+
for (let dict of dictList) {
|
|
27
|
+
dictMap[dict.K] = dict.V;
|
|
28
|
+
}
|
|
29
|
+
result[serviceKeyList[index]]['enumData'] = dictMap;
|
|
30
|
+
setSessionStorage(serviceKeyList[index] + '_MAP', dictMap);
|
|
21
31
|
}
|
|
22
|
-
result['enumData'] = dictMap
|
|
23
|
-
setSessionStorage(res.formKey + '_MAP', dictMap)
|
|
24
32
|
}
|
|
25
|
-
}
|
|
33
|
+
});
|
|
26
34
|
return result;
|
|
27
35
|
} catch (error) {
|
|
28
36
|
console.error(error)
|
package/utils/storage.js
CHANGED
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019 WeBank
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/* \
|
|
19
|
-
|*|
|
|
20
|
-
|*| :: cookies.js ::
|
|
21
|
-
|*|
|
|
22
|
-
|*| A complete cookies reader/writer framework with full unicode support.
|
|
23
|
-
|*|
|
|
24
|
-
|*| https://developer.mozilla.org/en-US/docs/DOM/document.cookie
|
|
25
|
-
|*|
|
|
26
|
-
|*| This framework is released under the GNU Public License, version 3 or later.
|
|
27
|
-
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
|
28
|
-
|*|
|
|
29
|
-
|*| Syntaxes:
|
|
30
|
-
|*|
|
|
31
|
-
|*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
|
|
32
|
-
|*| * docCookies.getItem(name)
|
|
33
|
-
|*| * docCookies.removeItem(name[, path], domain)
|
|
34
|
-
|*| * docCookies.hasItem(name)
|
|
35
|
-
|*| * docCookies.keys()
|
|
36
|
-
|*|
|
|
37
|
-
\ */
|
|
38
|
-
|
|
39
|
-
let docCookies = {
|
|
40
|
-
getItem: function(sKey) {
|
|
41
|
-
return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
|
|
42
|
-
},
|
|
43
|
-
setItem: function(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
|
|
44
|
-
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
let sExpires = '';
|
|
48
|
-
if (vEnd) {
|
|
49
|
-
switch (vEnd.constructor) {
|
|
50
|
-
case Number:
|
|
51
|
-
sExpires = vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : '; max-age=' + vEnd;
|
|
52
|
-
break;
|
|
53
|
-
case String:
|
|
54
|
-
sExpires = '; expires=' + vEnd;
|
|
55
|
-
break;
|
|
56
|
-
case Date:
|
|
57
|
-
sExpires = '; expires=' + vEnd.toUTCString();
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
document.cookie = encodeURIComponent(sKey) + '=' + encodeURIComponent(sValue) + sExpires + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '') + (bSecure ? '; secure' : '');
|
|
62
|
-
return true;
|
|
63
|
-
},
|
|
64
|
-
removeItem: function(sKey, sPath, sDomain) {
|
|
65
|
-
if (!sKey || !this.hasItem(sKey)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
document.cookie = encodeURIComponent(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '');
|
|
69
|
-
return true;
|
|
70
|
-
},
|
|
71
|
-
hasItem: function(sKey) {
|
|
72
|
-
return (new RegExp('(?:^|;\\s*)' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=')).test(document.cookie);
|
|
73
|
-
},
|
|
74
|
-
keys: /* optional method: you can safely remove it! */ function() {
|
|
75
|
-
let aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, '').split(/\s*(?:\=[^;]*)?;\s*/);
|
|
76
|
-
for (let nIdx = 0; nIdx < aKeys.length; nIdx++) {
|
|
77
|
-
aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);
|
|
78
|
-
}
|
|
79
|
-
return aKeys;
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 操作cookie、sessionStorage、localStorage、缓存
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
SESSION = 'session';
|
|
89
|
-
|
|
90
|
-
const LOCAL = 'local';
|
|
91
|
-
|
|
92
|
-
const COOKIE = 'cookie';
|
|
93
|
-
|
|
94
|
-
export default {
|
|
95
|
-
set: function(key, value, category = SESSION, expired) {
|
|
96
|
-
let { storage, isWebStorage = true } = this._map(category);
|
|
97
|
-
|
|
98
|
-
if (isWebStorage) {
|
|
99
|
-
storageManager.set(key, value, storage);
|
|
100
|
-
} else {
|
|
101
|
-
cookieManager.set(key, value, expired);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
get: function(key, category = SESSION) {
|
|
105
|
-
let { storage, isWebStorage = true } = this._map(category);
|
|
106
|
-
|
|
107
|
-
if (isWebStorage) {
|
|
108
|
-
return storageManager.get(key, storage);
|
|
109
|
-
} else {
|
|
110
|
-
return cookieManager.get(key);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
clear: function(category = SESSION) {
|
|
114
|
-
let { storage, isWebStorage = true } = this._map(category);
|
|
115
|
-
|
|
116
|
-
if (isWebStorage) {
|
|
117
|
-
storageManager.clear(storage);
|
|
118
|
-
} else {
|
|
119
|
-
cookieManager.clear();
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
remove: function(key, category = SESSION) {
|
|
123
|
-
let { storage, isWebStorage = true } = this._map(category);
|
|
124
|
-
|
|
125
|
-
if (isWebStorage) {
|
|
126
|
-
storageManager.remove(key, storage);
|
|
127
|
-
} else {
|
|
128
|
-
cookieManager.remove(key);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
_map: function(category) {
|
|
132
|
-
let isWebStorage = true; let storage;
|
|
133
|
-
|
|
134
|
-
switch (true) {
|
|
135
|
-
case category === SESSION:
|
|
136
|
-
storage = 'sessionStorage';
|
|
137
|
-
break;
|
|
138
|
-
case category === LOCAL:
|
|
139
|
-
storage = 'localStorage';
|
|
140
|
-
break;
|
|
141
|
-
case category === COOKIE:
|
|
142
|
-
storage = 'cookie';
|
|
143
|
-
isWebStorage = false;
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
storage = 'sessionStorage';
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return { isWebStorage, storage };
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
let isProd = process.env.NODE_ENV === 'production';
|
|
154
|
-
|
|
155
|
-
export const storageManager = {
|
|
156
|
-
set: function(key, value, storage) {
|
|
157
|
-
try {
|
|
158
|
-
window[storage].setItem(key, JSON.stringify(value));
|
|
159
|
-
} catch (e) {
|
|
160
|
-
!isProd && console.error(e);
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
get: function(key, storage) {
|
|
164
|
-
try {
|
|
165
|
-
if (window[storage].getItem(key)) {
|
|
166
|
-
return JSON.parse(window[storage].getItem(key));
|
|
167
|
-
} else {
|
|
168
|
-
return window[storage].getItem(key);
|
|
169
|
-
}
|
|
170
|
-
} catch (e) {
|
|
171
|
-
!isProd && console.error(e, key);
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
clear: function(storage) {
|
|
175
|
-
window[storage].clear();
|
|
176
|
-
},
|
|
177
|
-
remove: function(key, storage) {
|
|
178
|
-
window[storage].removeItem(key);
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export const cookieManager = {
|
|
183
|
-
set: function(key, value, expired) {
|
|
184
|
-
if (expired) docCookies.setItem(key, value, expired);
|
|
185
|
-
else docCookies.setItem(key, value);
|
|
186
|
-
},
|
|
187
|
-
get: function(key) {
|
|
188
|
-
return docCookies.getItem(key);
|
|
189
|
-
},
|
|
190
|
-
clear: function() {
|
|
191
|
-
docCookies.keys().forEach((key) => {
|
|
192
|
-
docCookies.removeItem(key);
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
remove: function(key) {
|
|
196
|
-
docCookies.removeItem(key);
|
|
197
|
-
},
|
|
198
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2019 WeBank
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/* \
|
|
19
|
+
|*|
|
|
20
|
+
|*| :: cookies.js ::
|
|
21
|
+
|*|
|
|
22
|
+
|*| A complete cookies reader/writer framework with full unicode support.
|
|
23
|
+
|*|
|
|
24
|
+
|*| https://developer.mozilla.org/en-US/docs/DOM/document.cookie
|
|
25
|
+
|*|
|
|
26
|
+
|*| This framework is released under the GNU Public License, version 3 or later.
|
|
27
|
+
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
|
28
|
+
|*|
|
|
29
|
+
|*| Syntaxes:
|
|
30
|
+
|*|
|
|
31
|
+
|*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
|
|
32
|
+
|*| * docCookies.getItem(name)
|
|
33
|
+
|*| * docCookies.removeItem(name[, path], domain)
|
|
34
|
+
|*| * docCookies.hasItem(name)
|
|
35
|
+
|*| * docCookies.keys()
|
|
36
|
+
|*|
|
|
37
|
+
\ */
|
|
38
|
+
|
|
39
|
+
let docCookies = {
|
|
40
|
+
getItem: function(sKey) {
|
|
41
|
+
return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
|
|
42
|
+
},
|
|
43
|
+
setItem: function(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
|
|
44
|
+
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
let sExpires = '';
|
|
48
|
+
if (vEnd) {
|
|
49
|
+
switch (vEnd.constructor) {
|
|
50
|
+
case Number:
|
|
51
|
+
sExpires = vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : '; max-age=' + vEnd;
|
|
52
|
+
break;
|
|
53
|
+
case String:
|
|
54
|
+
sExpires = '; expires=' + vEnd;
|
|
55
|
+
break;
|
|
56
|
+
case Date:
|
|
57
|
+
sExpires = '; expires=' + vEnd.toUTCString();
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
document.cookie = encodeURIComponent(sKey) + '=' + encodeURIComponent(sValue) + sExpires + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '') + (bSecure ? '; secure' : '');
|
|
62
|
+
return true;
|
|
63
|
+
},
|
|
64
|
+
removeItem: function(sKey, sPath, sDomain) {
|
|
65
|
+
if (!sKey || !this.hasItem(sKey)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
document.cookie = encodeURIComponent(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '');
|
|
69
|
+
return true;
|
|
70
|
+
},
|
|
71
|
+
hasItem: function(sKey) {
|
|
72
|
+
return (new RegExp('(?:^|;\\s*)' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=')).test(document.cookie);
|
|
73
|
+
},
|
|
74
|
+
keys: /* optional method: you can safely remove it! */ function() {
|
|
75
|
+
let aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, '').split(/\s*(?:\=[^;]*)?;\s*/);
|
|
76
|
+
for (let nIdx = 0; nIdx < aKeys.length; nIdx++) {
|
|
77
|
+
aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);
|
|
78
|
+
}
|
|
79
|
+
return aKeys;
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 操作cookie、sessionStorage、localStorage、缓存
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
const
|
|
88
|
+
SESSION = 'session';
|
|
89
|
+
|
|
90
|
+
const LOCAL = 'local';
|
|
91
|
+
|
|
92
|
+
const COOKIE = 'cookie';
|
|
93
|
+
|
|
94
|
+
export default {
|
|
95
|
+
set: function(key, value, category = SESSION, expired) {
|
|
96
|
+
let { storage, isWebStorage = true } = this._map(category);
|
|
97
|
+
|
|
98
|
+
if (isWebStorage) {
|
|
99
|
+
storageManager.set(key, value, storage);
|
|
100
|
+
} else {
|
|
101
|
+
cookieManager.set(key, value, expired);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
get: function(key, category = SESSION) {
|
|
105
|
+
let { storage, isWebStorage = true } = this._map(category);
|
|
106
|
+
|
|
107
|
+
if (isWebStorage) {
|
|
108
|
+
return storageManager.get(key, storage);
|
|
109
|
+
} else {
|
|
110
|
+
return cookieManager.get(key);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
clear: function(category = SESSION) {
|
|
114
|
+
let { storage, isWebStorage = true } = this._map(category);
|
|
115
|
+
|
|
116
|
+
if (isWebStorage) {
|
|
117
|
+
storageManager.clear(storage);
|
|
118
|
+
} else {
|
|
119
|
+
cookieManager.clear();
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
remove: function(key, category = SESSION) {
|
|
123
|
+
let { storage, isWebStorage = true } = this._map(category);
|
|
124
|
+
|
|
125
|
+
if (isWebStorage) {
|
|
126
|
+
storageManager.remove(key, storage);
|
|
127
|
+
} else {
|
|
128
|
+
cookieManager.remove(key);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
_map: function(category) {
|
|
132
|
+
let isWebStorage = true; let storage;
|
|
133
|
+
|
|
134
|
+
switch (true) {
|
|
135
|
+
case category === SESSION:
|
|
136
|
+
storage = 'sessionStorage';
|
|
137
|
+
break;
|
|
138
|
+
case category === LOCAL:
|
|
139
|
+
storage = 'localStorage';
|
|
140
|
+
break;
|
|
141
|
+
case category === COOKIE:
|
|
142
|
+
storage = 'cookie';
|
|
143
|
+
isWebStorage = false;
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
storage = 'sessionStorage';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return { isWebStorage, storage };
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
let isProd = process.env.NODE_ENV === 'production';
|
|
154
|
+
|
|
155
|
+
export const storageManager = {
|
|
156
|
+
set: function(key, value, storage) {
|
|
157
|
+
try {
|
|
158
|
+
window[storage].setItem(key, JSON.stringify(value));
|
|
159
|
+
} catch (e) {
|
|
160
|
+
!isProd && console.error(e);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
get: function(key, storage) {
|
|
164
|
+
try {
|
|
165
|
+
if (window[storage].getItem(key)) {
|
|
166
|
+
return JSON.parse(window[storage].getItem(key));
|
|
167
|
+
} else {
|
|
168
|
+
return window[storage].getItem(key);
|
|
169
|
+
}
|
|
170
|
+
} catch (e) {
|
|
171
|
+
!isProd && console.error(e, key);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
clear: function(storage) {
|
|
175
|
+
window[storage].clear();
|
|
176
|
+
},
|
|
177
|
+
remove: function(key, storage) {
|
|
178
|
+
window[storage].removeItem(key);
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const cookieManager = {
|
|
183
|
+
set: function(key, value, expired) {
|
|
184
|
+
if (expired) docCookies.setItem(key, value, expired);
|
|
185
|
+
else docCookies.setItem(key, value);
|
|
186
|
+
},
|
|
187
|
+
get: function(key) {
|
|
188
|
+
return docCookies.getItem(key);
|
|
189
|
+
},
|
|
190
|
+
clear: function() {
|
|
191
|
+
docCookies.keys().forEach((key) => {
|
|
192
|
+
docCookies.removeItem(key);
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
remove: function(key) {
|
|
196
|
+
docCookies.removeItem(key);
|
|
197
|
+
},
|
|
198
|
+
};
|