eoss 0.1.0-alpha.41 → 0.1.0-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +1446 -1354
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +183 -160
  86. package/lib/autocomplete.js +2852 -2583
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +4 -4
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +1216 -1147
  95. package/lib/calendar.js +864 -839
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +1199 -1130
  98. package/lib/carousel.js +1201 -1132
  99. package/lib/cascader-panel.js +1286 -1170
  100. package/lib/cascader.js +3309 -2976
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +1670 -1388
  103. package/lib/checkbox.js +9 -7
  104. package/lib/code-editor.js +4 -4
  105. package/lib/col.js +2 -2
  106. package/lib/collapse-item.js +1258 -1191
  107. package/lib/collapse.js +1251 -1184
  108. package/lib/color-picker.js +1506 -1329
  109. package/lib/config/api.js +17 -1
  110. package/lib/container.js +2 -2
  111. package/lib/cron.js +22 -22
  112. package/lib/data-table.js +1677 -1359
  113. package/lib/date-picker.js +2707 -2466
  114. package/lib/descriptions-item.js +4 -4
  115. package/lib/descriptions.js +4 -4
  116. package/lib/dialog.js +1213 -1144
  117. package/lib/divider.js +2 -2
  118. package/lib/drawer.js +9 -9
  119. package/lib/dropdown-item.js +6 -6
  120. package/lib/dropdown-menu.js +1415 -1265
  121. package/lib/dropdown.js +1219 -1150
  122. package/lib/email-login.js +1446 -1354
  123. package/lib/empty.js +2 -2
  124. package/lib/eoss.common.js +31462 -18205
  125. package/lib/flip.js +2 -2
  126. package/lib/flow-group.js +4578 -3381
  127. package/lib/flow-list.js +9566 -0
  128. package/lib/flow.js +19284 -10275
  129. package/lib/flows.js +1483 -1391
  130. package/lib/footer.js +2 -2
  131. package/lib/form-editor.js +2825 -2035
  132. package/lib/form-item.js +1368 -1192
  133. package/lib/form.js +2297 -2036
  134. package/lib/guide.js +2 -2
  135. package/lib/header.js +2 -2
  136. package/lib/icon.js +1384 -1292
  137. package/lib/icons.js +145 -99
  138. package/lib/image-viewer.js +1204 -1135
  139. package/lib/image.js +6 -6
  140. package/lib/index.js +1 -1
  141. package/lib/infinite-scroll.js +4 -4
  142. package/lib/input-number.js +169 -122
  143. package/lib/input.js +1399 -1325
  144. package/lib/link.js +2 -2
  145. package/lib/loading.js +11 -11
  146. package/lib/login.js +1486 -1389
  147. package/lib/lowcode-view.js +1618 -1526
  148. package/lib/lowcode.js +1620 -1586
  149. package/lib/main.js +2062 -1982
  150. package/lib/marquee.js +1202 -1133
  151. package/lib/menu-item-group.js +8 -8
  152. package/lib/menu-item.js +6 -6
  153. package/lib/menu.js +2698 -2479
  154. package/lib/message-box.js +1893 -1824
  155. package/lib/message.js +1782 -1713
  156. package/lib/notification.js +1783 -1714
  157. package/lib/option-group.js +16 -7
  158. package/lib/option.js +1223 -1146
  159. package/lib/page-header.js +2 -2
  160. package/lib/pagination.js +1207 -1138
  161. package/lib/phone-login.js +1441 -1352
  162. package/lib/popconfirm.js +7 -7
  163. package/lib/popover.js +2668 -2449
  164. package/lib/process-config.js +1508 -1416
  165. package/lib/process-module.js +1453 -1361
  166. package/lib/process-rule.js +1473 -1381
  167. package/lib/progress.js +2 -2
  168. package/lib/qr-code.js +4 -4
  169. package/lib/qrcode-login.js +1434 -1342
  170. package/lib/radio-button.js +14 -7
  171. package/lib/radio-group.js +1696 -1383
  172. package/lib/radio.js +31 -9
  173. package/lib/rate.js +1286 -1182
  174. package/lib/retrial-auth.js +1444 -1352
  175. package/lib/row.js +2 -2
  176. package/lib/scrollbar.js +1205 -1136
  177. package/lib/select.js +4176 -3717
  178. package/lib/selector-panel.js +2081 -1623
  179. package/lib/selector.js +2582 -2468
  180. package/lib/slider.js +149 -109
  181. package/lib/step.js +28 -30
  182. package/lib/steps.js +2353 -2278
  183. package/lib/submenu.js +1399 -1249
  184. package/lib/switch.js +1337 -1217
  185. package/lib/tab-pane.js +4 -4
  186. package/lib/table-column.js +1208 -1139
  187. package/lib/table.js +3791 -3476
  188. package/lib/tabs.js +1202 -1133
  189. package/lib/tag.js +2 -2
  190. package/lib/theme-chalk/autocomplete.css +1 -1
  191. package/lib/theme-chalk/base.css +1 -1
  192. package/lib/theme-chalk/cascader.css +1 -1
  193. package/lib/theme-chalk/checkbox-group.css +1 -1
  194. package/lib/theme-chalk/collapse.css +1 -1
  195. package/lib/theme-chalk/date-picker.css +1 -1
  196. package/lib/theme-chalk/flow copy.css +1 -0
  197. package/lib/theme-chalk/flow-group.css +1 -1
  198. package/lib/theme-chalk/flow-list.css +1 -0
  199. package/lib/theme-chalk/flow.css +1 -1
  200. package/lib/theme-chalk/form-editor.css +1 -1
  201. package/lib/theme-chalk/form.css +1 -1
  202. package/lib/theme-chalk/icons.css +1 -1
  203. package/lib/theme-chalk/index.css +1 -1
  204. package/lib/theme-chalk/input-number.css +1 -1
  205. package/lib/theme-chalk/input.css +1 -1
  206. package/lib/theme-chalk/login.css +1 -1
  207. package/lib/theme-chalk/main.css +1 -1
  208. package/lib/theme-chalk/message-box.css +1 -1
  209. package/lib/theme-chalk/pagination.css +1 -1
  210. package/lib/theme-chalk/radio-group.css +1 -1
  211. package/lib/theme-chalk/retrial-auth.css +1 -1
  212. package/lib/theme-chalk/select.css +1 -1
  213. package/lib/theme-chalk/selector.css +1 -1
  214. package/lib/theme-chalk/slider.css +1 -1
  215. package/lib/theme-chalk/switch.css +1 -1
  216. package/lib/theme-chalk/tabs.css +1 -1
  217. package/lib/theme-chalk/time-picker.css +1 -1
  218. package/lib/theme-chalk/transfer.css +1 -1
  219. package/lib/time-picker.js +2294 -2097
  220. package/lib/time-select.js +2286 -2089
  221. package/lib/timeline-item.js +2 -2
  222. package/lib/timeline.js +2 -2
  223. package/lib/tips.js +1429 -1337
  224. package/lib/toolbar.js +71 -48
  225. package/lib/tooltip.js +3277 -3058
  226. package/lib/transfer.js +1351 -1230
  227. package/lib/tree-group.js +1405 -1313
  228. package/lib/tree.js +2214 -2122
  229. package/lib/update-history.js +184 -161
  230. package/lib/upload.js +2432 -2384
  231. package/lib/utils/label.js +56 -0
  232. package/lib/utils/util.js +43 -1
  233. package/lib/wujie.js +1204 -1135
  234. package/package.json +5 -1
  235. package/packages/autocomplete/src/autocomplete.vue +88 -55
  236. package/packages/cascader/src/cascader.vue +166 -99
  237. package/packages/cascader-panel/src/node.js +31 -16
  238. package/packages/cascader-panel/src/store.js +26 -12
  239. package/packages/checkbox/src/checkbox-group.vue +93 -1
  240. package/packages/checkbox/src/checkbox.vue +4 -1
  241. package/packages/color-picker/src/color-picker.vue +279 -261
  242. package/packages/data-table/src/data-table.vue +104 -12
  243. package/packages/data-table/src/mixins/table-methods.js +118 -0
  244. package/packages/date-picker/src/picker.vue +17 -1
  245. package/packages/dialog/src/dialog.vue +2 -2
  246. package/packages/flow/src/component/Circulate.vue +59 -93
  247. package/packages/flow/src/component/CommonOpinions.vue +390 -0
  248. package/packages/flow/src/component/CustomPreset.vue +18 -25
  249. package/packages/flow/src/component/FileList.vue +11 -28
  250. package/packages/flow/src/component/FreeCirculation.vue +48 -59
  251. package/packages/flow/src/component/Preset.vue +10 -25
  252. package/packages/flow/src/component/SendMsg.vue +22 -71
  253. package/packages/flow/src/component/SortFlow.vue +115 -0
  254. package/packages/flow/src/component/TimeLimit.vue +20 -36
  255. package/packages/flow/src/component/opinions.vue +160 -108
  256. package/packages/flow/src/component/taskUnionExamine.vue +143 -145
  257. package/packages/flow/src/flow.vue +4598 -0
  258. package/packages/flow/src/form.vue +14 -20
  259. package/packages/flow/src/freeStartFlow.vue +196 -222
  260. package/packages/flow/src/main.vue +877 -618
  261. package/packages/flow/src/processForm.vue +789 -177
  262. package/packages/flow/src/processReject.vue +87 -83
  263. package/packages/flow/src/reset.vue +71 -70
  264. package/packages/flow/src/selectUser.vue +94 -85
  265. package/packages/flow/src/startTaskRead.vue +150 -156
  266. package/packages/flow/src/supervise.vue +44 -64
  267. package/packages/flow/src/table.vue +2 -10
  268. package/packages/flow-group/src/attachment.js +78 -0
  269. package/packages/flow-group/src/flow-item.vue +250 -0
  270. package/packages/flow-group/src/main.vue +151 -416
  271. package/packages/flow-list/index.js +5 -0
  272. package/packages/flow-list/src/main.vue +2432 -0
  273. package/packages/flowOld/index.js +7 -0
  274. package/packages/flowOld/src/component/Circulate.vue +464 -0
  275. package/packages/flowOld/src/component/CustomPreset.vue +343 -0
  276. package/packages/flowOld/src/component/FileList.vue +117 -0
  277. package/packages/flowOld/src/component/FreeCirculation.vue +278 -0
  278. package/packages/flowOld/src/component/Preset.vue +283 -0
  279. package/packages/flowOld/src/component/SendMsg.vue +309 -0
  280. package/packages/flowOld/src/component/TimeLimit.vue +223 -0
  281. package/packages/flowOld/src/component/opinions-file.vue +126 -0
  282. package/packages/flowOld/src/component/opinions.vue +429 -0
  283. package/packages/flowOld/src/component/taskUnionExamine.vue +832 -0
  284. package/packages/flowOld/src/form.vue +134 -0
  285. package/packages/flowOld/src/freeStartFlow.vue +2945 -0
  286. package/packages/flowOld/src/main.vue +4141 -0
  287. package/packages/flowOld/src/processForm.vue +1431 -0
  288. package/packages/flowOld/src/processReject.vue +338 -0
  289. package/packages/flowOld/src/reset.vue +964 -0
  290. package/packages/flowOld/src/selectUser.vue +520 -0
  291. package/packages/flowOld/src/startTaskRead.vue +737 -0
  292. package/packages/flowOld/src/supervise.vue +197 -0
  293. package/packages/flowOld/src/table.vue +71 -0
  294. package/packages/form/src/collapse.vue +40 -59
  295. package/packages/form/src/form-item-render.vue +117 -13
  296. package/packages/form/src/form-item.vue +121 -22
  297. package/packages/form/src/form.vue +62 -59
  298. package/packages/form/src/label-wrap.vue +5 -4
  299. package/packages/form/src/steps.vue +5 -8
  300. package/packages/form-editor/src/components.js +1077 -145
  301. package/packages/form-editor/src/form-editor.vue +94 -80
  302. package/packages/form-editor/src/props-panel.vue +59 -12
  303. package/packages/icons/src/icons.vue +91 -51
  304. package/packages/input/src/input.vue +787 -783
  305. package/packages/input-number/src/input-number.vue +58 -39
  306. package/packages/login/src/login.vue +9 -1
  307. package/packages/lowcode/src/util/components.js +64 -149
  308. package/packages/main/src/components/pages.vue +6 -42
  309. package/packages/main/src/minxs.js +26 -14
  310. package/packages/pagination/src/pagination.js +4 -4
  311. package/packages/phone-login/src/phone-login.vue +1 -4
  312. package/packages/process-rule/src/main.vue +10 -10
  313. package/packages/radio/src/radio-button.vue +10 -1
  314. package/packages/radio/src/radio-group.vue +110 -1
  315. package/packages/radio/src/radio.vue +32 -4
  316. package/packages/rate/src/rate.vue +49 -26
  317. package/packages/retrial-auth/src/main.vue +12 -12
  318. package/packages/select/src/option-group.vue +9 -1
  319. package/packages/select/src/option.vue +9 -1
  320. package/packages/select/src/select.vue +286 -224
  321. package/packages/selector/src/selector.vue +93 -85
  322. package/packages/selector-panel/src/mixin.js +0 -1
  323. package/packages/selector-panel/src/selection.vue +16 -8
  324. package/packages/selector-panel/src/selector-panel.vue +30 -19
  325. package/packages/slider/src/slider.vue +90 -64
  326. package/packages/steps/src/steps.vue +8 -6
  327. package/packages/switch/src/switch.vue +81 -56
  328. package/packages/table/src/store/index.js +3 -3
  329. package/packages/table/src/table.vue +69 -6
  330. package/packages/theme-chalk/src/autocomplete.scss +1 -1
  331. package/packages/theme-chalk/src/base.scss +16 -0
  332. package/packages/theme-chalk/src/cascader.scss +2 -0
  333. package/packages/theme-chalk/src/checkbox-group.scss +2 -0
  334. package/packages/theme-chalk/src/collapse.scss +2 -6
  335. package/packages/theme-chalk/src/common/var.scss +2 -2
  336. package/packages/theme-chalk/src/flow copy.scss +664 -0
  337. package/packages/theme-chalk/src/flow-group.scss +9 -14
  338. package/packages/theme-chalk/src/flow-list.scss +61 -0
  339. package/packages/theme-chalk/src/flow.scss +244 -360
  340. package/packages/theme-chalk/src/form-editor.scss +14 -5
  341. package/packages/theme-chalk/src/form.scss +26 -2
  342. package/packages/theme-chalk/src/icons.scss +30 -24
  343. package/packages/theme-chalk/src/index.scss +1 -0
  344. package/packages/theme-chalk/src/input.scss +6 -0
  345. package/packages/theme-chalk/src/radio-group.scss +3 -2
  346. package/packages/theme-chalk/src/retrial-auth.scss +3 -3
  347. package/packages/theme-chalk/src/selector.scss +14 -1
  348. package/packages/theme-chalk/src/switch.scss +1 -1
  349. package/packages/theme-chalk/src/tabs.scss +2 -5
  350. package/packages/toolbar/src/toolbar.vue +51 -18
  351. package/packages/transfer/src/transfer.vue +79 -40
  352. package/packages/upload/src/index.vue +1531 -1572
  353. package/packages/upload/src/upload.vue +0 -1
  354. package/src/components/field-render.vue +10 -7
  355. package/src/config/api.js +19 -0
  356. package/src/index.js +345 -342
  357. package/src/utils/label.js +53 -0
  358. package/src/utils/util.js +39 -0
