@lambo-design/shared 1.0.0-beta.210 → 1.0.0-beta.212
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 +4 -2
- package/config/themes/atrovirens/atrovirens.css.map +1 -1
- package/config/themes/atrovirens/atrovirens.less +7 -2
- package/config/themes/atrovirens/var.less +9 -3
- package/config/themes/blue/blue.css +4 -2
- package/config/themes/blue/blue.css.map +1 -1
- package/config/themes/blue/blue.less +7 -3
- package/config/themes/blue/var.less +7 -2
- package/config/themes/blue-white/blue-white.css +4 -2
- package/config/themes/blue-white/blue-white.css.map +1 -1
- package/config/themes/blue-white/blue-white.less +12 -8
- package/config/themes/blue-white/var.less +6 -2
- package/config/themes/blue-white-tight/blue-white-tight.css +4 -2
- package/config/themes/blue-white-tight/blue-white-tight.css.map +1 -1
- package/config/themes/blue-white-tight/blue-white-tight.less +7 -2
- package/config/themes/blue-white-tight/var.less +6 -2
- package/config/themes/danqing/danqing.css +577 -0
- package/config/themes/danqing/danqing.css.map +1 -0
- package/config/themes/{green-tobacco/greentobacco.less → danqing/danqing.less} +6 -2
- package/config/themes/{green-tobacco/greentobacco.css → danqing/danqing.wxss} +9 -8
- package/config/themes/{green-tobacco → danqing}/var.less +15 -8
- package/config/themes/deep/deep.css +4 -2
- package/config/themes/deep/deep.css.map +1 -1
- package/config/themes/deep/deep.less +7 -3
- package/config/themes/deep/var.less +7 -2
- package/config/themes/default/default.css +5 -3
- package/config/themes/default/default.css.map +1 -1
- package/config/themes/default/default.less +9 -4
- package/config/themes/default/var.less +6 -2
- package/config/themes/eap/eap.css +5 -3
- package/config/themes/eap/eap.css.map +1 -1
- package/config/themes/eap/eap.less +8 -3
- package/config/themes/eap/var.less +6 -2
- package/config/themes/gold/gold.css +4 -2
- package/config/themes/gold/gold.css.map +1 -1
- package/config/themes/gold/gold.less +7 -2
- package/config/themes/gold/var.less +6 -2
- package/config/themes/index.js +2 -2
- package/config/themes/lime/lime.css +4 -2
- package/config/themes/lime/lime.css.map +1 -1
- package/config/themes/lime/lime.less +7 -2
- package/config/themes/lime/var.less +7 -2
- package/config/themes/orange/orange.css +4 -2
- package/config/themes/orange/orange.css.map +1 -1
- package/config/themes/orange/orange.less +7 -2
- package/config/themes/orange/var.less +6 -2
- package/config/themes/red/red.css +4 -2
- package/config/themes/red/red.css.map +1 -1
- package/config/themes/red/red.less +7 -2
- package/config/themes/red/var.less +6 -2
- package/config/themes/theme-atrovirens.js +3 -2
- package/config/themes/theme-blue.js +3 -2
- package/config/themes/theme-bw.js +3 -2
- package/config/themes/theme-bwt.js +3 -2
- package/config/themes/{theme-greentobacco.js → theme-danqing.js} +10 -9
- package/config/themes/theme-deep.js +4 -3
- package/config/themes/theme-default.js +4 -3
- package/config/themes/theme-eap.js +4 -3
- package/config/themes/theme-gold.js +3 -2
- package/config/themes/theme-lime.js +3 -2
- package/config/themes/theme-orange.js +4 -3
- package/config/themes/theme-red.js +3 -2
- package/package.json +1 -1
- package/plugin/index.js +2 -2
- package/utils/crypto/aes.js +23 -0
- package/utils/crypto/rsa.js +16 -0
- package/utils/platform.js +42 -10
- 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
|
@@ -73,7 +73,6 @@ export default {
|
|
|
73
73
|
--border-radius-base: 6px;
|
|
74
74
|
--border-radius-small: 4px;
|
|
75
75
|
--cursor-disabled: not-allowed;
|
|
76
|
-
--font-weight-common-header: 500;
|
|
77
76
|
--padding-lg: 24px;
|
|
78
77
|
--padding-md: 16px;
|
|
79
78
|
--padding-sm: 12px;
|
|
@@ -95,7 +94,6 @@ export default {
|
|
|
95
94
|
--menu-dark-subsidiary-color: rgba(255, 255, 255, 0.7);
|
|
96
95
|
--menu-dark-group-title-color: rgba(255, 255, 255, 0.36);
|
|
97
96
|
--date-picker-cell-hover-bg: rgba(255, 52, 87, 0.3);
|
|
98
|
-
--content-header-back-color: #fff;
|
|
99
97
|
--shadow-color: rgba(0, 0, 0, 0.2);
|
|
100
98
|
--shadow-base: 0 1px 6px rgba(0, 0, 0, 0.2);
|
|
101
99
|
--shadow-card: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
|
@@ -544,6 +542,9 @@ export default {
|
|
|
544
542
|
--vxe-switch-disabled-background-color: rgba(0, 0, 0, 0.15);
|
|
545
543
|
/*pulldown*/
|
|
546
544
|
--vxe-pulldown-panel-background-color: #fff;
|
|
545
|
+
--page-container-title-font-size: 16px;
|
|
546
|
+
--content-header-bg-color: #fff;
|
|
547
|
+
--content-header-font-weight: 500;
|
|
547
548
|
`,
|
|
548
549
|
style: `
|
|
549
550
|
html {
|
package/package.json
CHANGED
package/plugin/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import WarnHandler from "./module/warn-handler";
|
|
|
4
4
|
export default {
|
|
5
5
|
install : function (Vue, options) {
|
|
6
6
|
DateFormat.install(Vue,options);
|
|
7
|
-
Loading.install(Vue
|
|
8
|
-
WarnHandler.install(Vue
|
|
7
|
+
Loading.install(Vue,options);
|
|
8
|
+
WarnHandler.install(Vue,options);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as CryptoJS from 'crypto-js';
|
|
2
|
+
|
|
3
|
+
const AES_KEY = 'gYj2iqBV5AzxC8H0';
|
|
4
|
+
const AES_IV = 'z5c8fSuHX1PxWtIg';
|
|
5
|
+
|
|
6
|
+
crypto.aes = {
|
|
7
|
+
encrypt(message) {
|
|
8
|
+
return CryptoJS.AES.encrypt(message, AES_KEY, {
|
|
9
|
+
mode: CryptoJS.mode.CBC,
|
|
10
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
11
|
+
iv: AES_IV
|
|
12
|
+
})
|
|
13
|
+
},
|
|
14
|
+
decrypt(ciphertext) {
|
|
15
|
+
return CryptoJS.AES.decrypt(ciphertext, AES_KEY, {
|
|
16
|
+
mode: CryptoJS.mode.CBC,
|
|
17
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
18
|
+
iv: AES_IV
|
|
19
|
+
}).toString(CryptoJS.enc.Utf8)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default crypto.aes;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import NodeRSA from "node-rsa";
|
|
2
|
+
|
|
3
|
+
const publicKey = `-----BEGIN PUBLIC KEY-----
|
|
4
|
+
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCyhhlApSAjPWRjzg+wSIfALbrC
|
|
5
|
+
Ti4GVBYYBjfMYKU0O9z6EGQAXSLPW+S4VYm4LKtKXuKoeF441KU2HvnGM63cTIYt
|
|
6
|
+
T4lGbTGeYfsbeWNs1u9G9J+DrfKK8HsVB1IZIqhbMf0x7KGMeoQ2SN4KtbaPIwhl
|
|
7
|
+
IPfXzuLZiCW90l+a/wIDAQAB
|
|
8
|
+
-----END PUBLIC KEY-----`;
|
|
9
|
+
|
|
10
|
+
// 创建NodeRSA实例并指定公钥格式
|
|
11
|
+
const key = new NodeRSA(publicKey, "pkcs8-public");
|
|
12
|
+
|
|
13
|
+
// 加密函数
|
|
14
|
+
function rsa(data) {
|
|
15
|
+
return key.encrypt(data, "base64");
|
|
16
|
+
}
|
package/utils/platform.js
CHANGED
|
@@ -734,11 +734,27 @@ export const isOpenBlank = (menu) => {
|
|
|
734
734
|
* @param menu
|
|
735
735
|
*/
|
|
736
736
|
export const isMobileApp = (app) => {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
737
|
+
try{
|
|
738
|
+
let extendProps = {};
|
|
739
|
+
if (app.extendProps) {
|
|
740
|
+
if (typeof app.extendProps == 'string') {
|
|
741
|
+
extendProps = JSON.parse(app.extendProps);
|
|
742
|
+
} else {
|
|
743
|
+
extendProps = app.extendProps;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (app.setting) {
|
|
747
|
+
if (typeof app.setting == 'string') {
|
|
748
|
+
extendProps = JSON.parse(app.setting);
|
|
749
|
+
} else {
|
|
750
|
+
extendProps = app.setting;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
if (extendProps && extendProps.is_mobile_app && extendProps.is_mobile_app == '1') {
|
|
754
|
+
return true;
|
|
755
|
+
}
|
|
756
|
+
}catch (e) {
|
|
757
|
+
console.error(e)
|
|
742
758
|
}
|
|
743
759
|
return false;
|
|
744
760
|
}
|
|
@@ -783,11 +799,27 @@ export const getMobileAppList = (appList,filterCenter= false) => {
|
|
|
783
799
|
* @param menu
|
|
784
800
|
*/
|
|
785
801
|
export const isCenterApp = (app) => {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
802
|
+
try{
|
|
803
|
+
let extendProps = {};
|
|
804
|
+
if (app.extendProps) {
|
|
805
|
+
if (typeof app.extendProps == 'string') {
|
|
806
|
+
extendProps = JSON.parse(app.extendProps);
|
|
807
|
+
} else {
|
|
808
|
+
extendProps = app.extendProps;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
if (app.setting) {
|
|
812
|
+
if (typeof app.setting == 'string') {
|
|
813
|
+
extendProps = JSON.parse(app.setting);
|
|
814
|
+
} else {
|
|
815
|
+
extendProps = app.setting;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if (extendProps && extendProps.is_center_app && extendProps.is_center_app == '1') {
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
}catch (e) {
|
|
822
|
+
console.error(e);
|
|
791
823
|
}
|
|
792
824
|
return false;
|
|
793
825
|
}
|
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
|
+
};
|
package/utils/style.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g
|
|
2
|
-
const MOZ_HACK_REGEXP = /^moz([A-Z])/
|
|
3
|
-
|
|
4
|
-
function camelCase(name) {
|
|
5
|
-
return name
|
|
6
|
-
.replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) {
|
|
7
|
-
return offset ? letter.toUpperCase() : letter
|
|
8
|
-
})
|
|
9
|
-
.replace(MOZ_HACK_REGEXP, 'Moz$1')
|
|
10
|
-
}
|
|
11
|
-
// getStyle
|
|
12
|
-
export function getStyle(element, styleName) {
|
|
13
|
-
if (!element || !styleName) return null
|
|
14
|
-
styleName = camelCase(styleName)
|
|
15
|
-
if (styleName === 'float') {
|
|
16
|
-
styleName = 'cssFloat'
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
const computed = document.defaultView.getComputedStyle(element, '')
|
|
20
|
-
return element.style[styleName] || computed ? computed[styleName] : null
|
|
21
|
-
} catch (e) {
|
|
22
|
-
return element.style[styleName]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g
|
|
2
|
+
const MOZ_HACK_REGEXP = /^moz([A-Z])/
|
|
3
|
+
|
|
4
|
+
function camelCase(name) {
|
|
5
|
+
return name
|
|
6
|
+
.replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) {
|
|
7
|
+
return offset ? letter.toUpperCase() : letter
|
|
8
|
+
})
|
|
9
|
+
.replace(MOZ_HACK_REGEXP, 'Moz$1')
|
|
10
|
+
}
|
|
11
|
+
// getStyle
|
|
12
|
+
export function getStyle(element, styleName) {
|
|
13
|
+
if (!element || !styleName) return null
|
|
14
|
+
styleName = camelCase(styleName)
|
|
15
|
+
if (styleName === 'float') {
|
|
16
|
+
styleName = 'cssFloat'
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const computed = document.defaultView.getComputedStyle(element, '')
|
|
20
|
+
return element.style[styleName] || computed ? computed[styleName] : null
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return element.style[styleName]
|
|
23
|
+
}
|
|
24
|
+
}
|
package/utils/transfer-queue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
let transferIndex = 1000
|
|
2
|
-
|
|
3
|
-
function transferIncrease() {
|
|
4
|
-
transferIndex++
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export { transferIndex, transferIncrease }
|
|
1
|
+
let transferIndex = 1000
|
|
2
|
+
|
|
3
|
+
function transferIncrease() {
|
|
4
|
+
transferIndex++
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { transferIndex, transferIncrease }
|