@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.
Files changed (185) hide show
  1. package/config/config.js +16 -2
  2. package/config/index.js +7 -2
  3. package/config/themes/atrovirens/atrovirens.css +574 -0
  4. package/config/themes/atrovirens/atrovirens.css.map +1 -0
  5. package/config/themes/atrovirens/atrovirens.less +666 -0
  6. package/config/themes/atrovirens/var.less +673 -0
  7. package/config/themes/blue/blue.css +574 -0
  8. package/config/themes/blue/blue.css.map +1 -0
  9. package/config/themes/blue/blue.less +668 -0
  10. package/config/themes/blue/var.less +675 -0
  11. package/config/themes/blue-white/blue-white.css +574 -0
  12. package/config/themes/blue-white/blue-white.css.map +1 -0
  13. package/config/themes/blue-white/blue-white.less +668 -0
  14. package/config/themes/blue-white/var.less +674 -0
  15. package/config/themes/blue-white-tight/blue-white-tight.css +575 -0
  16. package/config/themes/blue-white-tight/blue-white-tight.css.map +1 -0
  17. package/config/themes/blue-white-tight/blue-white-tight.less +670 -0
  18. package/config/themes/blue-white-tight/var.less +675 -0
  19. package/config/themes/danqing/danqing.css +574 -0
  20. package/config/themes/danqing/danqing.css.map +1 -0
  21. package/config/themes/danqing/danqing.less +666 -0
  22. package/config/themes/danqing/danqing.wxss +572 -0
  23. package/config/themes/danqing/var.less +677 -0
  24. package/config/themes/deep/deep.css +574 -0
  25. package/config/themes/deep/deep.css.map +1 -0
  26. package/config/themes/deep/deep.less +667 -0
  27. package/config/themes/deep/var.less +675 -0
  28. package/config/themes/default/default.css +574 -241
  29. package/config/themes/default/default.css.map +1 -0
  30. package/config/themes/default/default.less +438 -88
  31. package/config/themes/default/var.less +373 -12
  32. package/config/themes/eap/eap.css +574 -0
  33. package/config/themes/eap/eap.css.map +1 -0
  34. package/config/themes/eap/eap.less +669 -0
  35. package/config/themes/eap/var.less +675 -0
  36. package/config/themes/gold/gold.css +574 -0
  37. package/config/themes/gold/gold.css.map +1 -0
  38. package/config/themes/gold/gold.less +669 -0
  39. package/config/themes/gold/var.less +368 -7
  40. package/config/themes/index.js +16 -4
  41. package/config/themes/lime/lime.css +574 -0
  42. package/config/themes/lime/lime.css.map +1 -0
  43. package/config/themes/lime/lime.less +669 -0
  44. package/config/themes/lime/var.less +369 -7
  45. package/config/themes/orange/orange.css +574 -0
  46. package/config/themes/orange/orange.css.map +1 -0
  47. package/config/themes/orange/orange.less +669 -0
  48. package/config/themes/orange/var.less +676 -0
  49. package/config/themes/red/red.css +574 -0
  50. package/config/themes/red/red.css.map +1 -0
  51. package/config/themes/red/red.less +669 -0
  52. package/config/themes/red/var.less +675 -0
  53. package/config/themes/theme-atrovirens.js +556 -0
  54. package/config/themes/theme-blue.js +556 -0
  55. package/config/themes/theme-bw.js +556 -0
  56. package/config/themes/theme-bwt.js +557 -0
  57. package/config/themes/theme-danqing.js +556 -0
  58. package/config/themes/theme-deep.js +556 -0
  59. package/config/themes/theme-default.js +363 -59
  60. package/config/themes/theme-eap.js +556 -0
  61. package/config/themes/theme-gold.js +315 -11
  62. package/config/themes/theme-lime.js +315 -11
  63. package/config/themes/theme-orange.js +544 -27
  64. package/config/themes/theme-red.js +548 -32
  65. package/directives/module/print.js +1 -0
  66. package/directives/module/vue-print-nb/README.md +63 -0
  67. package/directives/module/vue-print-nb/print.js +94 -0
  68. package/directives/module/vue-print-nb/printarea.js +532 -0
  69. package/index.js +7 -1
  70. package/nstyles/common.less +197 -0
  71. package/nstyles/components/404.less +46 -0
  72. package/nstyles/components/button.less +34 -0
  73. package/nstyles/components/date-picker.less +37 -0
  74. package/nstyles/components/drawer.less +20 -0
  75. package/nstyles/components/dropdown.less +18 -0
  76. package/nstyles/components/excel-flow.less +72 -0
  77. package/nstyles/components/form.less +303 -0
  78. package/nstyles/components/index.less +23 -0
  79. package/nstyles/components/layout/collect.less +10 -0
  80. package/nstyles/components/layout/detail-view.less +107 -0
  81. package/nstyles/components/layout/full-screen.less +7 -0
  82. package/nstyles/components/layout/index.less +7 -0
  83. package/nstyles/components/layout/other-menu.less +142 -0
  84. package/nstyles/components/layout/page-view.less +101 -0
  85. package/nstyles/components/layout/sider-trigger.less +41 -0
  86. package/nstyles/components/layout/tags-nav.less +113 -0
  87. package/nstyles/components/modal.less +85 -0
  88. package/nstyles/components/n-button.less +131 -0
  89. package/nstyles/components/n-image-preview.less +131 -0
  90. package/nstyles/components/n-model/index.less +19 -0
  91. package/nstyles/components/n-model/report-index.less +43 -0
  92. package/nstyles/components/n-panel.less +41 -0
  93. package/nstyles/components/n-picker.less +37 -0
  94. package/nstyles/components/n-sign.less +17 -0
  95. package/nstyles/components/n-tooltip.less +10 -0
  96. package/nstyles/components/panel.less +31 -0
  97. package/nstyles/components/select.less +3 -0
  98. package/nstyles/components/sign.less +27 -0
  99. package/nstyles/components/table.less +315 -0
  100. package/nstyles/components/tree.less +159 -0
  101. package/nstyles/components/upload.less +164 -0
  102. package/nstyles/index.less +5 -0
  103. package/nstyles/reset.less +65 -0
  104. package/nstyles/third/ag.less +174 -0
  105. package/nstyles/third/icons/sort-desc.svg +1 -0
  106. package/nstyles/third/icons/sort-up.svg +1 -0
  107. package/nstyles/third/icons/sorting.svg +1 -0
  108. package/nstyles/third/index.less +11 -0
  109. package/nstyles/third/view-design.less +367 -0
  110. package/nstyles/variables/base.less +143 -0
  111. package/nstyles/variables/index.less +4 -0
  112. package/nstyles/variables/theme/default/button.less +7 -0
  113. package/nstyles/variables/theme/default/common.less +57 -0
  114. package/nstyles/variables/theme/default/index.less +7 -0
  115. package/nstyles/variables/theme/default/layout.less +40 -0
  116. package/nstyles/variables/theme/default/table.less +37 -0
  117. package/nstyles/variables/theme/default/tag.less +3 -0
  118. package/nstyles/variables/theme/default/upload.less +3 -0
  119. package/nstyles/variables/theme/index.less +13 -0
  120. package/nstyles/variables/theme/small/button.less +7 -0
  121. package/nstyles/variables/theme/small/common.less +39 -0
  122. package/nstyles/variables/theme/small/index.less +5 -0
  123. package/nstyles/variables/theme/small/layout.less +21 -0
  124. package/nstyles/variables/theme/small/table.less +17 -0
  125. package/nstyles/variables/theme/small/tag.less +3 -0
  126. package/package.json +26 -6
  127. package/plugin/index.js +12 -0
  128. package/plugin/module/date-format.js +30 -0
  129. package/plugin/module/loading.js +26 -0
  130. package/plugin/module/warn-handler.js +11 -0
  131. package/styles/image/inspur.png +0 -0
  132. package/styles/image/lan_navigator.png +0 -0
  133. package/styles/image/lv_navigator.png +0 -0
  134. package/utils/ajax/content-type.js +30 -0
  135. package/utils/assist.js +88 -25
  136. package/utils/base64.js +126 -0
  137. package/utils/blob.js +47 -0
  138. package/utils/crypto/index.js +10 -0
  139. package/utils/date.js +334 -305
  140. package/utils/dict/built-in-dict.js +20 -0
  141. package/utils/dict/index.js +133 -0
  142. package/utils/event.js +72 -0
  143. package/utils/excel.js +369 -237
  144. package/utils/file.js +19 -0
  145. package/utils/form/validate.js +29 -0
  146. package/utils/half-year.js +68 -0
  147. package/utils/index.js +37 -0
  148. package/utils/json.js +29 -0
  149. package/utils/lodop.js +5 -0
  150. package/utils/menu/index.js +270 -11
  151. package/utils/mime_type.js +67 -0
  152. package/utils/modelerUtil.js +4 -1
  153. package/utils/n/api.js +22 -0
  154. package/utils/n/date.js +57 -0
  155. package/utils/n/index.js +10 -0
  156. package/utils/n/is-type.js +176 -0
  157. package/utils/n/number.js +144 -0
  158. package/utils/n/permission-cache.js +11 -0
  159. package/utils/n/reuqest/axiosN.js +17 -0
  160. package/utils/n/reuqest/content-type.js +19 -0
  161. package/utils/n/reuqest/interceptors.js +95 -0
  162. package/utils/n/reuqest/url-params.js +12 -0
  163. package/utils/n/storage.js +51 -0
  164. package/utils/n/token.js +51 -0
  165. package/utils/n/user-cache.js +11 -0
  166. package/utils/n/user.js +34 -0
  167. package/utils/n/uuid.js +16 -0
  168. package/utils/n-generator-routers.js +208 -0
  169. package/utils/n-router.js +205 -0
  170. package/utils/n-theme.js +30 -0
  171. package/utils/number.js +72 -15
  172. package/utils/oss.js +57 -0
  173. package/utils/platform.js +760 -22
  174. package/utils/quarter.js +58 -0
  175. package/utils/storage.js +198 -0
  176. package/utils/style.js +24 -0
  177. package/utils/theme.js +98 -3
  178. package/utils/transfer-queue.js +7 -0
  179. package/utils/type.js +102 -0
  180. package/utils/util.js +795 -0
  181. package/utils/validator.js +181 -0
  182. package/config/themes/gold/default.css +0 -241
  183. package/config/themes/gold/default.less +0 -319
  184. package/config/themes/lime/default.css +0 -241
  185. package/config/themes/lime/default.less +0 -319
@@ -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
+ }
@@ -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
- localStorage.setItem("theme", themeKey);
14
+ if (typeof window !== 'undefined') {
15
+ localStorage.setItem("theme", themeKey);
16
+ localStorage.setItem('themeInStyle', '1');
17
+ }
8
18
  }
9
19
  });
10
20
  } else {
11
- themeKey = localStorage.getItem("theme");
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
- export { changeByThemeKey, changeByTheme };
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
+ };
@@ -0,0 +1,7 @@
1
+ let transferIndex = 1000
2
+
3
+ function transferIncrease() {
4
+ transferIndex++
5
+ }
6
+
7
+ export { transferIndex, transferIncrease }
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
+ }