package/lib/wujie.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 274);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 278);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -91,348 +91,112 @@ module.exports =
91
91
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
92
92
 
93
93
  "use strict";
94
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return setStorage; });
95
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getStorage; });
96
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return removeStorage; });
97
- /* unused harmony export setCookie */
98
- /* unused harmony export getCookie */
99
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
100
-
101
- /**
102
- * setStorage
103
- * @desc:设置本地储存数据
104
- * @author huangbo
105
- * @date 2022年5月7日
106
- * @param {String|Object} [key] - 数据的名称或包含type、key、value的对象
107
- * @param {String} [value] - 数据的值(当第一个参数为字符串时使用)
108
- **/
109
- var setStorage = function setStorage(key, value) {
110
- // 解析参数,支持两种调用方式:setStorage(key, value) 和 setStorage({type, key, value})
111
- var type = void 0,
112
- finalKey = void 0,
113
- finalValue = void 0;
114
-
115
- if ((typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object' && key !== null) {
116
- // 对象调用方式:setStorage({type, key, value})
117
- type = key.type;
118
- finalKey = key.key;
119
- finalValue = key.value;
120
- } else {
121
- // 字符串调用方式:setStorage(key, value)
122
- type = getStorage('storageType');
123
- finalKey = key;
124
- finalValue = value;
125
- }
126
-
127
- // 使用默认存储类型如果未指定
128
- type = type || getStorage('storageType');
129
-
130
- // 获取存储对象
131
- var storage = type === 'localStorage' ? localStorage : sessionStorage;
132
-
133
- // 处理不同类型的key
134
- if (typeof finalKey === 'string') {
135
- // 单个字符串key
136
- var storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
137
- storage.setItem(finalKey, storedValue);
138
- if (finalKey === 'token') {
139
- setCookie('token', storedValue);
140
- }
141
- } else if (Array.isArray(finalKey)) {
142
- // 数组key,为多个key设置同一个value
143
- var _storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
144
- for (var i = 0; i < finalKey.length; i++) {
145
- storage.setItem(finalKey[i], _storedValue);
146
- if (finalKey[i] === 'token') {
147
- setCookie('token', _storedValue);
148
- }
149
- }
150
- } else if ((typeof finalKey === 'undefined' ? 'undefined' : _typeof(finalKey)) === 'object' && finalKey !== null) {
151
- // 对象key,对象的属性名称作为key,属性值作为value
152
- for (var k in finalKey) {
153
- if (Object.prototype.hasOwnProperty.call(finalKey, k)) {
154
- var _storedValue2 = _typeof(finalKey[k]) === 'object' ? JSON.stringify(finalKey[k]) : finalKey[k];
155
- storage.setItem(k, _storedValue2);
156
- if (k === 'token') {
157
- setCookie('token', _storedValue2);
158
- }
159
- }
160
- }
161
- }
162
- };
163
-
164
- /**
165
- * getStorage
166
- * @desc:获取本地储存数据
167
- * @author huangbo
168
- * @date 2022年5月7日
169
- * @param {String} [key] - 获取的名称
170
- **/
171
- var getStorage = function getStorage(key) {
172
- if (key) {
173
- var res = sessionStorage.getItem(key) || localStorage.getItem(key);
174
- if (!res && key === 'token') {
175
- res = getCookie('token');
176
- }
177
- if (key === 'host' && !res) {
178
- res = '';
179
- }
180
- return res;
181
- }
182
- var defaults = {};
183
- var token = sessionStorage.getItem('token') || localStorage.getItem('token') || getCookie('token');
184
- var ssId = sessionStorage.getItem('ssId') || localStorage.getItem('ssId') || getCookie('ssId');
185
-
186
- var deviceUnique = sessionStorage.getItem('deviceUnique') || localStorage.getItem('deviceUnique') || getCookie('deviceUnique');
187
- if (token) {
188
- defaults.Authorization = token;
189
- }
190
- if (ssId) {
191
- defaults.ssId = ssId;
192
- }
193
- if (deviceUnique) {
194
- defaults.deviceUnique = deviceUnique;
195
- }
196
- return defaults;
197
- };
198
-
199
- /**
200
- * removeStorage
201
- * @desc:删除本地储存数据
202
- * @author huangbo
203
- * @date 2022年5月7日
204
- * @param {String, Array} [key] - 获取的名称
205
- **/
206
- var removeStorage = function removeStorage(key) {
207
- if (Array.isArray(key)) {
208
- for (var i = 0; i < key.length; i++) {
209
- sessionStorage.removeItem(key[i]);
210
- localStorage.removeItem(key[i]);
211
- if (key[i] === 'token') {
212
- removeCookie('token');
213
- }
214
- }
215
- } else if (key) {
216
- sessionStorage.removeItem(key);
217
- localStorage.removeItem(key);
218
- if (key === 'token') {
219
- removeCookie('token');
220
- }
221
- } else {
222
- sessionStorage.clear();
223
- localStorage.clear();
224
- removeCookie('token');
225
- }
226
- };
227
-
228
- /**
229
- * setCookie
230
- * @desc 设置cookie
231
- * @author huangbo
232
- * @param {string} [name] cookie名称
233
- * @param {string} [value] cookie值
234
- * @param {boolean} [isSession] 是否是会话cookie
235
- **/
236
- var setCookie = function setCookie(name, value) {
237
- var isSession = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
238
- var time = arguments[3];
239
-
240
- try {
241
- var cookieParts = [encodeURIComponent(name) + '=' + encodeURIComponent(value), 'path=/' // 仅保留path设置,确保全站访问
242
- ];
243
- // 会话/持久Cookie设置
244
- if (!isSession) {
245
- if (/MSIE|Trident/.test(navigator.userAgent)) {
246
- // IE使用expires
247
- var date = new Date();
248
- date.setTime(date.getTime() + (time || 7 * 24 * 60 * 60 * 1000));
249
- cookieParts.push('expires=' + date.toUTCString());
250
- } else {
251
- // 其他浏览器使用max-age
252
- cookieParts.push('max-age=' + (time || 7 * 24 * 60 * 60));
253
- }
254
- }
255
- // 内核兼容处理
256
- if (/MSIE|Trident/.test(navigator.userAgent)) {
257
- // IE特殊处理:添加P3P协议头
258
- cookieParts.push('P3P=CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
259
- } else {
260
- // 现代浏览器设置
261
- cookieParts.push('samesite=lax');
262
- if (window.location.protocol === 'https:') {
263
- cookieParts.push('secure');
264
- }
265
- }
266
-
267
- // 设置Cookie
268
- document.cookie = cookieParts.join('; ');
269
- return true;
270
- } catch (e) {
271
- console.error('Cookie设置失败:', e);
272
- return false;
273
- }
274
- };
275
-
276
- /**
277
- * getCookie
278
- * @desc 获取cookie中指定名称的值
279
- * @author huangbo
280
- * @param {string} [name] cookie名称
281
- **/
282
- var getCookie = function getCookie(name) {
283
- var cookies = document.cookie.split(';');
284
- for (var _iterator = cookies, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
285
- var _ref;
286
-
287
- if (_isArray) {
288
- if (_i >= _iterator.length) break;
289
- _ref = _iterator[_i++];
290
- } else {
291
- _i = _iterator.next();
292
- if (_i.done) break;
293
- _ref = _i.value;
294
- }
295
-
296
- var cookie = _ref;
297
-
298
- var _cookie$trim$split = cookie.trim().split('='),
299
- cookieName = _cookie$trim$split[0],
300
- cookieValue = _cookie$trim$split[1];
301
-
302
- if (decodeURIComponent(cookieName) === name) {
303
- return decodeURIComponent(cookieValue);
304
- }
305
- }
306
- return null;
307
- };
308
-
309
- /**
310
- * removeCookie
311
- * @desc:删除cookie
312
- * @author huangbo
313
- * @date 2022年5月7日
314
- * @param {String, Array} [key] - 获取的名称
315
- **/
316
- var removeCookie = function removeCookie(key) {
317
- if (Array.isArray(key)) {
318
- for (var i = 0; i < key.length; i++) {
319
- document.cookie = encodeURIComponent(key[i]) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
320
- }
321
- } else {
322
- document.cookie = encodeURIComponent(key) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
323
- }
324
- };
325
-
326
- /***/ }),
327
-
328
- /***/ 1:
329
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
330
-
331
- "use strict";
332
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return noop; });
333
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return hasOwn; });
334
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return toObject; });
335
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return getValueByPath; });
336
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return getPropByPath; });
337
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return generateId; });
338
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return valueEquals; });
339
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return escapeRegexpString; });
94
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return noop; });
95
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return hasOwn; });
96
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return toObject; });
97
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return getValueByPath; });
98
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return getPropByPath; });
99
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return generateId; });
100
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bb", function() { return valueEquals; });
101
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return escapeRegexpString; });
340
102
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return arrayFindIndex; });
341
103
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return arrayFind; });
342
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return coerceTruthyValueToArray; });
343
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return isIE; });
344
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return isEdge; });
345
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return isFirefox; });
104
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return coerceTruthyValueToArray; });
105
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return isIE; });
106
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return isEdge; });
107
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return isFirefox; });
346
108
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return autoprefixer; });
347
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return kebabCase; });
109
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return kebabCase; });
348
110
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return capitalize; });
349
111
  /* unused harmony export looseEqual */
350
112
  /* unused harmony export arrayEquals */
351
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return isEqual; });
352
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return rafThrottle; });
113
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return isEqual; });
114
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return rafThrottle; });
353
115
  /* unused harmony export objToArray */
