@lambo-design/shared 1.0.0-beta.22 → 1.0.0-beta.220
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/config.js +16 -2
- package/config/index.js +7 -2
- package/config/themes/atrovirens/atrovirens.css +574 -0
- package/config/themes/atrovirens/atrovirens.css.map +1 -0
- package/config/themes/atrovirens/atrovirens.less +666 -0
- package/config/themes/atrovirens/var.less +673 -0
- package/config/themes/blue/blue.css +574 -0
- package/config/themes/blue/blue.css.map +1 -0
- package/config/themes/blue/blue.less +668 -0
- package/config/themes/blue/var.less +675 -0
- package/config/themes/blue-white/blue-white.css +574 -0
- package/config/themes/blue-white/blue-white.css.map +1 -0
- package/config/themes/blue-white/blue-white.less +668 -0
- package/config/themes/blue-white/var.less +674 -0
- package/config/themes/blue-white-tight/blue-white-tight.css +575 -0
- package/config/themes/blue-white-tight/blue-white-tight.css.map +1 -0
- package/config/themes/blue-white-tight/blue-white-tight.less +670 -0
- package/config/themes/blue-white-tight/var.less +675 -0
- package/config/themes/danqing/danqing.css +574 -0
- package/config/themes/danqing/danqing.css.map +1 -0
- package/config/themes/danqing/danqing.less +666 -0
- package/config/themes/danqing/danqing.wxss +572 -0
- package/config/themes/danqing/var.less +677 -0
- package/config/themes/deep/deep.css +574 -0
- package/config/themes/deep/deep.css.map +1 -0
- package/config/themes/deep/deep.less +667 -0
- package/config/themes/deep/var.less +675 -0
- package/config/themes/default/default.css +574 -241
- package/config/themes/default/default.css.map +1 -0
- package/config/themes/default/default.less +438 -88
- package/config/themes/default/var.less +373 -12
- package/config/themes/eap/eap.css +574 -0
- package/config/themes/eap/eap.css.map +1 -0
- package/config/themes/eap/eap.less +669 -0
- package/config/themes/eap/var.less +675 -0
- package/config/themes/gold/gold.css +574 -0
- package/config/themes/gold/gold.css.map +1 -0
- package/config/themes/gold/gold.less +669 -0
- package/config/themes/gold/var.less +368 -7
- package/config/themes/index.js +16 -4
- package/config/themes/lime/lime.css +574 -0
- package/config/themes/lime/lime.css.map +1 -0
- package/config/themes/lime/lime.less +669 -0
- package/config/themes/lime/var.less +369 -7
- package/config/themes/orange/orange.css +574 -0
- package/config/themes/orange/orange.css.map +1 -0
- package/config/themes/orange/orange.less +669 -0
- package/config/themes/orange/var.less +676 -0
- package/config/themes/red/red.css +574 -0
- package/config/themes/red/red.css.map +1 -0
- package/config/themes/red/red.less +669 -0
- package/config/themes/red/var.less +675 -0
- package/config/themes/theme-atrovirens.js +556 -0
- package/config/themes/theme-blue.js +556 -0
- package/config/themes/theme-bw.js +556 -0
- package/config/themes/theme-bwt.js +557 -0
- package/config/themes/theme-danqing.js +556 -0
- package/config/themes/theme-deep.js +556 -0
- package/config/themes/theme-default.js +363 -59
- package/config/themes/theme-eap.js +556 -0
- package/config/themes/theme-gold.js +315 -11
- package/config/themes/theme-lime.js +315 -11
- package/config/themes/theme-orange.js +544 -27
- package/config/themes/theme-red.js +548 -32
- package/directives/module/print.js +1 -0
- package/directives/module/vue-print-nb/README.md +63 -0
- package/directives/module/vue-print-nb/print.js +94 -0
- package/directives/module/vue-print-nb/printarea.js +532 -0
- package/index.js +7 -1
- package/nstyles/common.less +197 -0
- package/nstyles/components/404.less +46 -0
- package/nstyles/components/button.less +34 -0
- package/nstyles/components/date-picker.less +37 -0
- package/nstyles/components/drawer.less +20 -0
- package/nstyles/components/dropdown.less +18 -0
- package/nstyles/components/excel-flow.less +72 -0
- package/nstyles/components/form.less +303 -0
- package/nstyles/components/index.less +23 -0
- package/nstyles/components/layout/collect.less +10 -0
- package/nstyles/components/layout/detail-view.less +107 -0
- package/nstyles/components/layout/full-screen.less +7 -0
- package/nstyles/components/layout/index.less +7 -0
- package/nstyles/components/layout/other-menu.less +142 -0
- package/nstyles/components/layout/page-view.less +101 -0
- package/nstyles/components/layout/sider-trigger.less +41 -0
- package/nstyles/components/layout/tags-nav.less +113 -0
- package/nstyles/components/modal.less +85 -0
- package/nstyles/components/n-button.less +131 -0
- package/nstyles/components/n-image-preview.less +131 -0
- package/nstyles/components/n-model/index.less +19 -0
- package/nstyles/components/n-model/report-index.less +43 -0
- package/nstyles/components/n-panel.less +41 -0
- package/nstyles/components/n-picker.less +37 -0
- package/nstyles/components/n-sign.less +17 -0
- package/nstyles/components/n-tooltip.less +10 -0
- package/nstyles/components/panel.less +31 -0
- package/nstyles/components/select.less +3 -0
- package/nstyles/components/sign.less +27 -0
- package/nstyles/components/table.less +315 -0
- package/nstyles/components/tree.less +159 -0
- package/nstyles/components/upload.less +164 -0
- package/nstyles/index.less +5 -0
- package/nstyles/reset.less +65 -0
- package/nstyles/third/ag.less +174 -0
- package/nstyles/third/icons/sort-desc.svg +1 -0
- package/nstyles/third/icons/sort-up.svg +1 -0
- package/nstyles/third/icons/sorting.svg +1 -0
- package/nstyles/third/index.less +11 -0
- package/nstyles/third/view-design.less +367 -0
- package/nstyles/variables/base.less +143 -0
- package/nstyles/variables/index.less +4 -0
- package/nstyles/variables/theme/default/button.less +7 -0
- package/nstyles/variables/theme/default/common.less +57 -0
- package/nstyles/variables/theme/default/index.less +7 -0
- package/nstyles/variables/theme/default/layout.less +40 -0
- package/nstyles/variables/theme/default/table.less +37 -0
- package/nstyles/variables/theme/default/tag.less +3 -0
- package/nstyles/variables/theme/default/upload.less +3 -0
- package/nstyles/variables/theme/index.less +13 -0
- package/nstyles/variables/theme/small/button.less +7 -0
- package/nstyles/variables/theme/small/common.less +39 -0
- package/nstyles/variables/theme/small/index.less +5 -0
- package/nstyles/variables/theme/small/layout.less +21 -0
- package/nstyles/variables/theme/small/table.less +17 -0
- package/nstyles/variables/theme/small/tag.less +3 -0
- package/package.json +26 -6
- package/plugin/index.js +12 -0
- package/plugin/module/date-format.js +30 -0
- package/plugin/module/loading.js +26 -0
- package/plugin/module/warn-handler.js +11 -0
- package/styles/image/inspur.png +0 -0
- package/styles/image/lan_navigator.png +0 -0
- package/styles/image/lv_navigator.png +0 -0
- package/utils/ajax/content-type.js +30 -0
- package/utils/assist.js +88 -25
- package/utils/base64.js +126 -0
- package/utils/blob.js +47 -0
- package/utils/crypto/index.js +10 -0
- package/utils/date.js +334 -305
- package/utils/dict/built-in-dict.js +20 -0
- package/utils/dict/index.js +133 -0
- package/utils/event.js +72 -0
- package/utils/excel.js +369 -237
- package/utils/file.js +19 -0
- package/utils/form/validate.js +29 -0
- package/utils/half-year.js +68 -0
- package/utils/index.js +37 -0
- package/utils/json.js +29 -0
- package/utils/lodop.js +5 -0
- package/utils/menu/index.js +270 -11
- package/utils/mime_type.js +67 -0
- package/utils/modelerUtil.js +4 -1
- package/utils/n/api.js +22 -0
- package/utils/n/date.js +57 -0
- package/utils/n/index.js +10 -0
- package/utils/n/is-type.js +176 -0
- package/utils/n/number.js +144 -0
- package/utils/n/permission-cache.js +11 -0
- package/utils/n/reuqest/axiosN.js +17 -0
- package/utils/n/reuqest/content-type.js +19 -0
- package/utils/n/reuqest/interceptors.js +95 -0
- package/utils/n/reuqest/url-params.js +12 -0
- package/utils/n/storage.js +51 -0
- package/utils/n/token.js +51 -0
- package/utils/n/user-cache.js +11 -0
- package/utils/n/user.js +34 -0
- package/utils/n/uuid.js +16 -0
- package/utils/n-generator-routers.js +208 -0
- package/utils/n-router.js +205 -0
- package/utils/n-theme.js +30 -0
- package/utils/number.js +72 -15
- package/utils/oss.js +57 -0
- package/utils/platform.js +760 -22
- package/utils/quarter.js +58 -0
- package/utils/storage.js +198 -0
- package/utils/style.js +24 -0
- package/utils/theme.js +98 -3
- package/utils/transfer-queue.js +7 -0
- package/utils/type.js +102 -0
- package/utils/util.js +795 -0
- package/utils/validator.js +181 -0
- package/config/themes/gold/default.css +0 -241
- package/config/themes/gold/default.less +0 -319
- package/config/themes/lime/default.css +0 -241
- package/config/themes/lime/default.less +0 -319
package/utils/quarter.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// 获取季度汉字
|
|
2
|
+
export function quarter2Chinese(quarterNum) {
|
|
3
|
+
let quarterList = ['一', '二', '三', '四']
|
|
4
|
+
return quarterNum ? quarterList[quarterNum - 1] : ''
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// 获取季度
|
|
8
|
+
export function getQuarter(date) {
|
|
9
|
+
if (!date || date.length < 6) {
|
|
10
|
+
return ''
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const year = date.substring(0, 4)
|
|
14
|
+
const month = date.substring(4, 6)
|
|
15
|
+
const quarter = getQuarterNum(parseInt(month))
|
|
16
|
+
return `${year}Q${quarter}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getQuarterNum(month) {
|
|
20
|
+
if (typeof month === 'string') {
|
|
21
|
+
if (isNaN(parseInt(month))) return 0
|
|
22
|
+
month = parseInt(month)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Math.ceil(month / 3)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function formatQuarter(quarter) {
|
|
29
|
+
if (!quarter || quarter.length < 6) {
|
|
30
|
+
return quarter
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const year = quarter.substring(0, 4)
|
|
34
|
+
const quarterNum = parseInt(quarter.substring(5))
|
|
35
|
+
return `${year}第${quarter2Chinese(quarterNum)}季度`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getQuarterBeginMonth(quarter) {
|
|
39
|
+
if (!quarter || quarter.length < 6) {
|
|
40
|
+
return quarter
|
|
41
|
+
}
|
|
42
|
+
const year = quarter.substring(0, 4)
|
|
43
|
+
const quarterNum = parseInt(quarter.substring(5))
|
|
44
|
+
const beginMonth = quarterNum * 3 - 2
|
|
45
|
+
const monthStr = beginMonth < 10 ? `0${beginMonth}` : `${beginMonth}`
|
|
46
|
+
return `${year}${monthStr}`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getQuarterEndMonth(quarter) {
|
|
50
|
+
if (!quarter || quarter.length < 6) {
|
|
51
|
+
return quarter
|
|
52
|
+
}
|
|
53
|
+
const year = quarter.substring(0, 4)
|
|
54
|
+
const quarterNum = parseInt(quarter.substring(5))
|
|
55
|
+
const endMonth = quarterNum * 3
|
|
56
|
+
const monthStr = endMonth < 10 ? `0${endMonth}` : `${endMonth}`
|
|
57
|
+
return `${year}${monthStr}`
|
|
58
|
+
}
|
package/utils/storage.js
ADDED
|
@@ -0,0 +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
|
+
};
|
package/utils/style.js
ADDED
|
@@ -0,0 +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
|
+
}
|
package/utils/theme.js
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
import themes from "../config/themes";
|
|
2
|
+
import cssVars from "css-vars-ponyfill";
|
|
3
|
+
import lan_navigator from '../styles/image/lan_navigator.png'
|
|
4
|
+
import lv_navigator from '../styles/image/lv_navigator.png'
|
|
5
|
+
import {handleSystemColor} from "./util";
|
|
6
|
+
import config from "@lambo-design/shared/config/config";
|
|
7
|
+
|
|
8
|
+
|
|
2
9
|
const changeByThemeKey = (themeKey) => {
|
|
3
10
|
if (themeKey) {
|
|
4
11
|
themes.forEach((theme) => {
|
|
5
12
|
if (theme.key === themeKey) {
|
|
6
13
|
changeByTheme(theme);
|
|
7
|
-
|
|
14
|
+
if (typeof window !== 'undefined') {
|
|
15
|
+
localStorage.setItem("theme", themeKey);
|
|
16
|
+
localStorage.setItem('themeInStyle', '1');
|
|
17
|
+
}
|
|
8
18
|
}
|
|
9
19
|
});
|
|
10
20
|
} else {
|
|
11
|
-
|
|
21
|
+
if (typeof window !== 'undefined') {
|
|
22
|
+
themeKey = localStorage.getItem("theme");
|
|
23
|
+
}
|
|
12
24
|
if (!themeKey) {
|
|
13
25
|
themeKey = themes[0].key;
|
|
14
26
|
}
|
|
15
27
|
changeByThemeKey(themeKey);
|
|
16
28
|
}
|
|
29
|
+
cssVars({
|
|
30
|
+
rootElement: document, // default
|
|
31
|
+
include: 'link[rel=stylesheet],style'
|
|
32
|
+
});
|
|
17
33
|
return themeKey;
|
|
18
34
|
};
|
|
19
35
|
|
|
@@ -40,4 +56,83 @@ const changeByTheme = (theme) => {
|
|
|
40
56
|
}
|
|
41
57
|
};
|
|
42
58
|
|
|
43
|
-
|
|
59
|
+
const changeThemeByThemeId = (themeId, status, filterStatus, systemForm) => {
|
|
60
|
+
// 主题切换方式(区分新旧两种:1-旧 2-新)
|
|
61
|
+
if (typeof window !== 'undefined') {
|
|
62
|
+
localStorage.setItem('themeInStyle', '2')
|
|
63
|
+
}
|
|
64
|
+
// 一键滤镜功能 - 灰度状态;
|
|
65
|
+
let grayscaleVal = '0%'
|
|
66
|
+
if (filterStatus && filterStatus === '1') {
|
|
67
|
+
grayscaleVal = '100%'
|
|
68
|
+
}
|
|
69
|
+
// 记录当前主题
|
|
70
|
+
if (typeof window !== 'undefined') {
|
|
71
|
+
// localStorage.setItem('themeIdCurrent', themeId)
|
|
72
|
+
localStorage.setItem('themeIdCurrent', themeId)
|
|
73
|
+
}
|
|
74
|
+
// 顶部栏背景图处理
|
|
75
|
+
let background_image = config.upmsServerContext + '/anon/oss/file/getImage/' + systemForm.topBkImg + '?height=64&width=1920'
|
|
76
|
+
if (!status || status === '2') {
|
|
77
|
+
if (background_image.includes('lan_navigator')) {
|
|
78
|
+
background_image = 'url(' + lan_navigator + ')'
|
|
79
|
+
} else if (background_image.includes('lv_navigator')) {
|
|
80
|
+
background_image = 'url(' + lv_navigator + ')'
|
|
81
|
+
}
|
|
82
|
+
} else if (status === '1') {
|
|
83
|
+
background_image = 'url(' + background_image + ')'
|
|
84
|
+
}
|
|
85
|
+
handleSystemColor(grayscaleVal, systemForm, background_image)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const getThemeConfig = (themeKey = 'default') =>{
|
|
89
|
+
let result = {};
|
|
90
|
+
themes.forEach((theme) => {
|
|
91
|
+
if (theme.key === themeKey) {
|
|
92
|
+
result = theme;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const getThemeVars = (themeKey = 'default') =>{
|
|
99
|
+
let theme = getThemeConfig(themeKey);
|
|
100
|
+
if (theme) {
|
|
101
|
+
return theme.vars;
|
|
102
|
+
}
|
|
103
|
+
return '';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const getThemeVarByKey = (themeKey = 'default',varKey) => {
|
|
107
|
+
let value = '';
|
|
108
|
+
if (varKey) {
|
|
109
|
+
let vars = getThemeVars(themeKey)
|
|
110
|
+
if (vars) {
|
|
111
|
+
let startIndexOfChar = vars.indexOf(varKey);
|
|
112
|
+
if (startIndexOfChar > -1) {
|
|
113
|
+
// 从起始字符位置开始,找到下一行的起始位置
|
|
114
|
+
let endIndex = vars.indexOf('\n', startIndexOfChar);
|
|
115
|
+
if (endIndex === -1) {
|
|
116
|
+
// 如果没有找到换行符,则返回从起始字符到字符串末尾的部分
|
|
117
|
+
value = vars.substring(startIndexOfChar);
|
|
118
|
+
} else {
|
|
119
|
+
// 返回从起始字符到换行符之前的部分(不包括换行符)
|
|
120
|
+
value = vars.substring(startIndexOfChar, endIndex);
|
|
121
|
+
}
|
|
122
|
+
if (value) {
|
|
123
|
+
value = value.substring(value.indexOf(":") + 1,value.indexOf(";")).replaceAll(" ","");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
changeByThemeKey,
|
|
133
|
+
changeByTheme,
|
|
134
|
+
changeThemeByThemeId,
|
|
135
|
+
getThemeConfig,
|
|
136
|
+
getThemeVars,
|
|
137
|
+
getThemeVarByKey
|
|
138
|
+
};
|
package/utils/type.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
const objectToString = Object.prototype.toString;
|
|
19
|
+
const OBJECT_STRING = '[object Object]';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 是否是普通对象
|
|
23
|
+
* @param {any} obj
|
|
24
|
+
* @return {Boolean}
|
|
25
|
+
*/
|
|
26
|
+
export function isPlainObject(obj) {
|
|
27
|
+
return objectToString.call(obj) === OBJECT_STRING;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 是否是数字
|
|
32
|
+
* @param {any} value
|
|
33
|
+
* @return {Boolean}
|
|
34
|
+
*/
|
|
35
|
+
export function isNumber(value) {
|
|
36
|
+
return typeof value === 'number';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 是否是日期
|
|
41
|
+
* @param {any} value
|
|
42
|
+
* @return {Boolean}
|
|
43
|
+
*/
|
|
44
|
+
export function isDate(value) {
|
|
45
|
+
return objectToString.call(value) === '[object Date]';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 是否是函数
|
|
50
|
+
* @param {any} value
|
|
51
|
+
* @return {Boolean}
|
|
52
|
+
*/
|
|
53
|
+
export function isFunction(value) {
|
|
54
|
+
return typeof value === 'function';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 是否是函数
|
|
59
|
+
* @param {any} value
|
|
60
|
+
* @return {Boolean}
|
|
61
|
+
*/
|
|
62
|
+
export function isObject(value) {
|
|
63
|
+
let type = typeof value;
|
|
64
|
+
return !!value && (type == 'object' || type == 'function');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 是否是数组
|
|
69
|
+
* @param {any} value
|
|
70
|
+
* @return {Boolean}
|
|
71
|
+
*/
|
|
72
|
+
export function isArray(value) {
|
|
73
|
+
return Array.isArray(value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 是否像对象
|
|
78
|
+
* @param {any} value
|
|
79
|
+
* @return {Boolean}
|
|
80
|
+
*/
|
|
81
|
+
export function isObjectLike(value) {
|
|
82
|
+
return !!value && typeof value == 'object';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 是否是字符串
|
|
87
|
+
* @param {any} value
|
|
88
|
+
* @return {Boolean}
|
|
89
|
+
*/
|
|
90
|
+
export function isString(value) {
|
|
91
|
+
return typeof value == 'string' ||
|
|
92
|
+
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == '[object String]');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 是否是空的
|
|
97
|
+
* @param {any} value
|
|
98
|
+
* @return {Boolean}
|
|
99
|
+
*/
|
|
100
|
+
export function isNull(value) {
|
|
101
|
+
return value === undefined || value === null || value === '';
|
|
102
|
+
}
|