354
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return requestAnimationFrame; });
116
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return requestAnimationFrame; });
355
117
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return cancelAnimationFrame; });
356
118
  /* unused harmony export debounce */
357
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return throttle; });
119
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return throttle; });
358
120
  /* unused harmony export guid */
359
121
  /* unused harmony export uid */
360
122
  /* unused harmony export get */
361
123
  /* unused harmony export set */
362
- /* unused harmony export cloneDeep */
124
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return cloneDeep; });
363
125
  /* unused harmony export grouping */
364
126
  /* unused harmony export pager */
365
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return getWinTop; });
127
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return getWinTop; });
366
128
  /* unused harmony export getFileType */
367
129
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return arrUnique; });
368
130
  /* unused harmony export average */
369
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return formatFileSize; });
131
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return formatFileSize; });
370
132
  /* unused harmony export browser */
371
133
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return busEmit; });
372
134
  /* unused harmony export chunkToChinese */
373
135
  /* unused harmony export concatenate */
374
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return delUrlParam; });
136
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return delUrlParam; });
375
137
  /* unused harmony export domEval */
376
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return downloadFile; });
377
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return encode; });
378
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return decode; });
379
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return exclAttribute; });
138
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return downloadFile; });
139
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return encode; });
140
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return decode; });
141
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return exclAttribute; });
380
142
  /* unused harmony export exportXls */
381
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return extend; });
143
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return extend; });
382
144
  /* unused harmony export getObjectType */
383
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return getParams; });
145
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return getParams; });
384
146
  /* unused harmony export getScript */
385
147
  /* unused harmony export getStyle */
386
148
  /* unused harmony export getTypeName */
387
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return getTypePrefix; });
149
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return getTypePrefix; });
388
150
  /* unused harmony export getValues */
389
151
  /* unused harmony export getZoom */
390
152
  /* unused harmony export getLength */
391
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return timestampUrl; });
153
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return timestampUrl; });
392
154
  /* unused harmony export hasChars */
393
155
  /* unused harmony export identical */
394
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return indexOfObj; });
395
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return isEmpty; });
396
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return isExist; });
156
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return indexOfObj; });
157
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return isEmpty; });
158
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return isExist; });
397
159
  /* unused harmony export isFunction */
398
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return isObjectEqual; });
399
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return joinUrl; });
160
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return isObjectEqual; });
161
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return joinUrl; });
400
162
  /* unused harmony export getHorizontalMargin */
401
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return layoutWaterfall; });
163
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return layoutWaterfall; });
402
164
  /* unused harmony export loadJs */
403
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return loading; });
165
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return loading; });
404
166
  /* unused harmony export lowerCase */
405
167
  /* unused harmony export overbrim */
406
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return queryParams; });
168
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return queryParams; });
407
169
  /* unused harmony export receiveMessage */
408
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return renderIcon; });
170
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return renderIcon; });
409
171
  /* unused harmony export replenish */
410
172
  /* unused harmony export rmbToCapital */
411
173
  /* unused harmony export setScale */
412
174
  /* unused harmony export sendMessage */
413
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return setFavicon; });
175
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return setFavicon; });
414
176
  /* unused harmony export sum */
415
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return startWith; });
177
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return startWith; });
416
178
  /* unused harmony export takeLeft */
417
179
  /* unused harmony export takeRight */
418
180
  /* unused harmony export trimWhitespace */
419
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return toFixed; });
181
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return toFixed; });
420
182
  /* unused harmony export toFunction */
421
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return updateTheme; });
183
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return updateTheme; });
422
184
  /* unused harmony export upperType */
423
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return urlJoinParams; });
424
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return uuid; });
425
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return watermark; });
185
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return urlJoinParams; });
186
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return uuid; });
187
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "db", function() { return watermark; });
426
188
  /* unused harmony export winTopOpen */
427
189
  /* unused harmony export confirm */
428
- /* unused harmony export success */
429
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return error; });
430
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return warning; });
190
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return success; });
191
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return error; });
192
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cb", function() { return warning; });
193
+ /* unused harmony export base64 */
194
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return renderUrl; });
431
195
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
432
196
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
433
197
  /* harmony import */ var _color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
434
198
  /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
435
- /* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
199
+ /* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
436
200
  /* harmony import */ var _date__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
437
201
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
438
202
 
@@ -3282,13 +3046,286 @@ var warning = function warning(content, _callback3) {
3282
3046
  }
3283
3047
  return MessageBox.alert(content, '提示', config);
3284
3048
  };
3049
+ /**
3050
+ * @desc 基于 Unicode 的 base64 编码,兼容中文等非 Latin1 字符
3051
+ * @param {any} val 任意值,null/undefined 返回空串
3052
+ * @return {string}
3053
+ **/
3054
+ var base64 = function base64(val) {
3055
+ if (val === null || val === undefined) return '';
3056
+ try {
3057
+ return window.btoa(unescape(encodeURIComponent(String(val))));
3058
+ } catch (e) {
3059
+ return '';
3060
+ }
3061
+ };
3062
+
3063
+ /**
3064
+ * @desc URL 渲染,将 userInfo 中的值替换到 URL 中的占位符
3065
+ * @param {string} url 需要渲染的 URL
3066
+ * @param {object} userInfo 用户信息
3067
+ * @return {string}
3068
+ **/
3069
+ var renderUrl = function renderUrl(url) {
3070
+ var userInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3071
+
3072
+ if (!url || typeof url !== 'string') return url;
3073
+ // const userInfo = this.$main.userInfo || this.$main.userModel || {};
3074
+ Object.keys(userInfo).forEach(function (key) {
3075
+ var val = userInfo[key];
3076
+ if (val === null || val === undefined) return;
3077
+ var safeKey = escapeRegexpString(key);
3078
+ var rawVal = String(val);
3079
+ var b64Val = base64(rawVal);
3080
+ // {base64-xxx} 与 {xxx} 两种占位符都要替换;
3081
+ // 使用函数式 replacement,避免值中的 $& / $1 等被特殊解释
3082
+ url = url.replace(new RegExp('\\{base64-' + safeKey + '\\}', 'g'), function () {
3083
+ return b64Val;
3084
+ });
3085
+ url = url.replace(new RegExp('\\{' + safeKey + '\\}', 'g'), function () {
3086
+ return rawVal;
3087
+ });
3088
+ });
3089
+ return url;
3090
+ };
3285
3091
 
3286
3092
  /***/ }),
3287
3093
 
3288
- /***/ 119:
3289
- /***/ (function(module, exports) {
3094
+ /***/ 1:
3095
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3290
3096
 
3291
- module.exports = require("wujie-vue2");
3097
+ "use strict";
3098
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return setStorage; });
3099
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getStorage; });
3100
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return removeStorage; });
3101
+ /* unused harmony export setCookie */
3102
+ /* unused harmony export getCookie */
3103
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
3104
+
3105
+ /**
3106
+ * setStorage
3107
+ * @desc:设置本地储存数据
3108
+ * @author huangbo
3109
+ * @date 2022年5月7日
3110
+ * @param {String|Object} [key] - 数据的名称或包含type、key、value的对象
3111
+ * @param {String} [value] - 数据的值(当第一个参数为字符串时使用)
3112
+ **/
3113
+ var setStorage = function setStorage(key, value) {
3114
+ // 解析参数,支持两种调用方式:setStorage(key, value) 和 setStorage({type, key, value})
3115
+ var type = void 0,
3116
+ finalKey = void 0,
3117
+ finalValue = void 0;
3118
+
3119
+ if ((typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object' && key !== null) {
3120
+ // 对象调用方式:setStorage({type, key, value})
3121
+ type = key.type;
3122
+ finalKey = key.key;
3123
+ finalValue = key.value;
3124
+ } else {
3125
+ // 字符串调用方式:setStorage(key, value)
3126
+ type = getStorage('storageType');
3127
+ finalKey = key;
3128
+ finalValue = value;
3129
+ }
3130
+
3131
+ // 使用默认存储类型如果未指定
3132
+ type = type || getStorage('storageType');
3133
+
3134
+ // 获取存储对象
3135
+ var storage = type === 'localStorage' ? localStorage : sessionStorage;
3136
+
3137
+ // 处理不同类型的key
3138
+ if (typeof finalKey === 'string') {
3139
+ // 单个字符串key
3140
+ var storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
3141
+ storage.setItem(finalKey, storedValue);
3142
+ if (finalKey === 'token') {
3143
+ setCookie('token', storedValue);
3144
+ }
3145
+ } else if (Array.isArray(finalKey)) {
3146
+ // 数组key,为多个key设置同一个value
3147
+ var _storedValue = (typeof finalValue === 'undefined' ? 'undefined' : _typeof(finalValue)) === 'object' ? JSON.stringify(finalValue) : finalValue;
3148
+ for (var i = 0; i < finalKey.length; i++) {
3149
+ storage.setItem(finalKey[i], _storedValue);
3150
+ if (finalKey[i] === 'token') {
3151
+ setCookie('token', _storedValue);
3152
+ }
3153
+ }
3154
+ } else if ((typeof finalKey === 'undefined' ? 'undefined' : _typeof(finalKey)) === 'object' && finalKey !== null) {
3155
+ // 对象key,对象的属性名称作为key,属性值作为value
3156
+ for (var k in finalKey) {
3157
+ if (Object.prototype.hasOwnProperty.call(finalKey, k)) {
3158
+ var _storedValue2 = _typeof(finalKey[k]) === 'object' ? JSON.stringify(finalKey[k]) : finalKey[k];
3159
+ storage.setItem(k, _storedValue2);
3160
+ if (k === 'token') {
3161
+ setCookie('token', _storedValue2);
3162
+ }
3163
+ }
3164
+ }
3165
+ }
3166
+ };
3167
+
3168
+ /**
3169
+ * getStorage
3170
+ * @desc:获取本地储存数据
3171
+ * @author huangbo
3172
+ * @date 2022年5月7日
3173
+ * @param {String} [key] - 获取的名称
3174
+ **/
3175
+ var getStorage = function getStorage(key) {
3176
+ if (key) {
3177
+ var res = sessionStorage.getItem(key) || localStorage.getItem(key);
3178
+ if (!res && key === 'token') {
3179
+ res = getCookie('token');
3180
+ }
3181
+ if (key === 'host' && !res) {
3182
+ res = '';
3183
+ }
3184
+ return res;
3185
+ }
3186
+ var defaults = {};
3187
+ var token = sessionStorage.getItem('token') || localStorage.getItem('token') || getCookie('token');
3188
+ var ssId = sessionStorage.getItem('ssId') || localStorage.getItem('ssId') || getCookie('ssId');
3189
+
3190
+ var deviceUnique = sessionStorage.getItem('deviceUnique') || localStorage.getItem('deviceUnique') || getCookie('deviceUnique');
3191
+ if (token) {
3192
+ defaults.Authorization = token;
3193
+ }
3194
+ if (ssId) {
3195
+ defaults.ssId = ssId;
3196
+ }
3197
+ if (deviceUnique) {
3198
+ defaults.deviceUnique = deviceUnique;
3199
+ }
3200
+ return defaults;
3201
+ };
3202
+
3203
+ /**
3204
+ * removeStorage
3205
+ * @desc:删除本地储存数据
3206
+ * @author huangbo
3207
+ * @date 2022年5月7日
3208
+ * @param {String, Array} [key] - 获取的名称
3209
+ **/
3210
+ var removeStorage = function removeStorage(key) {
3211
+ if (Array.isArray(key)) {
3212
+ for (var i = 0; i < key.length; i++) {
3213
+ sessionStorage.removeItem(key[i]);
3214
+ localStorage.removeItem(key[i]);
3215
+ if (key[i] === 'token') {
3216
+ removeCookie('token');
3217
+ }
3218
+ }
3219
+ } else if (key) {
3220
+ sessionStorage.removeItem(key);
3221
+ localStorage.removeItem(key);
3222
+ if (key === 'token') {
3223
+ removeCookie('token');
3224
+ }
3225
+ } else {
3226
+ sessionStorage.clear();
3227
+ localStorage.clear();
3228
+ removeCookie('token');
3229
+ }
3230
+ };
3231
+
3232
+ /**
3233
+ * setCookie
3234
+ * @desc 设置cookie
3235
+ * @author huangbo
3236
+ * @param {string} [name] cookie名称
3237
+ * @param {string} [value] cookie值
3238
+ * @param {boolean} [isSession] 是否是会话cookie
3239
+ **/
3240
+ var setCookie = function setCookie(name, value) {
3241
+ var isSession = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3242
+ var time = arguments[3];
3243
+
3244
+ try {
3245
+ var cookieParts = [encodeURIComponent(name) + '=' + encodeURIComponent(value), 'path=/' // 仅保留path设置,确保全站访问
3246
+ ];
3247
+ // 会话/持久Cookie设置
3248
+ if (!isSession) {
3249
+ if (/MSIE|Trident/.test(navigator.userAgent)) {
3250
+ // IE使用expires
3251
+ var date = new Date();
3252
+ date.setTime(date.getTime() + (time || 7 * 24 * 60 * 60 * 1000));
3253
+ cookieParts.push('expires=' + date.toUTCString());
3254
+ } else {
3255
+ // 其他浏览器使用max-age
3256
+ cookieParts.push('max-age=' + (time || 7 * 24 * 60 * 60));
3257
+ }
3258
+ }
3259
+ // 内核兼容处理
3260
+ if (/MSIE|Trident/.test(navigator.userAgent)) {
3261
+ // IE特殊处理:添加P3P协议头
3262
+ cookieParts.push('P3P=CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
3263
+ } else {
3264
+ // 现代浏览器设置
3265
+ cookieParts.push('samesite=lax');
3266
+ if (window.location.protocol === 'https:') {
3267
+ cookieParts.push('secure');
3268
+ }
3269
+ }
3270
+
3271
+ // 设置Cookie
3272
+ document.cookie = cookieParts.join('; ');
3273
+ return true;
3274
+ } catch (e) {
3275
+ console.error('Cookie设置失败:', e);
3276
+ return false;
3277
+ }
3278
+ };
3279
+
3280
+ /**
3281
+ * getCookie
3282
+ * @desc 获取cookie中指定名称的值
3283
+ * @author huangbo
3284
+ * @param {string} [name] cookie名称
3285
+ **/
3286
+ var getCookie = function getCookie(name) {
3287
+ var cookies = document.cookie.split(';');
3288
+ for (var _iterator = cookies, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
3289
+ var _ref;
3290
+
3291
+ if (_isArray) {
3292
+ if (_i >= _iterator.length) break;
3293
+ _ref = _iterator[_i++];
3294
+ } else {
3295
+ _i = _iterator.next();
3296
+ if (_i.done) break;
3297
+ _ref = _i.value;
3298
+ }
3299
+
3300
+ var cookie = _ref;
3301
+
3302
+ var _cookie$trim$split = cookie.trim().split('='),
3303
+ cookieName = _cookie$trim$split[0],
3304
+ cookieValue = _cookie$trim$split[1];
3305
+
3306
+ if (decodeURIComponent(cookieName) === name) {
3307
+ return decodeURIComponent(cookieValue);
3308
+ }
3309
+ }
3310
+ return null;
3311
+ };
3312
+
3313
+ /**
3314
+ * removeCookie
3315
+ * @desc:删除cookie
3316
+ * @author huangbo
3317
+ * @date 2022年5月7日
3318
+ * @param {String, Array} [key] - 获取的名称
3319
+ **/
3320
+ var removeCookie = function removeCookie(key) {
3321
+ if (Array.isArray(key)) {
3322
+ for (var i = 0; i < key.length; i++) {
3323
+ document.cookie = encodeURIComponent(key[i]) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
3324
+ }
3325
+ } else {
3326
+ document.cookie = encodeURIComponent(key) + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
3327
+ }
3328
+ };
3292
3329
 
3293
3330
  /***/ }),
3294
3331
 
@@ -3304,7 +3341,7 @@ module.exports = require("wujie-vue2");
3304
3341
  /* unused harmony export hsvTorgb */
3305
3342
  /* unused harmony export mixColor */
3306
3343
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getRgb; });
3307
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
3344
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
3308
3345
 
3309
3346
  var $hueStep = 2;
3310
3347
  var $saturationStep1 = 0.16;
@@ -3355,7 +3392,7 @@ var getColor = function getColor($color, $n) {
3355
3392
  var getLightness = function getLightness($v, $i, $isLight) {
3356
3393
  var $value = $isLight ? $v + $brightnessStep1 * $i : $v - $brightnessStep2 * $i;
3357
3394
  $value = $value < 1 ? $value : 1;
3358
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($value, 2);
3395
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($value, 2);
3359
3396
  };
3360
3397
 
3361
3398
  /**
@@ -3379,7 +3416,7 @@ var getSaturation = function getSaturation($s, $i, $isLight) {
3379
3416
  $saturation = 0.1;
3380
3417
  }
3381
3418
  $saturation = $saturation > 0.06 ? $saturation : 0.06;
3382
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($saturation, 2);
3419
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($saturation, 2);
3383
3420
  };
3384
3421
 
3385
3422
  /**
@@ -3493,7 +3530,14 @@ var getRgb = function getRgb($color) {
3493
3530
 
3494
3531
  /***/ }),
3495
3532
 
3496
- /***/ 136:
3533
+ /***/ 121:
3534
+ /***/ (function(module, exports) {
3535
+
3536
+ module.exports = require("wujie-vue2");
3537
+
3538
+ /***/ }),
3539
+
3540
+ /***/ 139:
3497
3541
  /***/ (function(module, exports) {
3498
3542
 
3499
3543
  module.exports = require("wujie-polyfill");
@@ -3535,7 +3579,7 @@ module.exports = require("vue");
3535
3579
 
3536
3580
  /***/ }),
3537
3581
 
3538
- /***/ 274:
3582
+ /***/ 278:
3539
3583
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3540
3584
 
3541
3585
  "use strict";
@@ -3608,14 +3652,14 @@ var external_vue_ = __webpack_require__(2);
3608
3652
  var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
3609
3653
 
3610
3654
  // EXTERNAL MODULE: external "wujie-vue2"
3611
- var external_wujie_vue2_ = __webpack_require__(119);
3655
+ var external_wujie_vue2_ = __webpack_require__(121);
3612
3656
  var external_wujie_vue2_default = /*#__PURE__*/__webpack_require__.n(external_wujie_vue2_);
3613
3657
 
3614
3658
  // EXTERNAL MODULE: external "wujie-polyfill"
3615
- var external_wujie_polyfill_ = __webpack_require__(136);
3659
+ var external_wujie_polyfill_ = __webpack_require__(139);
3616
3660
 
3617
3661
  // EXTERNAL MODULE: ./src/utils/util.js
3618
- var util = __webpack_require__(1);
3662
+ var util = __webpack_require__(0);
3619
3663
 
3620
3664
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/wujie/src/wujie.vue?vue&type=script&lang=js&
3621
3665
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
@@ -3728,7 +3772,7 @@ var bus = external_wujie_vue2_default.a.bus,
3728
3772
  computed: {
3729
3773
  appUrl: function appUrl() {
3730
3774
  if (this.host && this.url) {
3731
- return Object(util["Q" /* startWith */])(this.url, ['http://', 'https://']) ? this.url : '' + this.host + this.url;
3775
+ return Object(util["S" /* startWith */])(this.url, ['http://', 'https://']) ? this.url : '' + this.host + this.url;
3732
3776
  }
3733
3777
  return this.url;
3734
3778
  },
@@ -4163,736 +4207,759 @@ function normalizeComponent(
4163
4207
  /* unused harmony export getSecond */
4164
4208
  /* unused harmony export getWeekday */
4165
4209
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4166
-
4167
-
4210
+ /* Modified from https://github.com/taylorhakes/fecha
4211
+ *
4212
+ * The MIT License (MIT)
4213
+ *
4214
+ * Copyright (c) 2015 Taylor Hakes
4215
+ *
4216
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4217
+ * of this software and associated documentation files (the "Software"), to deal
4218
+ * in the Software without restriction, including without limitation the rights
4219
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4220
+ * copies of the Software, and to permit persons to whom the Software is
4221
+ * furnished to do so, subject to the following conditions:
4222
+ *
4223
+ * The above copyright notice and this permission notice shall be included in all
4224
+ * copies or substantial portions of the Software.
4225
+ *
4226
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4227
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4228
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4229
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4230
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4231
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4232
+ * SOFTWARE.
4233
+ */
4234
+
4235
+ /*eslint-disable*/
4236
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
4237
+
4238
+
4168
4239
  /**
4169
4240
  * Parse or format dates
4170
4241
  * @class fecha
4171
- */
4172
- var fecha = {};
4173
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4174
- var twoDigits = '\\d\\d?';
4175
- var threeDigits = '\\d{3}';
4176
- var fourDigits = '\\d{4}';
4177
- var word = '[^\\s]+';
4178
- var literal = /\[([^]*?)\]/gm;
4179
- var noop = function noop() {};
4180
-
4181
- function regexEscape(str) {
4182
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4183
- }
4184
-
4185
- function shorten(arr, sLen) {
4186
- var newArr = [];
4187
- for (var i = 0, len = arr.length; i < len; i++) {
4188
- newArr.push(arr[i].substr(0, sLen));
4189
- }
4190
- return newArr;
4191
- }
4192
-
4193
- function monthUpdate() {
4194
- return function (d, v) {
4195
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4196
- if (~index) {
4197
- d.month = index;
4198
- }
4199
- };
4200
- }
4201
-
4202
- function pad(val, len) {
4203
- val = String(val);
4204
- len = len || 2;
4205
- while (val.length < len) {
4206
- val = '0' + val;
4207
- }
4208
- return val;
4209
- }
4210
-
4211
- // 直接使用中文日期名称常量
4212
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4213
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4214
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4215
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4216
- var amPm = ['上午', '下午'];
4217
- var DoFn = function DoFn(D) {
4218
- return D + '日';
4219
- };
4220
-
4221
- var formatFlags = {
4222
- D: function D(dateObj) {
4223
- return dateObj.getDay();
4224
- },
4225
- DD: function DD(dateObj) {
4226
- return pad(dateObj.getDay());
4227
- },
4228
- Do: function Do(dateObj) {
4229
- return DoFn(dateObj.getDate());
4230
- },
4231
- d: function d(dateObj) {
4232
- return dateObj.getDate();
4233
- },
4234
- dd: function dd(dateObj) {
4235
- return pad(dateObj.getDate());
4236
- },
4237
- ddd: function ddd(dateObj) {
4238
- return dayNamesShort[dateObj.getDay()];
4239
- },
4240
- dddd: function dddd(dateObj) {
4241
- return dayNames[dateObj.getDay()];
4242
- },
4243
- M: function M(dateObj) {
4244
- return dateObj.getMonth() + 1;
4245
- },
4246
- MM: function MM(dateObj) {
4247
- return pad(dateObj.getMonth() + 1);
4248
- },
4249
- MMM: function MMM(dateObj) {
4250
- return monthNamesShort[dateObj.getMonth()];
4251
- },
4252
- MMMM: function MMMM(dateObj) {
4253
- return monthNames[dateObj.getMonth()];
4254
- },
4255
- yy: function yy(dateObj) {
4256
- return pad(String(dateObj.getFullYear()), 4).substr(2);
4257
- },
4258
- yyyy: function yyyy(dateObj) {
4259
- return pad(dateObj.getFullYear(), 4);
4260
- },
4261
- h: function h(dateObj) {
4262
- return dateObj.getHours() % 12 || 12;
4263
- },
4264
- hh: function hh(dateObj) {
4265
- return pad(dateObj.getHours() % 12 || 12);
4266
- },
4267
- H: function H(dateObj) {
4268
- return dateObj.getHours();
4269
- },
4270
- HH: function HH(dateObj) {
4271
- return pad(dateObj.getHours());
4272
- },
4273
- m: function m(dateObj) {
4274
- return dateObj.getMinutes();
4275
- },
4276
- mm: function mm(dateObj) {
4277
- return pad(dateObj.getMinutes());
4278
- },
4279
- s: function s(dateObj) {
4280
- return dateObj.getSeconds();
4281
- },
4282
- ss: function ss(dateObj) {
4283
- return pad(dateObj.getSeconds());
4284
- },
4285
- S: function S(dateObj) {
4286
- return Math.round(dateObj.getMilliseconds() / 100);
4287
- },
4288
- SS: function SS(dateObj) {
4289
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4290
- },
4291
- SSS: function SSS(dateObj) {
4292
- return pad(dateObj.getMilliseconds(), 3);
4293
- },
4294
- a: function a(dateObj) {
4295
- return dateObj.getHours() < 12 ? '上午' : '下午';
4296
- },
4297
- A: function A(dateObj) {
4298
- return dateObj.getHours() < 12 ? '上午' : '下午';
4299
- },
4300
- ZZ: function ZZ(dateObj) {
4301
- var o = dateObj.getTimezoneOffset();
4302
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4303
- }
4304
- };
4305
-
4306
- var parseFlags = {
4307
- d: [twoDigits, function (d, v) {
4308
- d.day = v;
4309
- }],
4310
- Do: [twoDigits + word, function (d, v) {
4311
- d.day = parseInt(v, 10);
4312
- }],
4313
- M: [twoDigits, function (d, v) {
4314
- d.month = v - 1;
4315
- }],
4316
- yy: [twoDigits, function (d, v) {
4317
- var da = new Date(),
4318
- cent = +('' + da.getFullYear()).substr(0, 2);
4319
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4320
- }],
4321
- h: [twoDigits, function (d, v) {
4322
- d.hour = v;
4323
- }],
4324
- m: [twoDigits, function (d, v) {
4325
- d.minute = v;
4326
- }],
4327
- s: [twoDigits, function (d, v) {
4328
- d.second = v;
4329
- }],
4330
- yyyy: [fourDigits, function (d, v) {
4331
- d.year = v;
4332
- }],
4333
- S: ['\\d', function (d, v) {
4334
- d.millisecond = v * 100;
4335
- }],
4336
- SS: ['\\d{2}', function (d, v) {
4337
- d.millisecond = v * 10;
4338
- }],
4339
- SSS: [threeDigits, function (d, v) {
4340
- d.millisecond = v;
4341
- }],
4342
- D: [twoDigits, noop],
4343
- ddd: [word, noop],
4344
- MMM: [word, monthUpdate('monthNamesShort')],
4345
- MMMM: [word, monthUpdate('monthNames')],
4346
- a: [word, function (d, v) {
4347
- var val = v.toLowerCase();
4348
- if (val === '上午') {
4349
- d.isPm = false;
4350
- } else if (val === '下午') {
4351
- d.isPm = true;
4352
- }
4353
- }],
4354
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4355
- var parts = (v + '').match(/([+-]|\d\d)/gi),
4356
- minutes = void 0;
4357
-
4358
- if (parts) {
4359
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4360
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4361
- }
4362
- }]
4363
- };
4364
- parseFlags.dd = parseFlags.d;
4365
- parseFlags.dddd = parseFlags.ddd;
4366
- parseFlags.DD = parseFlags.D;
4367
- parseFlags.mm = parseFlags.m;
4368
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4369
- parseFlags.MM = parseFlags.M;
4370
- parseFlags.ss = parseFlags.s;
4371
- parseFlags.A = parseFlags.a;
4372
-
4373
- // Some common format strings
4374
- fecha.masks = {
4375
- default: 'ddd MMM dd yyyy HH:mm:ss',
4376
- shortDate: 'M/D/yy',
4377
- mediumDate: 'MMM d, yyyy',
4378
- longDate: 'MMMM d, yyyy',
4379
- fullDate: 'dddd, MMMM d, yyyy',
4380
- shortTime: 'HH:mm',
4381
- mediumTime: 'HH:mm:ss',
4382
- longTime: 'HH:mm:ss.SSS'
4383
- };
4384
-
4242
+ */
4243
+ const fecha = {};
4244
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4245
+ const twoDigits = '\\d\\d?';
4246
+ const threeDigits = '\\d{3}';
4247
+ const fourDigits = '\\d{4}';
4248
+ const word = '[^\\s]+';
4249
+ const literal = /\[([^]*?)\]/gm;
4250
+ const noop = function () {};
4251
+
4252
+ function regexEscape(str) {
4253
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4254
+ }
4255
+
4256
+ function shorten(arr, sLen) {
4257
+ const newArr = [];
4258
+ for (let i = 0, len = arr.length; i < len; i++) {
4259
+ newArr.push(arr[i].substr(0, sLen));
4260
+ }
4261
+ return newArr;
4262
+ }
4263
+
4264
+ function monthUpdate() {
4265
+ return function (d, v) {
4266
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4267
+ if (~index) {
4268
+ d.month = index;
4269
+ }
4270
+ };
4271
+ }
4272
+
4273
+ function pad(val, len) {
4274
+ val = String(val);
4275
+ len = len || 2;
4276
+ while (val.length < len) {
4277
+ val = '0' + val;
4278
+ }
4279
+ return val;
4280
+ }
4281
+
4282
+ // 直接使用中文日期名称常量
4283
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4284
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4285
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4286
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4287
+ const amPm = ['上午', '下午'];
4288
+ const DoFn = function DoFn(D) {
4289
+ return D + '日';
4290
+ };
4291
+
4292
+ const formatFlags = {
4293
+ D: function(dateObj) {
4294
+ return dateObj.getDay();
4295
+ },
4296
+ DD: function(dateObj) {
4297
+ return pad(dateObj.getDay());
4298
+ },
4299
+ Do: function(dateObj) {
4300
+ return DoFn(dateObj.getDate());
4301
+ },
4302
+ d: function(dateObj) {
4303
+ return dateObj.getDate();
4304
+ },
4305
+ dd: function(dateObj) {
4306
+ return pad(dateObj.getDate());
4307
+ },
4308
+ ddd: function(dateObj) {
4309
+ return dayNamesShort[dateObj.getDay()];
4310
+ },
4311
+ dddd: function(dateObj) {
4312
+ return dayNames[dateObj.getDay()];
4313
+ },
4314
+ M: function(dateObj) {
4315
+ return dateObj.getMonth() + 1;
4316
+ },
4317
+ MM: function(dateObj) {
4318
+ return pad(dateObj.getMonth() + 1);
4319
+ },
4320
+ MMM: function(dateObj) {
4321
+ return monthNamesShort[dateObj.getMonth()];
4322
+ },
4323
+ MMMM: function(dateObj) {
4324
+ return monthNames[dateObj.getMonth()];
4325
+ },
4326
+ yy: function(dateObj) {
4327
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
4328
+ },
4329
+ yyyy: function(dateObj) {
4330
+ return pad(dateObj.getFullYear(), 4);
4331
+ },
4332
+ h: function(dateObj) {
4333
+ return dateObj.getHours() % 12 || 12;
4334
+ },
4335
+ hh: function(dateObj) {
4336
+ return pad(dateObj.getHours() % 12 || 12);
4337
+ },
4338
+ H: function(dateObj) {
4339
+ return dateObj.getHours();
4340
+ },
4341
+ HH: function(dateObj) {
4342
+ return pad(dateObj.getHours());
4343
+ },
4344
+ m: function(dateObj) {
4345
+ return dateObj.getMinutes();
4346
+ },
4347
+ mm: function(dateObj) {
4348
+ return pad(dateObj.getMinutes());
4349
+ },
4350
+ s: function(dateObj) {
4351
+ return dateObj.getSeconds();
4352
+ },
4353
+ ss: function(dateObj) {
4354
+ return pad(dateObj.getSeconds());
4355
+ },
4356
+ S: function(dateObj) {
4357
+ return Math.round(dateObj.getMilliseconds() / 100);
4358
+ },
4359
+ SS: function(dateObj) {
4360
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4361
+ },
4362
+ SSS: function(dateObj) {
4363
+ return pad(dateObj.getMilliseconds(), 3);
4364
+ },
4365
+ a: function(dateObj) {
4366
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4367
+ },
4368
+ A: function(dateObj) {
4369
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4370
+ },
4371
+ ZZ: function(dateObj) {
4372
+ const o = dateObj.getTimezoneOffset();
4373
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4374
+ }
4375
+ };
4376
+
4377
+ const parseFlags = {
4378
+ d: [twoDigits, function (d, v) {
4379
+ d.day = v;
4380
+ }],
4381
+ Do: [twoDigits + word, function (d, v) {
4382
+ d.day = parseInt(v, 10);
4383
+ }],
4384
+ M: [twoDigits, function (d, v) {
4385
+ d.month = v - 1;
4386
+ }],
4387
+ yy: [twoDigits, function (d, v) {
4388
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
4389
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4390
+ }],
4391
+ h: [twoDigits, function (d, v) {
4392
+ d.hour = v;
4393
+ }],
4394
+ m: [twoDigits, function (d, v) {
4395
+ d.minute = v;
4396
+ }],
4397
+ s: [twoDigits, function (d, v) {
4398
+ d.second = v;
4399
+ }],
4400
+ yyyy: [fourDigits, function (d, v) {
4401
+ d.year = v;
4402
+ }],
4403
+ S: ['\\d', function (d, v) {
4404
+ d.millisecond = v * 100;
4405
+ }],
4406
+ SS: ['\\d{2}', function (d, v) {
4407
+ d.millisecond = v * 10;
4408
+ }],
4409
+ SSS: [threeDigits, function (d, v) {
4410
+ d.millisecond = v;
4411
+ }],
4412
+ D: [twoDigits, noop],
4413
+ ddd: [word, noop],
4414
+ MMM: [word, monthUpdate('monthNamesShort')],
4415
+ MMMM: [word, monthUpdate('monthNames')],
4416
+ a: [word, function (d, v) {
4417
+ const val = v.toLowerCase();
4418
+ if (val === '上午') {
4419
+ d.isPm = false;
4420
+ } else if (val === '下午') {
4421
+ d.isPm = true;
4422
+ }
4423
+ }],
4424
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4425
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
4426
+
4427
+ if (parts) {
4428
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4429
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4430
+ }
4431
+ }]
4432
+ };
4433
+ parseFlags.dd = parseFlags.d;
4434
+ parseFlags.dddd = parseFlags.ddd;
4435
+ parseFlags.DD = parseFlags.D;
4436
+ parseFlags.mm = parseFlags.m;
4437
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4438
+ parseFlags.MM = parseFlags.M;
4439
+ parseFlags.ss = parseFlags.s;
4440
+ parseFlags.A = parseFlags.a;
4441
+
4442
+
4443
+ // Some common format strings
4444
+ fecha.masks = {
4445
+ default: 'ddd MMM dd yyyy HH:mm:ss',
4446
+ shortDate: 'M/D/yy',
4447
+ mediumDate: 'MMM d, yyyy',
4448
+ longDate: 'MMMM d, yyyy',
4449
+ fullDate: 'dddd, MMMM d, yyyy',
4450
+ shortTime: 'HH:mm',
4451
+ mediumTime: 'HH:mm:ss',
4452
+ longTime: 'HH:mm:ss.SSS'
4453
+ };
4454
+
4385
4455
  /***
4386
4456
  * Format a date
4387
4457
  * @method format
4388
4458
  * @param {Date|number} dateObj
4389
4459
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
4390
- */
4391
- fecha.format = function (dateObj, mask) {
4392
- if (typeof dateObj === 'number') {
4393
- dateObj = new Date(dateObj);
4394
- }
4395
-
4396
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4397
- throw new Error('Invalid Date in fecha.format');
4398
- }
4399
-
4400
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
4401
-
4402
- var literals = [];
4403
-
4404
- // Make literals inactive by replacing them with ??
4405
- mask = mask.replace(literal, function ($0, $1) {
4406
- literals.push($1);
4407
- return '@@@';
4408
- });
4409
- // Apply formatting rules
4410
- mask = mask.replace(token, function ($0) {
4411
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4412
- });
4413
- // Inline literal values back into the formatted value
4414
- return mask.replace(/@@@/g, function () {
4415
- return literals.shift();
4416
- });
4417
- };
4418
-
4460
+ */
4461
+ fecha.format = function (dateObj, mask) {
4462
+ if (typeof dateObj === 'number') {
4463
+ dateObj = new Date(dateObj);
4464
+ }
4465
+
4466
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4467
+ throw new Error('Invalid Date in fecha.format');
4468
+ }
4469
+
4470
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
4471
+
4472
+ const literals = [];
4473
+
4474
+ // Make literals inactive by replacing them with ??
4475
+ mask = mask.replace(literal, function($0, $1) {
4476
+ literals.push($1);
4477
+ return '@@@';
4478
+ });
4479
+ // Apply formatting rules
4480
+ mask = mask.replace(token, function ($0) {
4481
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4482
+ });
4483
+ // Inline literal values back into the formatted value
4484
+ return mask.replace(/@@@/g, function() {
4485
+ return literals.shift();
4486
+ });
4487
+ };
4488
+
4419
4489
  /**
4420
4490
  * Parse a date string into an object, changes - into /
4421
4491
  * @method parse
4422
4492
  * @param {string} dateStr Date string
4423
4493
  * @param {string} format Date parse format
4424
4494
  * @returns {Date|boolean}
4425
- */
4426
- fecha.parse = function (dateStr, format) {
4427
- if (typeof format !== 'string') {
4428
- throw new Error('Invalid format in fecha.parse');
4429
- }
4430
-
4431
- format = fecha.masks[format] || format;
4432
-
4433
- // Avoid regular expression denial of service, fail early for really long strings
4434
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4435
- if (dateStr.length > 1000) {
4436
- return null;
4437
- }
4438
-
4439
- var dateInfo = {};
4440
- var parseInfo = [];
4441
- var literals = [];
4442
- format = format.replace(literal, function ($0, $1) {
4443
- literals.push($1);
4444
- return '@@@';
4445
- });
4446
- var newFormat = regexEscape(format).replace(token, function ($0) {
4447
- if (parseFlags[$0]) {
4448
- var info = parseFlags[$0];
4449
- parseInfo.push(info[1]);
4450
- return '(' + info[0] + ')';
4451
- }
4452
-
4453
- return $0;
4454
- });
4455
- newFormat = newFormat.replace(/@@@/g, function () {
4456
- return literals.shift();
4457
- });
4458
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
4459
- if (!matches) {
4460
- return null;
4461
- }
4462
-
4463
- for (var i = 1; i < matches.length; i++) {
4464
- parseInfo[i - 1](dateInfo, matches[i]);
4465
- }
4466
-
4467
- var today = new Date();
4468
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4469
- dateInfo.hour = +dateInfo.hour + 12;
4470
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4471
- dateInfo.hour = 0;
4472
- }
4473
-
4474
- var date = void 0;
4475
- if (dateInfo.timezoneOffset != null) {
4476
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4477
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4478
- } else {
4479
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4480
- }
4481
- return date;
4482
- };
4483
-
4484
- // 导出fecha对象
4485
-
4486
-
4487
- // 以下是从date-util.js合并的函数
4488
- var newArray = function newArray(start, end) {
4489
- var result = [];
4490
- for (var i = start; i <= end; i++) {
4491
- result.push(i);
4492
- }
4493
- return result;
4494
- };
4495
-
4496
- var getSettings = function getSettings() {
4497
- return {
4498
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4499
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4500
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4501
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4502
- amPm: ['上午', '下午']
4503
- };
4504
- };
4505
-
4506
- var toDate = function toDate(date) {
4507
- return isDate(date) ? new Date(date) : null;
4508
- };
4509
-
4510
- var isDate = function isDate(date) {
4511
- if (date === null || date === undefined) return false;
4512
- if (isNaN(new Date(date).getTime())) return false;
4513
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4514
- return true;
4515
- };
4516
-
4517
- var isDateObject = function isDateObject(val) {
4518
- return val instanceof Date;
4519
- };
4520
-
4521
- var formatDate = function formatDate(date) {
4522
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
4523
-
4524
- // 处理多种输入类型
4525
- if (!date) return '';
4526
-
4527
- // 如果是时间戳,转成日期对象
4528
- if (typeof date === 'number') {
4529
- date = new Date(date);
4530
- }
4531
- // 如果是字符串,转成日期对象
4532
- if (typeof date === 'string') {
4533
- date = new Date(date);
4534
- }
4535
-
4536
- // 调用toDate进一步验证和转换
4537
- date = toDate(date);
4538
- if (!date) return '';
4539
-
4540
- // 兼容大写和小写的格式标记
4541
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4542
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
4543
-
4544
- // 使用fecha库进行格式化,支持中文配置
4545
- var str = fecha.format(date, lowercaseFormat, getSettings());
4546
- return str;
4547
- };
4548
-
4549
- var parseDate = function parseDate(string, format) {
4550
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4551
- };
4552
-
4553
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
4554
- if (month === 3 || month === 5 || month === 8 || month === 10) {
4555
- return 30;
4556
- }
4557
-
4558
- if (month === 1) {
4559
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4560
- return 29;
4561
- } else {
4562
- return 28;
4563
- }
4564
- }
4565
-
4566
- return 31;
4567
- };
4568
-
4569
- var getDayCountOfYear = function getDayCountOfYear(year) {
4570
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
4571
- return isLeapYear ? 366 : 365;
4572
- };
4573
-
4574
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
4575
- var temp = new Date(date.getTime());
4576
- temp.setDate(1);
4577
- return temp.getDay();
4578
- };
4579
-
4580
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4581
- // {prev, next} Date should work for Daylight Saving Time
4582
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4583
- var prevDate = function prevDate(date) {
4584
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4585
-
4586
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4587
- };
4588
-
4589
- var nextDate = function nextDate(date) {
4590
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4591
-
4592
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4593
- };
4594
-
4595
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
4596
- var result = new Date(year, month, 1);
4597
- var day = result.getDay();
4598
-
4599
- if (day === 0) {
4600
- return prevDate(result, 7);
4601
- } else {
4602
- return prevDate(result, day);
4603
- }
4604
- };
4605
-
4606
- var getWeekNumber = function getWeekNumber(date) {
4607
- // 支持多种输入类型
4608
- if (!date || !isDate(date)) {
4609
- date = new Date();
4610
- }
4611
- if (typeof date === 'string') {
4612
- date = new Date(date);
4613
- }
4614
-
4615
- // 验证日期有效性
4616
- if (!isDate(date)) return null;
4617
-
4618
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4619
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4620
- // 将星期日的星期数设为7
4621
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4622
- // 获取当年的第一天
4623
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4624
- // 计算到最近的星期四的完整周数
4625
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
4626
- // 返回周数
4627
- return weekNo;
4628
- };
4629
-
4630
- var getRangeHours = function getRangeHours(ranges) {
4631
- var hours = [];
4632
- var disabledHours = [];
4633
-
4634
- (ranges || []).forEach(function (range) {
4635
- var value = range.map(function (date) {
4636
- return date.getHours();
4637
- });
4638
-
4639
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4640
- });
4641
-
4642
- if (disabledHours.length) {
4643
- for (var i = 0; i < 24; i++) {
4644
- hours[i] = disabledHours.indexOf(i) === -1;
4645
- }
4646
- } else {
4647
- for (var _i = 0; _i < 24; _i++) {
4648
- hours[_i] = false;
4649
- }
4650
- }
4651
-
4652
- return hours;
4653
- };
4654
-
4655
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
4656
- if (amount <= 0) return [];
4657
- var temp = new Date(date.getTime());
4658
- temp.setDate(0);
4659
- var lastDay = temp.getDate();
4660
- return range(amount).map(function (_, index) {
4661
- return lastDay - (amount - index - 1);
4662
- });
4663
- };
4664
-
4665
- var getMonthDays = function getMonthDays(date) {
4666
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4667
- var days = temp.getDate();
4668
- return range(days).map(function (_, index) {
4669
- return index + 1;
4670
- });
4671
- };
4672
-
4673
- function setRangeData(arr, start, end, value) {
4674
- for (var i = start; i < end; i++) {
4675
- arr[i] = value;
4676
- }
4677
- }
4678
-
4679
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
4680
- var minutes = new Array(60);
4681
-
4682
- if (ranges.length > 0) {
4683
- ranges.forEach(function (range) {
4684
- var start = range[0];
4685
- var end = range[1];
4686
- var startHour = start.getHours();
4687
- var startMinute = start.getMinutes();
4688
- var endHour = end.getHours();
4689
- var endMinute = end.getMinutes();
4690
- if (startHour === hour && endHour !== hour) {
4691
- setRangeData(minutes, startMinute, 60, true);
4692
- } else if (startHour === hour && endHour === hour) {
4693
- setRangeData(minutes, startMinute, endMinute + 1, true);
4694
- } else if (startHour !== hour && endHour === hour) {
4695
- setRangeData(minutes, 0, endMinute + 1, true);
4696
- } else if (startHour < hour && endHour > hour) {
4697
- setRangeData(minutes, 0, 60, true);
4698
- }
4699
- });
4700
- } else {
4701
- setRangeData(minutes, 0, 60, true);
4702
- }
4703
- return minutes;
4704
- };
4705
-
4706
- var range = function range(n) {
4707
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4708
- return Array.apply(null, { length: n }).map(function (_, n) {
4709
- return n;
4710
- });
4711
- };
4712
-
4713
- var modifyDate = function modifyDate(date, y, m, d) {
4714
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4715
- };
4716
-
4717
- var modifyTime = function modifyTime(date, h, m, s) {
4718
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4719
- };
4720
-
4721
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
4722
- if (date == null || !time) {
4723
- return date;
4724
- }
4725
- time = parseDate(time, 'HH:mm:ss');
4726
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4727
- };
4728
-
4729
- var clearTime = function clearTime(date) {
4730
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4731
- };
4732
-
4733
- var clearMilliseconds = function clearMilliseconds(date) {
4734
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4735
- };
4736
-
4737
- var limitTimeRange = function limitTimeRange(date, ranges) {
4738
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
4739
-
4740
- // TODO: refactory a more elegant solution
4741
- if (ranges.length === 0) return date;
4742
- var normalizeDate = function normalizeDate(date) {
4743
- return fecha.parse(fecha.format(date, format), format);
4744
- };
4745
- var ndate = normalizeDate(date);
4746
- var nranges = ranges.map(function (range) {
4747
- return range.map(normalizeDate);
4748
- });
4749
- if (nranges.some(function (nrange) {
4750
- return ndate >= nrange[0] && ndate <= nrange[1];
4751
- })) return date;
4752
-
4753
- var minDate = nranges[0][0];
4754
- var maxDate = nranges[0][0];
4755
-
4756
- nranges.forEach(function (nrange) {
4757
- minDate = new Date(Math.min(nrange[0], minDate));
4758
- maxDate = new Date(Math.max(nrange[1], minDate));
4759
- });
4760
-
4761
- var ret = ndate < minDate ? minDate : maxDate;
4762
- // preserve Year/Month/Date
4763
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
4764
- };
4765
-
4766
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
4767
- var limitedDate = limitTimeRange(date, selectableRange, format);
4768
- return limitedDate.getTime() === date.getTime();
4769
- };
4770
-
4771
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
4772
- // clamp date to the number of days in `year`, `month`
4773
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
4774
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4775
- return modifyDate(date, year, month, monthDate);
4776
- };
4777
-
4778
- var prevMonth = function prevMonth(date) {
4779
- var year = date.getFullYear();
4780
- var month = date.getMonth();
4781
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
4782
- };
4783
-
4784
- var nextMonth = function nextMonth(date) {
4785
- var year = date.getFullYear();
4786
- var month = date.getMonth();
4787
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
4788
- };
4789
-
4790
- var prevYear = function prevYear(date) {
4791
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4792
-
4793
- var year = date.getFullYear();
4794
- var month = date.getMonth();
4795
- return changeYearMonthAndClampDate(date, year - amount, month);
4796
- };
4797
-
4798
- var nextYear = function nextYear(date) {
4799
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4800
-
4801
- var year = date.getFullYear();
4802
- var month = date.getMonth();
4803
- return changeYearMonthAndClampDate(date, year + amount, month);
4804
- };
4805
-
4806
- var extractDateFormat = function extractDateFormat(format) {
4807
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
4808
- };
4809
-
4810
- var extractTimeFormat = function extractTimeFormat(format) {
4811
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
4812
- };
4813
-
4814
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
4815
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
4816
- };
4817
-
4495
+ */
4496
+ fecha.parse = function (dateStr, format) {
4497
+ if (typeof format !== 'string') {
4498
+ throw new Error('Invalid format in fecha.parse');
4499
+ }
4500
+
4501
+ format = fecha.masks[format] || format;
4502
+
4503
+ // Avoid regular expression denial of service, fail early for really long strings
4504
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4505
+ if (dateStr.length > 1000) {
4506
+ return null;
4507
+ }
4508
+
4509
+ const dateInfo = {};
4510
+ const parseInfo = [];
4511
+ const literals = [];
4512
+ format = format.replace(literal, function($0, $1) {
4513
+ literals.push($1);
4514
+ return '@@@';
4515
+ });
4516
+ let newFormat = regexEscape(format).replace(token, function ($0) {
4517
+ if (parseFlags[$0]) {
4518
+ const info = parseFlags[$0];
4519
+ parseInfo.push(info[1]);
4520
+ return '(' + info[0] + ')';
4521
+ }
4522
+
4523
+ return $0;
4524
+ });
4525
+ newFormat = newFormat.replace(/@@@/g, function() {
4526
+ return literals.shift();
4527
+ });
4528
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
4529
+ if (!matches) {
4530
+ return null;
4531
+ }
4532
+
4533
+ for (let i = 1; i < matches.length; i++) {
4534
+ parseInfo[i - 1](dateInfo, matches[i]);
4535
+ }
4536
+
4537
+ const today = new Date();
4538
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4539
+ dateInfo.hour = +dateInfo.hour + 12;
4540
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4541
+ dateInfo.hour = 0;
4542
+ }
4543
+
4544
+ let date;
4545
+ if (dateInfo.timezoneOffset != null) {
4546
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4547
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4548
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4549
+ } else {
4550
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4551
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4552
+ }
4553
+ return date;
4554
+ };
4555
+
4556
+ // 导出fecha对象
4557
+
4558
+
4559
+ // 以下是从date-util.js合并的函数
4560
+ const newArray = function(start, end) {
4561
+ let result = [];
4562
+ for (let i = start; i <= end; i++) {
4563
+ result.push(i);
4564
+ }
4565
+ return result;
4566
+ };
4567
+
4568
+ const getSettings = () => {
4569
+ return {
4570
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4571
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4572
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4573
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4574
+ amPm: ['上午', '下午']
4575
+ };
4576
+ };
4577
+
4578
+ const toDate = function(date) {
4579
+ return isDate(date) ? new Date(date) : null;
4580
+ };
4581
+
4582
+ const isDate = function(date) {
4583
+ if (date === null || date === undefined) return false;
4584
+ if (isNaN(new Date(date).getTime())) return false;
4585
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4586
+ return true;
4587
+ };
4588
+
4589
+ const isDateObject = function(val) {
4590
+ return val instanceof Date;
4591
+ };
4592
+
4593
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
4594
+ // 处理多种输入类型
4595
+ if (!date) return '';
4596
+
4597
+ // 如果是时间戳,转成日期对象
4598
+ if (typeof date === 'number') {
4599
+ date = new Date(date);
4600
+ }
4601
+ // 如果是字符串,转成日期对象
4602
+ if (typeof date === 'string') {
4603
+ date = new Date(date);
4604
+ }
4605
+
4606
+ // 调用toDate进一步验证和转换
4607
+ date = toDate(date);
4608
+ if (!date) return '';
4609
+
4610
+ // 兼容大写和小写的格式标记
4611
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4612
+ const lowercaseFormat = format
4613
+ .replace(/YYYY/g, 'yyyy')
4614
+ .replace(/D/g, 'd')
4615
+
4616
+ // 使用fecha库进行格式化,支持中文配置
4617
+ const str = fecha.format(date, lowercaseFormat, getSettings());
4618
+ return str;
4619
+ };
4620
+
4621
+ const parseDate = function(string, format) {
4622
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4623
+ };
4624
+
4625
+ const getDayCountOfMonth = function(year, month) {
4626
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
4627
+ return 30;
4628
+ }
4629
+
4630
+ if (month === 1) {
4631
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4632
+ return 29;
4633
+ } else {
4634
+ return 28;
4635
+ }
4636
+ }
4637
+
4638
+ return 31;
4639
+ };
4640
+
4641
+ const getDayCountOfYear = function(year) {
4642
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
4643
+ return isLeapYear ? 366 : 365;
4644
+ };
4645
+
4646
+ const getFirstDayOfMonth = function(date) {
4647
+ const temp = new Date(date.getTime());
4648
+ temp.setDate(1);
4649
+ return temp.getDay();
4650
+ };
4651
+
4652
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4653
+ // {prev, next} Date should work for Daylight Saving Time
4654
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4655
+ const prevDate = function(date, amount = 1) {
4656
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4657
+ };
4658
+
4659
+ const nextDate = function(date, amount = 1) {
4660
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4661
+ };
4662
+
4663
+ const getStartDateOfMonth = function(year, month) {
4664
+ const result = new Date(year, month, 1);
4665
+ const day = result.getDay();
4666
+
4667
+ if (day === 0) {
4668
+ return prevDate(result, 7);
4669
+ } else {
4670
+ return prevDate(result, day);
4671
+ }
4672
+ };
4673
+
4674
+ const getWeekNumber = function(date) {
4675
+ // 支持多种输入类型
4676
+ if (!date||!isDate(date)) {
4677
+ date = new Date();
4678
+ }
4679
+ if (typeof date === 'string') {
4680
+ date = new Date(date);
4681
+ }
4682
+
4683
+ // 验证日期有效性
4684
+ if (!isDate(date)) return null;
4685
+
4686
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4687
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4688
+ // 将星期日的星期数设为7
4689
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4690
+ // 获取当年的第一天
4691
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4692
+ // 计算到最近的星期四的完整周数
4693
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
4694
+ // 返回周数
4695
+ return weekNo;
4696
+ };
4697
+
4698
+ const getRangeHours = function(ranges) {
4699
+ const hours = [];
4700
+ let disabledHours = [];
4701
+
4702
+ (ranges || []).forEach(range => {
4703
+ const value = range.map(date => date.getHours());
4704
+
4705
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4706
+ });
4707
+
4708
+ if (disabledHours.length) {
4709
+ for (let i = 0; i < 24; i++) {
4710
+ hours[i] = disabledHours.indexOf(i) === -1;
4711
+ }
4712
+ } else {
4713
+ for (let i = 0; i < 24; i++) {
4714
+ hours[i] = false;
4715
+ }
4716
+ }
4717
+
4718
+ return hours;
4719
+ };
4720
+
4721
+ const getPrevMonthLastDays = (date, amount) => {
4722
+ if (amount <= 0) return [];
4723
+ const temp = new Date(date.getTime());
4724
+ temp.setDate(0);
4725
+ const lastDay = temp.getDate();
4726
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
4727
+ };
4728
+
4729
+ const getMonthDays = (date) => {
4730
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4731
+ const days = temp.getDate();
4732
+ return range(days).map((_, index) => index + 1);
4733
+ };
4734
+
4735
+ function setRangeData(arr, start, end, value) {
4736
+ for (let i = start; i < end; i++) {
4737
+ arr[i] = value;
4738
+ }
4739
+ }
4740
+
4741
+ const getRangeMinutes = function(ranges, hour) {
4742
+ const minutes = new Array(60);
4743
+
4744
+ if (ranges.length > 0) {
4745
+ ranges.forEach(range => {
4746
+ const start = range[0];
4747
+ const end = range[1];
4748
+ const startHour = start.getHours();
4749
+ const startMinute = start.getMinutes();
4750
+ const endHour = end.getHours();
4751
+ const endMinute = end.getMinutes();
4752
+ if (startHour === hour && endHour !== hour) {
4753
+ setRangeData(minutes, startMinute, 60, true);
4754
+ } else if (startHour === hour && endHour === hour) {
4755
+ setRangeData(minutes, startMinute, endMinute + 1, true);
4756
+ } else if (startHour !== hour && endHour === hour) {
4757
+ setRangeData(minutes, 0, endMinute + 1, true);
4758
+ } else if (startHour < hour && endHour > hour) {
4759
+ setRangeData(minutes, 0, 60, true);
4760
+ }
4761
+ });
4762
+ } else {
4763
+ setRangeData(minutes, 0, 60, true);
4764
+ }
4765
+ return minutes;
4766
+ };
4767
+
4768
+ const range = function(n) {
4769
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4770
+ return Array.apply(null, {length: n}).map((_, n) => n);
4771
+ };
4772
+
4773
+ const modifyDate = function(date, y, m, d) {
4774
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4775
+ };
4776
+
4777
+ const modifyTime = function(date, h, m, s) {
4778
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4779
+ };
4780
+
4781
+ const modifyWithTimeString = (date, time) => {
4782
+ if (date == null || !time) {
4783
+ return date;
4784
+ }
4785
+ time = parseDate(time, 'HH:mm:ss');
4786
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4787
+ };
4788
+
4789
+ const clearTime = function(date) {
4790
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4791
+ };
4792
+
4793
+ const clearMilliseconds = function(date) {
4794
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4795
+ };
4796
+
4797
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
4798
+ // TODO: refactory a more elegant solution
4799
+ if (ranges.length === 0) return date;
4800
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
4801
+ const ndate = normalizeDate(date);
4802
+ const nranges = ranges.map(range => range.map(normalizeDate));
4803
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
4804
+
4805
+ let minDate = nranges[0][0];
4806
+ let maxDate = nranges[0][0];
4807
+
4808
+ nranges.forEach(nrange => {
4809
+ minDate = new Date(Math.min(nrange[0], minDate));
4810
+ maxDate = new Date(Math.max(nrange[1], minDate));
4811
+ });
4812
+
4813
+ const ret = ndate < minDate ? minDate : maxDate;
4814
+ // preserve Year/Month/Date
4815
+ return modifyDate(
4816
+ ret,
4817
+ date.getFullYear(),
4818
+ date.getMonth(),
4819
+ date.getDate()
4820
+ );
4821
+ };
4822
+
4823
+ const timeWithinRange = function(date, selectableRange, format) {
4824
+ const limitedDate = limitTimeRange(date, selectableRange, format);
4825
+ return limitedDate.getTime() === date.getTime();
4826
+ };
4827
+
4828
+ const changeYearMonthAndClampDate = function(date, year, month) {
4829
+ // clamp date to the number of days in `year`, `month`
4830
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
4831
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4832
+ return modifyDate(date, year, month, monthDate);
4833
+ };
4834
+
4835
+ const prevMonth = function(date) {
4836
+ const year = date.getFullYear();
4837
+ const month = date.getMonth();
4838
+ return month === 0
4839
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
4840
+ : changeYearMonthAndClampDate(date, year, month - 1);
4841
+ };
4842
+
4843
+ const nextMonth = function(date) {
4844
+ const year = date.getFullYear();
4845
+ const month = date.getMonth();
4846
+ return month === 11
4847
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
4848
+ : changeYearMonthAndClampDate(date, year, month + 1);
4849
+ };
4850
+
4851
+ const prevYear = function(date, amount = 1) {
4852
+ const year = date.getFullYear();
4853
+ const month = date.getMonth();
4854
+ return changeYearMonthAndClampDate(date, year - amount, month);
4855
+ };
4856
+
4857
+ const nextYear = function(date, amount = 1) {
4858
+ const year = date.getFullYear();
4859
+ const month = date.getMonth();
4860
+ return changeYearMonthAndClampDate(date, year + amount, month);
4861
+ };
4862
+
4863
+ const extractDateFormat = function(format) {
4864
+ return format
4865
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
4866
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
4867
+ .trim();
4868
+ };
4869
+
4870
+ const extractTimeFormat = function(format) {
4871
+ return format
4872
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
4873
+ .trim();
4874
+ };
4875
+
4876
+ const validateRangeInOneMonth = function(start, end) {
4877
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
4878
+ };
4879
+
4818
4880
  /**
4819
4881
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
4820
4882
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
4821
4883
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
4822
4884
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
4823
4885
  * @returns {number} 工作日数量
4824
- */
4825
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
4826
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
4827
-
4828
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
4829
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
4830
- }
4831
-
4832
- var startDateObj = new Date(start_date);
4833
- var endDateObj = new Date(end_date);
4834
-
4835
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
4836
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
4837
- }
4838
-
4839
- if (startDateObj > endDateObj) {
4840
- throw new Error('Start date should be earlier than or equal to end date.');
4841
- }
4842
-
4843
- var workdays = 0;
4844
-
4845
- // Iterate through each day in the date range
4846
-
4847
- var _loop = function _loop(currentDate) {
4848
- // Check if the current day is a weekend (Saturday or Sunday)
4849
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
4850
-
4851
- // Check if the current day is a holiday
4852
- var isHoliday = holidays.some(function (holiday) {
4853
- var holidayDate = new Date(holiday);
4854
- return currentDate.toDateString() === holidayDate.toDateString();
4855
- });
4856
-
4857
- // If it's a workday (not a weekend or holiday), increment the workdays count
4858
- if (!isWeekend && !isHoliday) {
4859
- workdays++;
4860
- }
4861
- };
4862
-
4863
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
4864
- _loop(currentDate);
4865
- }
4866
-
4867
- return workdays;
4868
- };
4869
-
4886
+ */
4887
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
4888
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
4889
+ throw new Error(
4890
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
4891
+ );
4892
+ }
4893
+
4894
+ const startDateObj = new Date(start_date);
4895
+ const endDateObj = new Date(end_date);
4896
+
4897
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
4898
+ throw new Error(
4899
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
4900
+ );
4901
+ }
4902
+
4903
+ if (startDateObj > endDateObj) {
4904
+ throw new Error('Start date should be earlier than or equal to end date.');
4905
+ }
4906
+
4907
+ let workdays = 0;
4908
+
4909
+ // Iterate through each day in the date range
4910
+ for (
4911
+ let currentDate = new Date(startDateObj);
4912
+ currentDate <= endDateObj;
4913
+ currentDate.setDate(currentDate.getDate() + 1)
4914
+ ) {
4915
+ // Check if the current day is a weekend (Saturday or Sunday)
4916
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
4917
+
4918
+ // Check if the current day is a holiday
4919
+ const isHoliday = holidays.some((holiday) => {
4920
+ const holidayDate = new Date(holiday);
4921
+ return currentDate.toDateString() === holidayDate.toDateString();
4922
+ });
4923
+
4924
+ // If it's a workday (not a weekend or holiday), increment the workdays count
4925
+ if (!isWeekend && !isHoliday) {
4926
+ workdays++;
4927
+ }
4928
+ }
4929
+
4930
+ return workdays;
4931
+ };
4932
+
4870
4933
  /**
4871
4934
  * 日期加减天数
4872
4935
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
4873
4936
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
4874
4937
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
4875
- */
4876
- var dateAddDays = function dateAddDays(start_date, days) {
4877
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
4878
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days.");
4879
- }
4880
-
4881
- var startDateObj = new Date(start_date);
4882
- if (isNaN(startDateObj.getTime())) {
4883
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4884
- }
4885
-
4886
- var resultDateObj = new Date(startDateObj);
4887
- resultDateObj.setDate(resultDateObj.getDate() + days);
4888
-
4889
- var resultYear = resultDateObj.getFullYear();
4890
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
4891
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
4892
-
4893
- return resultYear + '-' + resultMonth + '-' + resultDay;
4894
- };
4895
-
4938
+ */
4939
+ const dateAddDays = function (start_date, days) {
4940
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
4941
+ throw new Error(
4942
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
4943
+ );
4944
+ }
4945
+
4946
+ const startDateObj = new Date(start_date);
4947
+ if (isNaN(startDateObj.getTime())) {
4948
+ throw new Error(
4949
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
4950
+ );
4951
+ }
4952
+
4953
+ const resultDateObj = new Date(startDateObj);
4954
+ resultDateObj.setDate(resultDateObj.getDate() + days);
4955
+
4956
+ const resultYear = resultDateObj.getFullYear();
4957
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
4958
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
4959
+
4960
+ return `${resultYear}-${resultMonth}-${resultDay}`;
4961
+ };
4962
+
4896
4963
  /**
4897
4964
  * 计算两个日期之间的差值
4898
4965
  * @date 2023年12月14日
@@ -4900,180 +4967,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
4900
4967
  * @param {String} end_date - 结束日期字符串
4901
4968
  * @param {String} unit - 单位:year/month/day
4902
4969
  * @returns {Number} 差值
4903
- */
4904
- var dateDiff = function dateDiff(start_date, end_date) {
4905
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
4906
-
4907
- // Assuming date strings are in "YYYY-MM-DD" format
4908
- var startDate = new Date(start_date);
4909
- var endDate = new Date(end_date);
4910
-
4911
- // If the date is invalid, return 0
4912
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
4913
- return 0;
4914
- }
4915
-
4916
- if (unit === 'year') {
4917
- return endDate.getFullYear() - startDate.getFullYear();
4918
- } else if (unit === 'month') {
4919
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
4920
- } else {
4921
- // Default to day
4922
- var timeDifference = endDate - startDate;
4923
- // Calculate days (86400000 milliseconds per day)
4924
- return Math.floor(timeDifference / 86400000);
4925
- }
4926
- };
4927
-
4970
+ */
4971
+ const dateDiff = function (start_date, end_date, unit = 'day') {
4972
+ // Assuming date strings are in "YYYY-MM-DD" format
4973
+ var startDate = new Date(start_date);
4974
+ var endDate = new Date(end_date);
4975
+
4976
+ // If the date is invalid, return 0
4977
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
4978
+ return 0;
4979
+ }
4980
+
4981
+ if (unit === 'year') {
4982
+ return endDate.getFullYear() - startDate.getFullYear();
4983
+ } else if (unit === 'month') {
4984
+ return (
4985
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
4986
+ (endDate.getMonth() - startDate.getMonth())
4987
+ );
4988
+ } else {
4989
+ // Default to day
4990
+ var timeDifference = endDate - startDate;
4991
+ // Calculate days (86400000 milliseconds per day)
4992
+ return Math.floor(timeDifference / 86400000);
4993
+ }
4994
+ };
4995
+
4928
4996
  /**
4929
4997
  * 获取月份中的日期
4930
4998
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
4931
4999
  * @returns {number} 月份中的日期(1-31)
4932
- */
4933
- var dayOfMonth = function dayOfMonth(date) {
4934
- if (typeof date !== 'string') {
4935
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4936
- }
4937
-
4938
- var dateObj = new Date(date);
4939
- if (isNaN(dateObj.getTime())) {
4940
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4941
- }
4942
-
4943
- return dateObj.getDate();
4944
- };
4945
-
5000
+ */
5001
+ const dayOfMonth = function (date) {
5002
+ if (typeof date !== 'string') {
5003
+ throw new Error(
5004
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5005
+ );
5006
+ }
5007
+
5008
+ const dateObj = new Date(date);
5009
+ if (isNaN(dateObj.getTime())) {
5010
+ throw new Error(
5011
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5012
+ );
5013
+ }
5014
+
5015
+ return dateObj.getDate();
5016
+ };
5017
+
4946
5018
  /**
4947
5019
  * 获取当前日期
4948
5020
  * @date 2022年5月7日
4949
5021
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
4950
5022
  * @returns {string} 当前日期的格式化字符串
4951
- */
4952
- var getCurrentDate = function getCurrentDate() {
4953
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
4954
-
4955
- return formatDate(new Date(), format);
4956
- };
4957
-
5023
+ */
5024
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
5025
+ return formatDate(new Date(), format);
5026
+ };
5027
+
4958
5028
  /**
4959
5029
  * 获取当前日期时间
4960
5030
  * @date 2022年5月7日
4961
5031
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
4962
5032
  * @returns {string} 当前日期时间的格式化字符串
4963
- */
4964
- var getCurrentDateTime = function getCurrentDateTime() {
4965
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
4966
-
4967
- return formatDate(new Date(), format);
4968
- };
4969
-
5033
+ */
5034
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5035
+ return formatDate(new Date(), format);
5036
+ };
5037
+
4970
5038
  /**
4971
5039
  * 获取小时
4972
5040
  * @date 2022年5月7日
4973
5041
  * @param {Date|string} [date] - 日期对象或日期字符串
4974
5042
  * @returns {number} 小时数(0-23)
4975
- */
4976
- var getHour = function getHour(date) {
4977
- if (!date) {
4978
- return new Date().getHours();
4979
- }
4980
- if (typeof date === 'string') {
4981
- date = new Date(date);
4982
- }
4983
- return date.getHours();
4984
- };
4985
-
5043
+ */
5044
+ const getHour = function (date) {
5045
+ if (!date) {
5046
+ return new Date().getHours();
5047
+ }
5048
+ if (typeof date === 'string') {
5049
+ date = new Date(date);
5050
+ }
5051
+ return date.getHours();
5052
+ };
5053
+
4986
5054
  /**
4987
5055
  * 获取分钟
4988
5056
  * @date 2022年5月7日
4989
5057
  * @param {Date|string} [date] - 日期对象或日期字符串
4990
5058
  * @returns {number} 分钟数(0-59)
4991
- */
4992
- var getMinute = function getMinute(date) {
4993
- if (!date) {
4994
- return new Date().getMinutes();
4995
- }
4996
- if (typeof date === 'string') {
4997
- date = new Date(date);
4998
- }
4999
- return date.getMinutes();
5000
- };
5001
-
5059
+ */
5060
+ const getMinute = function (date) {
5061
+ if (!date) {
5062
+ return new Date().getMinutes();
5063
+ }
5064
+ if (typeof date === 'string') {
5065
+ date = new Date(date);
5066
+ }
5067
+ return date.getMinutes();
5068
+ };
5069
+
5002
5070
  /**
5003
5071
  * 获取月份
5004
5072
  * @date 2022年5月7日
5005
5073
  * @param {Date|string} [date] - 日期对象或日期字符串
5006
5074
  * @returns {number} 月份数(1-12)
5007
- */
5008
- var getMonth = function getMonth(date) {
5009
- if (!date) {
5010
- return new Date().getMonth() + 1;
5011
- }
5012
- if (typeof date === 'string') {
5013
- date = new Date(date);
5014
- }
5015
- return date.getMonth() + 1;
5016
- };
5017
-
5075
+ */
5076
+ const getMonth = function (date) {
5077
+ if (!date) {
5078
+ return new Date().getMonth() + 1;
5079
+ }
5080
+ if (typeof date === 'string') {
5081
+ date = new Date(date);
5082
+ }
5083
+ return date.getMonth() + 1;
5084
+ };
5085
+
5018
5086
  /**
5019
5087
  * 获取秒
5020
5088
  * @date 2022年5月7日
5021
5089
  * @param {Date|string} [date] - 日期对象或日期字符串
5022
5090
  * @returns {number} 秒数(0-59)
5023
- */
5024
- var getSecond = function getSecond(date) {
5025
- if (!date) {
5026
- return new Date().getSeconds();
5027
- }
5028
- if (typeof date === 'string') {
5029
- date = new Date(date);
5030
- }
5031
- return date.getSeconds();
5032
- };
5033
-
5091
+ */
5092
+ const getSecond = function (date) {
5093
+ if (!date) {
5094
+ return new Date().getSeconds();
5095
+ }
5096
+ if (typeof date === 'string') {
5097
+ date = new Date(date);
5098
+ }
5099
+ return date.getSeconds();
5100
+ };
5101
+
5034
5102
  /**
5035
5103
  * 获取星期几
5036
5104
  * @date 2022年5月7日
5037
5105
  * @param {Date|string} [date] - 日期对象或日期字符串
5038
5106
  * @returns {number} 星期几(0-6,0表示星期日)
5039
- */
5040
- var getWeekday = function getWeekday(date) {
5041
- if (!date) {
5042
- return new Date().getDay();
5043
- }
5044
- if (typeof date === 'string') {
5045
- date = new Date(date);
5046
- }
5047
- return date.getDay();
5048
- };
5049
-
5107
+ */
5108
+ const getWeekday = function (date) {
5109
+ if (!date) {
5110
+ return new Date().getDay();
5111
+ }
5112
+ if (typeof date === 'string') {
5113
+ date = new Date(date);
5114
+ }
5115
+ return date.getDay();
5116
+ };
5117
+
5118
+
5050
5119
  /**
5051
5120
  * @desc 获取上午/下午/晚上
5052
5121
  * @author huangbo
5053
5122
  * @date 2022年5月7日
5054
5123
  * @param {String} [time] - 时间
5055
- **/
5056
- var timeCycle = function timeCycle(time) {
5057
- var hour = 0;
5058
- if (!time) {
5059
- hour = new Date().getHours();
5060
- } else if (typeof time === 'string') {
5061
- // 从时间字符串中提取小时
5062
- var match = time.match(/^(\d{1,2})/);
5063
- if (match) {
5064
- hour = parseInt(match[1], 10);
5065
- }
5066
- } else if (typeof time === 'number') {
5067
- hour = time;
5068
- }
5069
- // 判断时间段
5070
- if (hour >= 5 && hour < 12) {
5071
- return '上午';
5072
- } else if (hour >= 12 && hour < 18) {
5073
- return '下午';
5074
- } else {
5075
- return '晚上';
5076
- }
5124
+ **/
5125
+ const timeCycle = function (time) {
5126
+ let hour = 0;
5127
+ if (!time) {
5128
+ hour = new Date().getHours();
5129
+ } else if (typeof time === 'string') {
5130
+ // 从时间字符串中提取小时
5131
+ const match = time.match(/^(\d{1,2})/);
5132
+ if (match) {
5133
+ hour = parseInt(match[1], 10);
5134
+ }
5135
+ } else if (typeof time === 'number') {
5136
+ hour = time;
5137
+ }
5138
+ // 判断时间段
5139
+ if (hour >= 5 && hour < 12) {
5140
+ return '上午';
5141
+ } else if (hour >= 12 && hour < 18) {
5142
+ return '下午';
5143
+ } else {
5144
+ return '晚上';
5145
+ }
5077
5146
  };
5078
5147
 
5079
5148
  /***/ }),