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/tabs.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 = 208);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 212);
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,10 +3046,290 @@ 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
- /***/ 12:
3094
+ /***/ 1:
3095
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3096
+
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
+ };
3329
+
3330
+ /***/ }),
3331
+
3332
+ /***/ 12:
3289
3333
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3290
3334
 
3291
3335
  "use strict";
@@ -3297,7 +3341,7 @@ var warning = function warning(content, _callback3) {
3297
3341
  /* unused harmony export hsvTorgb */
3298
3342
  /* unused harmony export mixColor */
3299
3343
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getRgb; });
3300
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
3344
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
3301
3345
 
3302
3346
  var $hueStep = 2;
3303
3347
  var $saturationStep1 = 0.16;
@@ -3348,7 +3392,7 @@ var getColor = function getColor($color, $n) {
3348
3392
  var getLightness = function getLightness($v, $i, $isLight) {
3349
3393
  var $value = $isLight ? $v + $brightnessStep1 * $i : $v - $brightnessStep2 * $i;
3350
3394
  $value = $value < 1 ? $value : 1;
3351
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($value, 2);
3395
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($value, 2);
3352
3396
  };
3353
3397
 
3354
3398
  /**
@@ -3372,7 +3416,7 @@ var getSaturation = function getSaturation($s, $i, $isLight) {
3372
3416
  $saturation = 0.1;
3373
3417
  }
3374
3418
  $saturation = $saturation > 0.06 ? $saturation : 0.06;
3375
- return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "T"])($saturation, 2);
3419
+ return Object(_util__WEBPACK_IMPORTED_MODULE_0__[/* toFixed */ "W"])($saturation, 2);
3376
3420
  };
3377
3421
 
3378
3422
  /**
@@ -3486,7 +3530,7 @@ var getRgb = function getRgb($color) {
3486
3530
 
3487
3531
  /***/ }),
3488
3532
 
3489
- /***/ 122:
3533
+ /***/ 124:
3490
3534
  /***/ (function(module, exports) {
3491
3535
 
3492
3536
  module.exports = require("babel-helper-vue-jsx-merge-props");
@@ -3528,7 +3572,7 @@ module.exports = require("vue");
3528
3572
 
3529
3573
  /***/ }),
3530
3574
 
3531
- /***/ 208:
3575
+ /***/ 212:
3532
3576
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3533
3577
 
3534
3578
  "use strict";
@@ -3536,7 +3580,7 @@ module.exports = require("vue");
3536
3580
  __webpack_require__.r(__webpack_exports__);
3537
3581
 
3538
3582
  // EXTERNAL MODULE: external "babel-helper-vue-jsx-merge-props"
3539
- var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(122);
3583
+ var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(124);
3540
3584
  var external_babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(external_babel_helper_vue_jsx_merge_props_);
3541
3585
 
3542
3586
  // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/tabs/src/tab-bar.vue?vue&type=template&id=61310203&
@@ -3557,7 +3601,7 @@ tab_barvue_type_template_id_61310203_render._withStripped = true
3557
3601
  // CONCATENATED MODULE: ./packages/tabs/src/tab-bar.vue?vue&type=template&id=61310203&
3558
3602
 
3559
3603
  // EXTERNAL MODULE: ./src/utils/util.js
3560
- var util = __webpack_require__(1);
3604
+ var util = __webpack_require__(0);
3561
3605
 
3562
3606
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tabs/src/tab-bar.vue?vue&type=script&lang=js&
3563
3607
  //
@@ -3740,7 +3784,7 @@ var component = Object(componentNormalizer["a" /* default */])(
3740
3784
 
3741
3785
  /* harmony default export */ var tab_bar = (component.exports);
3742
3786
  // EXTERNAL MODULE: ./src/utils/resize-event.js
3743
- var resize_event = __webpack_require__(38);
3787
+ var resize_event = __webpack_require__(39);
3744
3788
 
3745
3789
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tabs/src/tab-nav.vue?vue&type=script&lang=js&
3746
3790
  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; };
@@ -4838,7 +4882,7 @@ function isDefined(val) {
4838
4882
 
4839
4883
  /***/ }),
4840
4884
 
4841
- /***/ 38:
4885
+ /***/ 39:
4842
4886
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4843
4887
 
4844
4888
  "use strict";
@@ -5206,736 +5250,759 @@ function normalizeComponent(
5206
5250
  /* unused harmony export getSecond */
5207
5251
  /* unused harmony export getWeekday */
5208
5252
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
5209
-
5210
-
5253
+ /* Modified from https://github.com/taylorhakes/fecha
5254
+ *
5255
+ * The MIT License (MIT)
5256
+ *
5257
+ * Copyright (c) 2015 Taylor Hakes
5258
+ *
5259
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5260
+ * of this software and associated documentation files (the "Software"), to deal
5261
+ * in the Software without restriction, including without limitation the rights
5262
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5263
+ * copies of the Software, and to permit persons to whom the Software is
5264
+ * furnished to do so, subject to the following conditions:
5265
+ *
5266
+ * The above copyright notice and this permission notice shall be included in all
5267
+ * copies or substantial portions of the Software.
5268
+ *
5269
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5270
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5271
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5272
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5273
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5274
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5275
+ * SOFTWARE.
5276
+ */
5277
+
5278
+ /*eslint-disable*/
5279
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5280
+
5281
+
5211
5282
  /**
5212
5283
  * Parse or format dates
5213
5284
  * @class fecha
5214
- */
5215
- var fecha = {};
5216
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5217
- var twoDigits = '\\d\\d?';
5218
- var threeDigits = '\\d{3}';
5219
- var fourDigits = '\\d{4}';
5220
- var word = '[^\\s]+';
5221
- var literal = /\[([^]*?)\]/gm;
5222
- var noop = function noop() {};
5223
-
5224
- function regexEscape(str) {
5225
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5226
- }
5227
-
5228
- function shorten(arr, sLen) {
5229
- var newArr = [];
5230
- for (var i = 0, len = arr.length; i < len; i++) {
5231
- newArr.push(arr[i].substr(0, sLen));
5232
- }
5233
- return newArr;
5234
- }
5235
-
5236
- function monthUpdate() {
5237
- return function (d, v) {
5238
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5239
- if (~index) {
5240
- d.month = index;
5241
- }
5242
- };
5243
- }
5244
-
5245
- function pad(val, len) {
5246
- val = String(val);
5247
- len = len || 2;
5248
- while (val.length < len) {
5249
- val = '0' + val;
5250
- }
5251
- return val;
5252
- }
5253
-
5254
- // 直接使用中文日期名称常量
5255
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5256
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5257
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5258
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5259
- var amPm = ['上午', '下午'];
5260
- var DoFn = function DoFn(D) {
5261
- return D + '日';
5262
- };
5263
-
5264
- var formatFlags = {
5265
- D: function D(dateObj) {
5266
- return dateObj.getDay();
5267
- },
5268
- DD: function DD(dateObj) {
5269
- return pad(dateObj.getDay());
5270
- },
5271
- Do: function Do(dateObj) {
5272
- return DoFn(dateObj.getDate());
5273
- },
5274
- d: function d(dateObj) {
5275
- return dateObj.getDate();
5276
- },
5277
- dd: function dd(dateObj) {
5278
- return pad(dateObj.getDate());
5279
- },
5280
- ddd: function ddd(dateObj) {
5281
- return dayNamesShort[dateObj.getDay()];
5282
- },
5283
- dddd: function dddd(dateObj) {
5284
- return dayNames[dateObj.getDay()];
5285
- },
5286
- M: function M(dateObj) {
5287
- return dateObj.getMonth() + 1;
5288
- },
5289
- MM: function MM(dateObj) {
5290
- return pad(dateObj.getMonth() + 1);
5291
- },
5292
- MMM: function MMM(dateObj) {
5293
- return monthNamesShort[dateObj.getMonth()];
5294
- },
5295
- MMMM: function MMMM(dateObj) {
5296
- return monthNames[dateObj.getMonth()];
5297
- },
5298
- yy: function yy(dateObj) {
5299
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5300
- },
5301
- yyyy: function yyyy(dateObj) {
5302
- return pad(dateObj.getFullYear(), 4);
5303
- },
5304
- h: function h(dateObj) {
5305
- return dateObj.getHours() % 12 || 12;
5306
- },
5307
- hh: function hh(dateObj) {
5308
- return pad(dateObj.getHours() % 12 || 12);
5309
- },
5310
- H: function H(dateObj) {
5311
- return dateObj.getHours();
5312
- },
5313
- HH: function HH(dateObj) {
5314
- return pad(dateObj.getHours());
5315
- },
5316
- m: function m(dateObj) {
5317
- return dateObj.getMinutes();
5318
- },
5319
- mm: function mm(dateObj) {
5320
- return pad(dateObj.getMinutes());
5321
- },
5322
- s: function s(dateObj) {
5323
- return dateObj.getSeconds();
5324
- },
5325
- ss: function ss(dateObj) {
5326
- return pad(dateObj.getSeconds());
5327
- },
5328
- S: function S(dateObj) {
5329
- return Math.round(dateObj.getMilliseconds() / 100);
5330
- },
5331
- SS: function SS(dateObj) {
5332
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5333
- },
5334
- SSS: function SSS(dateObj) {
5335
- return pad(dateObj.getMilliseconds(), 3);
5336
- },
5337
- a: function a(dateObj) {
5338
- return dateObj.getHours() < 12 ? '上午' : '下午';
5339
- },
5340
- A: function A(dateObj) {
5341
- return dateObj.getHours() < 12 ? '上午' : '下午';
5342
- },
5343
- ZZ: function ZZ(dateObj) {
5344
- var o = dateObj.getTimezoneOffset();
5345
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5346
- }
5347
- };
5348
-
5349
- var parseFlags = {
5350
- d: [twoDigits, function (d, v) {
5351
- d.day = v;
5352
- }],
5353
- Do: [twoDigits + word, function (d, v) {
5354
- d.day = parseInt(v, 10);
5355
- }],
5356
- M: [twoDigits, function (d, v) {
5357
- d.month = v - 1;
5358
- }],
5359
- yy: [twoDigits, function (d, v) {
5360
- var da = new Date(),
5361
- cent = +('' + da.getFullYear()).substr(0, 2);
5362
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5363
- }],
5364
- h: [twoDigits, function (d, v) {
5365
- d.hour = v;
5366
- }],
5367
- m: [twoDigits, function (d, v) {
5368
- d.minute = v;
5369
- }],
5370
- s: [twoDigits, function (d, v) {
5371
- d.second = v;
5372
- }],
5373
- yyyy: [fourDigits, function (d, v) {
5374
- d.year = v;
5375
- }],
5376
- S: ['\\d', function (d, v) {
5377
- d.millisecond = v * 100;
5378
- }],
5379
- SS: ['\\d{2}', function (d, v) {
5380
- d.millisecond = v * 10;
5381
- }],
5382
- SSS: [threeDigits, function (d, v) {
5383
- d.millisecond = v;
5384
- }],
5385
- D: [twoDigits, noop],
5386
- ddd: [word, noop],
5387
- MMM: [word, monthUpdate('monthNamesShort')],
5388
- MMMM: [word, monthUpdate('monthNames')],
5389
- a: [word, function (d, v) {
5390
- var val = v.toLowerCase();
5391
- if (val === '上午') {
5392
- d.isPm = false;
5393
- } else if (val === '下午') {
5394
- d.isPm = true;
5395
- }
5396
- }],
5397
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5398
- var parts = (v + '').match(/([+-]|\d\d)/gi),
5399
- minutes = void 0;
5400
-
5401
- if (parts) {
5402
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5403
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5404
- }
5405
- }]
5406
- };
5407
- parseFlags.dd = parseFlags.d;
5408
- parseFlags.dddd = parseFlags.ddd;
5409
- parseFlags.DD = parseFlags.D;
5410
- parseFlags.mm = parseFlags.m;
5411
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5412
- parseFlags.MM = parseFlags.M;
5413
- parseFlags.ss = parseFlags.s;
5414
- parseFlags.A = parseFlags.a;
5415
-
5416
- // Some common format strings
5417
- fecha.masks = {
5418
- default: 'ddd MMM dd yyyy HH:mm:ss',
5419
- shortDate: 'M/D/yy',
5420
- mediumDate: 'MMM d, yyyy',
5421
- longDate: 'MMMM d, yyyy',
5422
- fullDate: 'dddd, MMMM d, yyyy',
5423
- shortTime: 'HH:mm',
5424
- mediumTime: 'HH:mm:ss',
5425
- longTime: 'HH:mm:ss.SSS'
5426
- };
5427
-
5285
+ */
5286
+ const fecha = {};
5287
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5288
+ const twoDigits = '\\d\\d?';
5289
+ const threeDigits = '\\d{3}';
5290
+ const fourDigits = '\\d{4}';
5291
+ const word = '[^\\s]+';
5292
+ const literal = /\[([^]*?)\]/gm;
5293
+ const noop = function () {};
5294
+
5295
+ function regexEscape(str) {
5296
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5297
+ }
5298
+
5299
+ function shorten(arr, sLen) {
5300
+ const newArr = [];
5301
+ for (let i = 0, len = arr.length; i < len; i++) {
5302
+ newArr.push(arr[i].substr(0, sLen));
5303
+ }
5304
+ return newArr;
5305
+ }
5306
+
5307
+ function monthUpdate() {
5308
+ return function (d, v) {
5309
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5310
+ if (~index) {
5311
+ d.month = index;
5312
+ }
5313
+ };
5314
+ }
5315
+
5316
+ function pad(val, len) {
5317
+ val = String(val);
5318
+ len = len || 2;
5319
+ while (val.length < len) {
5320
+ val = '0' + val;
5321
+ }
5322
+ return val;
5323
+ }
5324
+
5325
+ // 直接使用中文日期名称常量
5326
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5327
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5328
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5329
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5330
+ const amPm = ['上午', '下午'];
5331
+ const DoFn = function DoFn(D) {
5332
+ return D + '日';
5333
+ };
5334
+
5335
+ const formatFlags = {
5336
+ D: function(dateObj) {
5337
+ return dateObj.getDay();
5338
+ },
5339
+ DD: function(dateObj) {
5340
+ return pad(dateObj.getDay());
5341
+ },
5342
+ Do: function(dateObj) {
5343
+ return DoFn(dateObj.getDate());
5344
+ },
5345
+ d: function(dateObj) {
5346
+ return dateObj.getDate();
5347
+ },
5348
+ dd: function(dateObj) {
5349
+ return pad(dateObj.getDate());
5350
+ },
5351
+ ddd: function(dateObj) {
5352
+ return dayNamesShort[dateObj.getDay()];
5353
+ },
5354
+ dddd: function(dateObj) {
5355
+ return dayNames[dateObj.getDay()];
5356
+ },
5357
+ M: function(dateObj) {
5358
+ return dateObj.getMonth() + 1;
5359
+ },
5360
+ MM: function(dateObj) {
5361
+ return pad(dateObj.getMonth() + 1);
5362
+ },
5363
+ MMM: function(dateObj) {
5364
+ return monthNamesShort[dateObj.getMonth()];
5365
+ },
5366
+ MMMM: function(dateObj) {
5367
+ return monthNames[dateObj.getMonth()];
5368
+ },
5369
+ yy: function(dateObj) {
5370
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5371
+ },
5372
+ yyyy: function(dateObj) {
5373
+ return pad(dateObj.getFullYear(), 4);
5374
+ },
5375
+ h: function(dateObj) {
5376
+ return dateObj.getHours() % 12 || 12;
5377
+ },
5378
+ hh: function(dateObj) {
5379
+ return pad(dateObj.getHours() % 12 || 12);
5380
+ },
5381
+ H: function(dateObj) {
5382
+ return dateObj.getHours();
5383
+ },
5384
+ HH: function(dateObj) {
5385
+ return pad(dateObj.getHours());
5386
+ },
5387
+ m: function(dateObj) {
5388
+ return dateObj.getMinutes();
5389
+ },
5390
+ mm: function(dateObj) {
5391
+ return pad(dateObj.getMinutes());
5392
+ },
5393
+ s: function(dateObj) {
5394
+ return dateObj.getSeconds();
5395
+ },
5396
+ ss: function(dateObj) {
5397
+ return pad(dateObj.getSeconds());
5398
+ },
5399
+ S: function(dateObj) {
5400
+ return Math.round(dateObj.getMilliseconds() / 100);
5401
+ },
5402
+ SS: function(dateObj) {
5403
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5404
+ },
5405
+ SSS: function(dateObj) {
5406
+ return pad(dateObj.getMilliseconds(), 3);
5407
+ },
5408
+ a: function(dateObj) {
5409
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5410
+ },
5411
+ A: function(dateObj) {
5412
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5413
+ },
5414
+ ZZ: function(dateObj) {
5415
+ const o = dateObj.getTimezoneOffset();
5416
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5417
+ }
5418
+ };
5419
+
5420
+ const parseFlags = {
5421
+ d: [twoDigits, function (d, v) {
5422
+ d.day = v;
5423
+ }],
5424
+ Do: [twoDigits + word, function (d, v) {
5425
+ d.day = parseInt(v, 10);
5426
+ }],
5427
+ M: [twoDigits, function (d, v) {
5428
+ d.month = v - 1;
5429
+ }],
5430
+ yy: [twoDigits, function (d, v) {
5431
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5432
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5433
+ }],
5434
+ h: [twoDigits, function (d, v) {
5435
+ d.hour = v;
5436
+ }],
5437
+ m: [twoDigits, function (d, v) {
5438
+ d.minute = v;
5439
+ }],
5440
+ s: [twoDigits, function (d, v) {
5441
+ d.second = v;
5442
+ }],
5443
+ yyyy: [fourDigits, function (d, v) {
5444
+ d.year = v;
5445
+ }],
5446
+ S: ['\\d', function (d, v) {
5447
+ d.millisecond = v * 100;
5448
+ }],
5449
+ SS: ['\\d{2}', function (d, v) {
5450
+ d.millisecond = v * 10;
5451
+ }],
5452
+ SSS: [threeDigits, function (d, v) {
5453
+ d.millisecond = v;
5454
+ }],
5455
+ D: [twoDigits, noop],
5456
+ ddd: [word, noop],
5457
+ MMM: [word, monthUpdate('monthNamesShort')],
5458
+ MMMM: [word, monthUpdate('monthNames')],
5459
+ a: [word, function (d, v) {
5460
+ const val = v.toLowerCase();
5461
+ if (val === '上午') {
5462
+ d.isPm = false;
5463
+ } else if (val === '下午') {
5464
+ d.isPm = true;
5465
+ }
5466
+ }],
5467
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5468
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5469
+
5470
+ if (parts) {
5471
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5472
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5473
+ }
5474
+ }]
5475
+ };
5476
+ parseFlags.dd = parseFlags.d;
5477
+ parseFlags.dddd = parseFlags.ddd;
5478
+ parseFlags.DD = parseFlags.D;
5479
+ parseFlags.mm = parseFlags.m;
5480
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5481
+ parseFlags.MM = parseFlags.M;
5482
+ parseFlags.ss = parseFlags.s;
5483
+ parseFlags.A = parseFlags.a;
5484
+
5485
+
5486
+ // Some common format strings
5487
+ fecha.masks = {
5488
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5489
+ shortDate: 'M/D/yy',
5490
+ mediumDate: 'MMM d, yyyy',
5491
+ longDate: 'MMMM d, yyyy',
5492
+ fullDate: 'dddd, MMMM d, yyyy',
5493
+ shortTime: 'HH:mm',
5494
+ mediumTime: 'HH:mm:ss',
5495
+ longTime: 'HH:mm:ss.SSS'
5496
+ };
5497
+
5428
5498
  /***
5429
5499
  * Format a date
5430
5500
  * @method format
5431
5501
  * @param {Date|number} dateObj
5432
5502
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5433
- */
5434
- fecha.format = function (dateObj, mask) {
5435
- if (typeof dateObj === 'number') {
5436
- dateObj = new Date(dateObj);
5437
- }
5438
-
5439
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5440
- throw new Error('Invalid Date in fecha.format');
5441
- }
5442
-
5443
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5444
-
5445
- var literals = [];
5446
-
5447
- // Make literals inactive by replacing them with ??
5448
- mask = mask.replace(literal, function ($0, $1) {
5449
- literals.push($1);
5450
- return '@@@';
5451
- });
5452
- // Apply formatting rules
5453
- mask = mask.replace(token, function ($0) {
5454
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5455
- });
5456
- // Inline literal values back into the formatted value
5457
- return mask.replace(/@@@/g, function () {
5458
- return literals.shift();
5459
- });
5460
- };
5461
-
5503
+ */
5504
+ fecha.format = function (dateObj, mask) {
5505
+ if (typeof dateObj === 'number') {
5506
+ dateObj = new Date(dateObj);
5507
+ }
5508
+
5509
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5510
+ throw new Error('Invalid Date in fecha.format');
5511
+ }
5512
+
5513
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5514
+
5515
+ const literals = [];
5516
+
5517
+ // Make literals inactive by replacing them with ??
5518
+ mask = mask.replace(literal, function($0, $1) {
5519
+ literals.push($1);
5520
+ return '@@@';
5521
+ });
5522
+ // Apply formatting rules
5523
+ mask = mask.replace(token, function ($0) {
5524
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5525
+ });
5526
+ // Inline literal values back into the formatted value
5527
+ return mask.replace(/@@@/g, function() {
5528
+ return literals.shift();
5529
+ });
5530
+ };
5531
+
5462
5532
  /**
5463
5533
  * Parse a date string into an object, changes - into /
5464
5534
  * @method parse
5465
5535
  * @param {string} dateStr Date string
5466
5536
  * @param {string} format Date parse format
5467
5537
  * @returns {Date|boolean}
5468
- */
5469
- fecha.parse = function (dateStr, format) {
5470
- if (typeof format !== 'string') {
5471
- throw new Error('Invalid format in fecha.parse');
5472
- }
5473
-
5474
- format = fecha.masks[format] || format;
5475
-
5476
- // Avoid regular expression denial of service, fail early for really long strings
5477
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5478
- if (dateStr.length > 1000) {
5479
- return null;
5480
- }
5481
-
5482
- var dateInfo = {};
5483
- var parseInfo = [];
5484
- var literals = [];
5485
- format = format.replace(literal, function ($0, $1) {
5486
- literals.push($1);
5487
- return '@@@';
5488
- });
5489
- var newFormat = regexEscape(format).replace(token, function ($0) {
5490
- if (parseFlags[$0]) {
5491
- var info = parseFlags[$0];
5492
- parseInfo.push(info[1]);
5493
- return '(' + info[0] + ')';
5494
- }
5495
-
5496
- return $0;
5497
- });
5498
- newFormat = newFormat.replace(/@@@/g, function () {
5499
- return literals.shift();
5500
- });
5501
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
5502
- if (!matches) {
5503
- return null;
5504
- }
5505
-
5506
- for (var i = 1; i < matches.length; i++) {
5507
- parseInfo[i - 1](dateInfo, matches[i]);
5508
- }
5509
-
5510
- var today = new Date();
5511
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5512
- dateInfo.hour = +dateInfo.hour + 12;
5513
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5514
- dateInfo.hour = 0;
5515
- }
5516
-
5517
- var date = void 0;
5518
- if (dateInfo.timezoneOffset != null) {
5519
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5520
- 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));
5521
- } else {
5522
- 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);
5523
- }
5524
- return date;
5525
- };
5526
-
5527
- // 导出fecha对象
5528
-
5529
-
5530
- // 以下是从date-util.js合并的函数
5531
- var newArray = function newArray(start, end) {
5532
- var result = [];
5533
- for (var i = start; i <= end; i++) {
5534
- result.push(i);
5535
- }
5536
- return result;
5537
- };
5538
-
5539
- var getSettings = function getSettings() {
5540
- return {
5541
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5542
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5543
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5544
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5545
- amPm: ['上午', '下午']
5546
- };
5547
- };
5548
-
5549
- var toDate = function toDate(date) {
5550
- return isDate(date) ? new Date(date) : null;
5551
- };
5552
-
5553
- var isDate = function isDate(date) {
5554
- if (date === null || date === undefined) return false;
5555
- if (isNaN(new Date(date).getTime())) return false;
5556
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5557
- return true;
5558
- };
5559
-
5560
- var isDateObject = function isDateObject(val) {
5561
- return val instanceof Date;
5562
- };
5563
-
5564
- var formatDate = function formatDate(date) {
5565
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5566
-
5567
- // 处理多种输入类型
5568
- if (!date) return '';
5569
-
5570
- // 如果是时间戳,转成日期对象
5571
- if (typeof date === 'number') {
5572
- date = new Date(date);
5573
- }
5574
- // 如果是字符串,转成日期对象
5575
- if (typeof date === 'string') {
5576
- date = new Date(date);
5577
- }
5578
-
5579
- // 调用toDate进一步验证和转换
5580
- date = toDate(date);
5581
- if (!date) return '';
5582
-
5583
- // 兼容大写和小写的格式标记
5584
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5585
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5586
-
5587
- // 使用fecha库进行格式化,支持中文配置
5588
- var str = fecha.format(date, lowercaseFormat, getSettings());
5589
- return str;
5590
- };
5591
-
5592
- var parseDate = function parseDate(string, format) {
5593
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5594
- };
5595
-
5596
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5597
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5598
- return 30;
5599
- }
5600
-
5601
- if (month === 1) {
5602
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5603
- return 29;
5604
- } else {
5605
- return 28;
5606
- }
5607
- }
5608
-
5609
- return 31;
5610
- };
5611
-
5612
- var getDayCountOfYear = function getDayCountOfYear(year) {
5613
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5614
- return isLeapYear ? 366 : 365;
5615
- };
5616
-
5617
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5618
- var temp = new Date(date.getTime());
5619
- temp.setDate(1);
5620
- return temp.getDay();
5621
- };
5622
-
5623
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5624
- // {prev, next} Date should work for Daylight Saving Time
5625
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5626
- var prevDate = function prevDate(date) {
5627
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5628
-
5629
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5630
- };
5631
-
5632
- var nextDate = function nextDate(date) {
5633
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5634
-
5635
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5636
- };
5637
-
5638
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5639
- var result = new Date(year, month, 1);
5640
- var day = result.getDay();
5641
-
5642
- if (day === 0) {
5643
- return prevDate(result, 7);
5644
- } else {
5645
- return prevDate(result, day);
5646
- }
5647
- };
5648
-
5649
- var getWeekNumber = function getWeekNumber(date) {
5650
- // 支持多种输入类型
5651
- if (!date || !isDate(date)) {
5652
- date = new Date();
5653
- }
5654
- if (typeof date === 'string') {
5655
- date = new Date(date);
5656
- }
5657
-
5658
- // 验证日期有效性
5659
- if (!isDate(date)) return null;
5660
-
5661
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5662
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5663
- // 将星期日的星期数设为7
5664
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5665
- // 获取当年的第一天
5666
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5667
- // 计算到最近的星期四的完整周数
5668
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5669
- // 返回周数
5670
- return weekNo;
5671
- };
5672
-
5673
- var getRangeHours = function getRangeHours(ranges) {
5674
- var hours = [];
5675
- var disabledHours = [];
5676
-
5677
- (ranges || []).forEach(function (range) {
5678
- var value = range.map(function (date) {
5679
- return date.getHours();
5680
- });
5681
-
5682
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5683
- });
5684
-
5685
- if (disabledHours.length) {
5686
- for (var i = 0; i < 24; i++) {
5687
- hours[i] = disabledHours.indexOf(i) === -1;
5688
- }
5689
- } else {
5690
- for (var _i = 0; _i < 24; _i++) {
5691
- hours[_i] = false;
5692
- }
5693
- }
5694
-
5695
- return hours;
5696
- };
5697
-
5698
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5699
- if (amount <= 0) return [];
5700
- var temp = new Date(date.getTime());
5701
- temp.setDate(0);
5702
- var lastDay = temp.getDate();
5703
- return range(amount).map(function (_, index) {
5704
- return lastDay - (amount - index - 1);
5705
- });
5706
- };
5707
-
5708
- var getMonthDays = function getMonthDays(date) {
5709
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5710
- var days = temp.getDate();
5711
- return range(days).map(function (_, index) {
5712
- return index + 1;
5713
- });
5714
- };
5715
-
5716
- function setRangeData(arr, start, end, value) {
5717
- for (var i = start; i < end; i++) {
5718
- arr[i] = value;
5719
- }
5720
- }
5721
-
5722
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5723
- var minutes = new Array(60);
5724
-
5725
- if (ranges.length > 0) {
5726
- ranges.forEach(function (range) {
5727
- var start = range[0];
5728
- var end = range[1];
5729
- var startHour = start.getHours();
5730
- var startMinute = start.getMinutes();
5731
- var endHour = end.getHours();
5732
- var endMinute = end.getMinutes();
5733
- if (startHour === hour && endHour !== hour) {
5734
- setRangeData(minutes, startMinute, 60, true);
5735
- } else if (startHour === hour && endHour === hour) {
5736
- setRangeData(minutes, startMinute, endMinute + 1, true);
5737
- } else if (startHour !== hour && endHour === hour) {
5738
- setRangeData(minutes, 0, endMinute + 1, true);
5739
- } else if (startHour < hour && endHour > hour) {
5740
- setRangeData(minutes, 0, 60, true);
5741
- }
5742
- });
5743
- } else {
5744
- setRangeData(minutes, 0, 60, true);
5745
- }
5746
- return minutes;
5747
- };
5748
-
5749
- var range = function range(n) {
5750
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5751
- return Array.apply(null, { length: n }).map(function (_, n) {
5752
- return n;
5753
- });
5754
- };
5755
-
5756
- var modifyDate = function modifyDate(date, y, m, d) {
5757
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5758
- };
5759
-
5760
- var modifyTime = function modifyTime(date, h, m, s) {
5761
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5762
- };
5763
-
5764
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
5765
- if (date == null || !time) {
5766
- return date;
5767
- }
5768
- time = parseDate(time, 'HH:mm:ss');
5769
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5770
- };
5771
-
5772
- var clearTime = function clearTime(date) {
5773
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5774
- };
5775
-
5776
- var clearMilliseconds = function clearMilliseconds(date) {
5777
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5778
- };
5779
-
5780
- var limitTimeRange = function limitTimeRange(date, ranges) {
5781
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5782
-
5783
- // TODO: refactory a more elegant solution
5784
- if (ranges.length === 0) return date;
5785
- var normalizeDate = function normalizeDate(date) {
5786
- return fecha.parse(fecha.format(date, format), format);
5787
- };
5788
- var ndate = normalizeDate(date);
5789
- var nranges = ranges.map(function (range) {
5790
- return range.map(normalizeDate);
5791
- });
5792
- if (nranges.some(function (nrange) {
5793
- return ndate >= nrange[0] && ndate <= nrange[1];
5794
- })) return date;
5795
-
5796
- var minDate = nranges[0][0];
5797
- var maxDate = nranges[0][0];
5798
-
5799
- nranges.forEach(function (nrange) {
5800
- minDate = new Date(Math.min(nrange[0], minDate));
5801
- maxDate = new Date(Math.max(nrange[1], minDate));
5802
- });
5803
-
5804
- var ret = ndate < minDate ? minDate : maxDate;
5805
- // preserve Year/Month/Date
5806
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5807
- };
5808
-
5809
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5810
- var limitedDate = limitTimeRange(date, selectableRange, format);
5811
- return limitedDate.getTime() === date.getTime();
5812
- };
5813
-
5814
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5815
- // clamp date to the number of days in `year`, `month`
5816
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5817
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5818
- return modifyDate(date, year, month, monthDate);
5819
- };
5820
-
5821
- var prevMonth = function prevMonth(date) {
5822
- var year = date.getFullYear();
5823
- var month = date.getMonth();
5824
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5825
- };
5826
-
5827
- var nextMonth = function nextMonth(date) {
5828
- var year = date.getFullYear();
5829
- var month = date.getMonth();
5830
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5831
- };
5832
-
5833
- var prevYear = function prevYear(date) {
5834
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5835
-
5836
- var year = date.getFullYear();
5837
- var month = date.getMonth();
5838
- return changeYearMonthAndClampDate(date, year - amount, month);
5839
- };
5840
-
5841
- var nextYear = function nextYear(date) {
5842
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5843
-
5844
- var year = date.getFullYear();
5845
- var month = date.getMonth();
5846
- return changeYearMonthAndClampDate(date, year + amount, month);
5847
- };
5848
-
5849
- var extractDateFormat = function extractDateFormat(format) {
5850
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5851
- };
5852
-
5853
- var extractTimeFormat = function extractTimeFormat(format) {
5854
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5855
- };
5856
-
5857
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5858
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5859
- };
5860
-
5538
+ */
5539
+ fecha.parse = function (dateStr, format) {
5540
+ if (typeof format !== 'string') {
5541
+ throw new Error('Invalid format in fecha.parse');
5542
+ }
5543
+
5544
+ format = fecha.masks[format] || format;
5545
+
5546
+ // Avoid regular expression denial of service, fail early for really long strings
5547
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5548
+ if (dateStr.length > 1000) {
5549
+ return null;
5550
+ }
5551
+
5552
+ const dateInfo = {};
5553
+ const parseInfo = [];
5554
+ const literals = [];
5555
+ format = format.replace(literal, function($0, $1) {
5556
+ literals.push($1);
5557
+ return '@@@';
5558
+ });
5559
+ let newFormat = regexEscape(format).replace(token, function ($0) {
5560
+ if (parseFlags[$0]) {
5561
+ const info = parseFlags[$0];
5562
+ parseInfo.push(info[1]);
5563
+ return '(' + info[0] + ')';
5564
+ }
5565
+
5566
+ return $0;
5567
+ });
5568
+ newFormat = newFormat.replace(/@@@/g, function() {
5569
+ return literals.shift();
5570
+ });
5571
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
5572
+ if (!matches) {
5573
+ return null;
5574
+ }
5575
+
5576
+ for (let i = 1; i < matches.length; i++) {
5577
+ parseInfo[i - 1](dateInfo, matches[i]);
5578
+ }
5579
+
5580
+ const today = new Date();
5581
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5582
+ dateInfo.hour = +dateInfo.hour + 12;
5583
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5584
+ dateInfo.hour = 0;
5585
+ }
5586
+
5587
+ let date;
5588
+ if (dateInfo.timezoneOffset != null) {
5589
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5590
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5591
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5592
+ } else {
5593
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5594
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5595
+ }
5596
+ return date;
5597
+ };
5598
+
5599
+ // 导出fecha对象
5600
+
5601
+
5602
+ // 以下是从date-util.js合并的函数
5603
+ const newArray = function(start, end) {
5604
+ let result = [];
5605
+ for (let i = start; i <= end; i++) {
5606
+ result.push(i);
5607
+ }
5608
+ return result;
5609
+ };
5610
+
5611
+ const getSettings = () => {
5612
+ return {
5613
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5614
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5615
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5616
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5617
+ amPm: ['上午', '下午']
5618
+ };
5619
+ };
5620
+
5621
+ const toDate = function(date) {
5622
+ return isDate(date) ? new Date(date) : null;
5623
+ };
5624
+
5625
+ const isDate = function(date) {
5626
+ if (date === null || date === undefined) return false;
5627
+ if (isNaN(new Date(date).getTime())) return false;
5628
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5629
+ return true;
5630
+ };
5631
+
5632
+ const isDateObject = function(val) {
5633
+ return val instanceof Date;
5634
+ };
5635
+
5636
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
5637
+ // 处理多种输入类型
5638
+ if (!date) return '';
5639
+
5640
+ // 如果是时间戳,转成日期对象
5641
+ if (typeof date === 'number') {
5642
+ date = new Date(date);
5643
+ }
5644
+ // 如果是字符串,转成日期对象
5645
+ if (typeof date === 'string') {
5646
+ date = new Date(date);
5647
+ }
5648
+
5649
+ // 调用toDate进一步验证和转换
5650
+ date = toDate(date);
5651
+ if (!date) return '';
5652
+
5653
+ // 兼容大写和小写的格式标记
5654
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5655
+ const lowercaseFormat = format
5656
+ .replace(/YYYY/g, 'yyyy')
5657
+ .replace(/D/g, 'd')
5658
+
5659
+ // 使用fecha库进行格式化,支持中文配置
5660
+ const str = fecha.format(date, lowercaseFormat, getSettings());
5661
+ return str;
5662
+ };
5663
+
5664
+ const parseDate = function(string, format) {
5665
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5666
+ };
5667
+
5668
+ const getDayCountOfMonth = function(year, month) {
5669
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5670
+ return 30;
5671
+ }
5672
+
5673
+ if (month === 1) {
5674
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5675
+ return 29;
5676
+ } else {
5677
+ return 28;
5678
+ }
5679
+ }
5680
+
5681
+ return 31;
5682
+ };
5683
+
5684
+ const getDayCountOfYear = function(year) {
5685
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5686
+ return isLeapYear ? 366 : 365;
5687
+ };
5688
+
5689
+ const getFirstDayOfMonth = function(date) {
5690
+ const temp = new Date(date.getTime());
5691
+ temp.setDate(1);
5692
+ return temp.getDay();
5693
+ };
5694
+
5695
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5696
+ // {prev, next} Date should work for Daylight Saving Time
5697
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5698
+ const prevDate = function(date, amount = 1) {
5699
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5700
+ };
5701
+
5702
+ const nextDate = function(date, amount = 1) {
5703
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5704
+ };
5705
+
5706
+ const getStartDateOfMonth = function(year, month) {
5707
+ const result = new Date(year, month, 1);
5708
+ const day = result.getDay();
5709
+
5710
+ if (day === 0) {
5711
+ return prevDate(result, 7);
5712
+ } else {
5713
+ return prevDate(result, day);
5714
+ }
5715
+ };
5716
+
5717
+ const getWeekNumber = function(date) {
5718
+ // 支持多种输入类型
5719
+ if (!date||!isDate(date)) {
5720
+ date = new Date();
5721
+ }
5722
+ if (typeof date === 'string') {
5723
+ date = new Date(date);
5724
+ }
5725
+
5726
+ // 验证日期有效性
5727
+ if (!isDate(date)) return null;
5728
+
5729
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5730
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5731
+ // 将星期日的星期数设为7
5732
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5733
+ // 获取当年的第一天
5734
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5735
+ // 计算到最近的星期四的完整周数
5736
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5737
+ // 返回周数
5738
+ return weekNo;
5739
+ };
5740
+
5741
+ const getRangeHours = function(ranges) {
5742
+ const hours = [];
5743
+ let disabledHours = [];
5744
+
5745
+ (ranges || []).forEach(range => {
5746
+ const value = range.map(date => date.getHours());
5747
+
5748
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5749
+ });
5750
+
5751
+ if (disabledHours.length) {
5752
+ for (let i = 0; i < 24; i++) {
5753
+ hours[i] = disabledHours.indexOf(i) === -1;
5754
+ }
5755
+ } else {
5756
+ for (let i = 0; i < 24; i++) {
5757
+ hours[i] = false;
5758
+ }
5759
+ }
5760
+
5761
+ return hours;
5762
+ };
5763
+
5764
+ const getPrevMonthLastDays = (date, amount) => {
5765
+ if (amount <= 0) return [];
5766
+ const temp = new Date(date.getTime());
5767
+ temp.setDate(0);
5768
+ const lastDay = temp.getDate();
5769
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
5770
+ };
5771
+
5772
+ const getMonthDays = (date) => {
5773
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5774
+ const days = temp.getDate();
5775
+ return range(days).map((_, index) => index + 1);
5776
+ };
5777
+
5778
+ function setRangeData(arr, start, end, value) {
5779
+ for (let i = start; i < end; i++) {
5780
+ arr[i] = value;
5781
+ }
5782
+ }
5783
+
5784
+ const getRangeMinutes = function(ranges, hour) {
5785
+ const minutes = new Array(60);
5786
+
5787
+ if (ranges.length > 0) {
5788
+ ranges.forEach(range => {
5789
+ const start = range[0];
5790
+ const end = range[1];
5791
+ const startHour = start.getHours();
5792
+ const startMinute = start.getMinutes();
5793
+ const endHour = end.getHours();
5794
+ const endMinute = end.getMinutes();
5795
+ if (startHour === hour && endHour !== hour) {
5796
+ setRangeData(minutes, startMinute, 60, true);
5797
+ } else if (startHour === hour && endHour === hour) {
5798
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5799
+ } else if (startHour !== hour && endHour === hour) {
5800
+ setRangeData(minutes, 0, endMinute + 1, true);
5801
+ } else if (startHour < hour && endHour > hour) {
5802
+ setRangeData(minutes, 0, 60, true);
5803
+ }
5804
+ });
5805
+ } else {
5806
+ setRangeData(minutes, 0, 60, true);
5807
+ }
5808
+ return minutes;
5809
+ };
5810
+
5811
+ const range = function(n) {
5812
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5813
+ return Array.apply(null, {length: n}).map((_, n) => n);
5814
+ };
5815
+
5816
+ const modifyDate = function(date, y, m, d) {
5817
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5818
+ };
5819
+
5820
+ const modifyTime = function(date, h, m, s) {
5821
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5822
+ };
5823
+
5824
+ const modifyWithTimeString = (date, time) => {
5825
+ if (date == null || !time) {
5826
+ return date;
5827
+ }
5828
+ time = parseDate(time, 'HH:mm:ss');
5829
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5830
+ };
5831
+
5832
+ const clearTime = function(date) {
5833
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5834
+ };
5835
+
5836
+ const clearMilliseconds = function(date) {
5837
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5838
+ };
5839
+
5840
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5841
+ // TODO: refactory a more elegant solution
5842
+ if (ranges.length === 0) return date;
5843
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5844
+ const ndate = normalizeDate(date);
5845
+ const nranges = ranges.map(range => range.map(normalizeDate));
5846
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5847
+
5848
+ let minDate = nranges[0][0];
5849
+ let maxDate = nranges[0][0];
5850
+
5851
+ nranges.forEach(nrange => {
5852
+ minDate = new Date(Math.min(nrange[0], minDate));
5853
+ maxDate = new Date(Math.max(nrange[1], minDate));
5854
+ });
5855
+
5856
+ const ret = ndate < minDate ? minDate : maxDate;
5857
+ // preserve Year/Month/Date
5858
+ return modifyDate(
5859
+ ret,
5860
+ date.getFullYear(),
5861
+ date.getMonth(),
5862
+ date.getDate()
5863
+ );
5864
+ };
5865
+
5866
+ const timeWithinRange = function(date, selectableRange, format) {
5867
+ const limitedDate = limitTimeRange(date, selectableRange, format);
5868
+ return limitedDate.getTime() === date.getTime();
5869
+ };
5870
+
5871
+ const changeYearMonthAndClampDate = function(date, year, month) {
5872
+ // clamp date to the number of days in `year`, `month`
5873
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5874
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5875
+ return modifyDate(date, year, month, monthDate);
5876
+ };
5877
+
5878
+ const prevMonth = function(date) {
5879
+ const year = date.getFullYear();
5880
+ const month = date.getMonth();
5881
+ return month === 0
5882
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5883
+ : changeYearMonthAndClampDate(date, year, month - 1);
5884
+ };
5885
+
5886
+ const nextMonth = function(date) {
5887
+ const year = date.getFullYear();
5888
+ const month = date.getMonth();
5889
+ return month === 11
5890
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5891
+ : changeYearMonthAndClampDate(date, year, month + 1);
5892
+ };
5893
+
5894
+ const prevYear = function(date, amount = 1) {
5895
+ const year = date.getFullYear();
5896
+ const month = date.getMonth();
5897
+ return changeYearMonthAndClampDate(date, year - amount, month);
5898
+ };
5899
+
5900
+ const nextYear = function(date, amount = 1) {
5901
+ const year = date.getFullYear();
5902
+ const month = date.getMonth();
5903
+ return changeYearMonthAndClampDate(date, year + amount, month);
5904
+ };
5905
+
5906
+ const extractDateFormat = function(format) {
5907
+ return format
5908
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
5909
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5910
+ .trim();
5911
+ };
5912
+
5913
+ const extractTimeFormat = function(format) {
5914
+ return format
5915
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5916
+ .trim();
5917
+ };
5918
+
5919
+ const validateRangeInOneMonth = function(start, end) {
5920
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5921
+ };
5922
+
5861
5923
  /**
5862
5924
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5863
5925
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5864
5926
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5865
5927
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5866
5928
  * @returns {number} 工作日数量
5867
- */
5868
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5869
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5870
-
5871
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5872
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5873
- }
5874
-
5875
- var startDateObj = new Date(start_date);
5876
- var endDateObj = new Date(end_date);
5877
-
5878
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5879
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5880
- }
5881
-
5882
- if (startDateObj > endDateObj) {
5883
- throw new Error('Start date should be earlier than or equal to end date.');
5884
- }
5885
-
5886
- var workdays = 0;
5887
-
5888
- // Iterate through each day in the date range
5889
-
5890
- var _loop = function _loop(currentDate) {
5891
- // Check if the current day is a weekend (Saturday or Sunday)
5892
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5893
-
5894
- // Check if the current day is a holiday
5895
- var isHoliday = holidays.some(function (holiday) {
5896
- var holidayDate = new Date(holiday);
5897
- return currentDate.toDateString() === holidayDate.toDateString();
5898
- });
5899
-
5900
- // If it's a workday (not a weekend or holiday), increment the workdays count
5901
- if (!isWeekend && !isHoliday) {
5902
- workdays++;
5903
- }
5904
- };
5905
-
5906
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5907
- _loop(currentDate);
5908
- }
5909
-
5910
- return workdays;
5911
- };
5912
-
5929
+ */
5930
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5931
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5932
+ throw new Error(
5933
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5934
+ );
5935
+ }
5936
+
5937
+ const startDateObj = new Date(start_date);
5938
+ const endDateObj = new Date(end_date);
5939
+
5940
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5941
+ throw new Error(
5942
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5943
+ );
5944
+ }
5945
+
5946
+ if (startDateObj > endDateObj) {
5947
+ throw new Error('Start date should be earlier than or equal to end date.');
5948
+ }
5949
+
5950
+ let workdays = 0;
5951
+
5952
+ // Iterate through each day in the date range
5953
+ for (
5954
+ let currentDate = new Date(startDateObj);
5955
+ currentDate <= endDateObj;
5956
+ currentDate.setDate(currentDate.getDate() + 1)
5957
+ ) {
5958
+ // Check if the current day is a weekend (Saturday or Sunday)
5959
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5960
+
5961
+ // Check if the current day is a holiday
5962
+ const isHoliday = holidays.some((holiday) => {
5963
+ const holidayDate = new Date(holiday);
5964
+ return currentDate.toDateString() === holidayDate.toDateString();
5965
+ });
5966
+
5967
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5968
+ if (!isWeekend && !isHoliday) {
5969
+ workdays++;
5970
+ }
5971
+ }
5972
+
5973
+ return workdays;
5974
+ };
5975
+
5913
5976
  /**
5914
5977
  * 日期加减天数
5915
5978
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5916
5979
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5917
5980
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5918
- */
5919
- var dateAddDays = function dateAddDays(start_date, days) {
5920
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5921
- 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.");
5922
- }
5923
-
5924
- var startDateObj = new Date(start_date);
5925
- if (isNaN(startDateObj.getTime())) {
5926
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5927
- }
5928
-
5929
- var resultDateObj = new Date(startDateObj);
5930
- resultDateObj.setDate(resultDateObj.getDate() + days);
5931
-
5932
- var resultYear = resultDateObj.getFullYear();
5933
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5934
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5935
-
5936
- return resultYear + '-' + resultMonth + '-' + resultDay;
5937
- };
5938
-
5981
+ */
5982
+ const dateAddDays = function (start_date, days) {
5983
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5984
+ throw new Error(
5985
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5986
+ );
5987
+ }
5988
+
5989
+ const startDateObj = new Date(start_date);
5990
+ if (isNaN(startDateObj.getTime())) {
5991
+ throw new Error(
5992
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5993
+ );
5994
+ }
5995
+
5996
+ const resultDateObj = new Date(startDateObj);
5997
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5998
+
5999
+ const resultYear = resultDateObj.getFullYear();
6000
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6001
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6002
+
6003
+ return `${resultYear}-${resultMonth}-${resultDay}`;
6004
+ };
6005
+
5939
6006
  /**
5940
6007
  * 计算两个日期之间的差值
5941
6008
  * @date 2023年12月14日
@@ -5943,180 +6010,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
5943
6010
  * @param {String} end_date - 结束日期字符串
5944
6011
  * @param {String} unit - 单位:year/month/day
5945
6012
  * @returns {Number} 差值
5946
- */
5947
- var dateDiff = function dateDiff(start_date, end_date) {
5948
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5949
-
5950
- // Assuming date strings are in "YYYY-MM-DD" format
5951
- var startDate = new Date(start_date);
5952
- var endDate = new Date(end_date);
5953
-
5954
- // If the date is invalid, return 0
5955
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5956
- return 0;
5957
- }
5958
-
5959
- if (unit === 'year') {
5960
- return endDate.getFullYear() - startDate.getFullYear();
5961
- } else if (unit === 'month') {
5962
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5963
- } else {
5964
- // Default to day
5965
- var timeDifference = endDate - startDate;
5966
- // Calculate days (86400000 milliseconds per day)
5967
- return Math.floor(timeDifference / 86400000);
5968
- }
5969
- };
5970
-
6013
+ */
6014
+ const dateDiff = function (start_date, end_date, unit = 'day') {
6015
+ // Assuming date strings are in "YYYY-MM-DD" format
6016
+ var startDate = new Date(start_date);
6017
+ var endDate = new Date(end_date);
6018
+
6019
+ // If the date is invalid, return 0
6020
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6021
+ return 0;
6022
+ }
6023
+
6024
+ if (unit === 'year') {
6025
+ return endDate.getFullYear() - startDate.getFullYear();
6026
+ } else if (unit === 'month') {
6027
+ return (
6028
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
6029
+ (endDate.getMonth() - startDate.getMonth())
6030
+ );
6031
+ } else {
6032
+ // Default to day
6033
+ var timeDifference = endDate - startDate;
6034
+ // Calculate days (86400000 milliseconds per day)
6035
+ return Math.floor(timeDifference / 86400000);
6036
+ }
6037
+ };
6038
+
5971
6039
  /**
5972
6040
  * 获取月份中的日期
5973
6041
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5974
6042
  * @returns {number} 月份中的日期(1-31)
5975
- */
5976
- var dayOfMonth = function dayOfMonth(date) {
5977
- if (typeof date !== 'string') {
5978
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5979
- }
5980
-
5981
- var dateObj = new Date(date);
5982
- if (isNaN(dateObj.getTime())) {
5983
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5984
- }
5985
-
5986
- return dateObj.getDate();
5987
- };
5988
-
6043
+ */
6044
+ const dayOfMonth = function (date) {
6045
+ if (typeof date !== 'string') {
6046
+ throw new Error(
6047
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
6048
+ );
6049
+ }
6050
+
6051
+ const dateObj = new Date(date);
6052
+ if (isNaN(dateObj.getTime())) {
6053
+ throw new Error(
6054
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6055
+ );
6056
+ }
6057
+
6058
+ return dateObj.getDate();
6059
+ };
6060
+
5989
6061
  /**
5990
6062
  * 获取当前日期
5991
6063
  * @date 2022年5月7日
5992
6064
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5993
6065
  * @returns {string} 当前日期的格式化字符串
5994
- */
5995
- var getCurrentDate = function getCurrentDate() {
5996
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5997
-
5998
- return formatDate(new Date(), format);
5999
- };
6000
-
6066
+ */
6067
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
6068
+ return formatDate(new Date(), format);
6069
+ };
6070
+
6001
6071
  /**
6002
6072
  * 获取当前日期时间
6003
6073
  * @date 2022年5月7日
6004
6074
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
6005
6075
  * @returns {string} 当前日期时间的格式化字符串
6006
- */
6007
- var getCurrentDateTime = function getCurrentDateTime() {
6008
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
6009
-
6010
- return formatDate(new Date(), format);
6011
- };
6012
-
6076
+ */
6077
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
6078
+ return formatDate(new Date(), format);
6079
+ };
6080
+
6013
6081
  /**
6014
6082
  * 获取小时
6015
6083
  * @date 2022年5月7日
6016
6084
  * @param {Date|string} [date] - 日期对象或日期字符串
6017
6085
  * @returns {number} 小时数(0-23)
6018
- */
6019
- var getHour = function getHour(date) {
6020
- if (!date) {
6021
- return new Date().getHours();
6022
- }
6023
- if (typeof date === 'string') {
6024
- date = new Date(date);
6025
- }
6026
- return date.getHours();
6027
- };
6028
-
6086
+ */
6087
+ const getHour = function (date) {
6088
+ if (!date) {
6089
+ return new Date().getHours();
6090
+ }
6091
+ if (typeof date === 'string') {
6092
+ date = new Date(date);
6093
+ }
6094
+ return date.getHours();
6095
+ };
6096
+
6029
6097
  /**
6030
6098
  * 获取分钟
6031
6099
  * @date 2022年5月7日
6032
6100
  * @param {Date|string} [date] - 日期对象或日期字符串
6033
6101
  * @returns {number} 分钟数(0-59)
6034
- */
6035
- var getMinute = function getMinute(date) {
6036
- if (!date) {
6037
- return new Date().getMinutes();
6038
- }
6039
- if (typeof date === 'string') {
6040
- date = new Date(date);
6041
- }
6042
- return date.getMinutes();
6043
- };
6044
-
6102
+ */
6103
+ const getMinute = function (date) {
6104
+ if (!date) {
6105
+ return new Date().getMinutes();
6106
+ }
6107
+ if (typeof date === 'string') {
6108
+ date = new Date(date);
6109
+ }
6110
+ return date.getMinutes();
6111
+ };
6112
+
6045
6113
  /**
6046
6114
  * 获取月份
6047
6115
  * @date 2022年5月7日
6048
6116
  * @param {Date|string} [date] - 日期对象或日期字符串
6049
6117
  * @returns {number} 月份数(1-12)
6050
- */
6051
- var getMonth = function getMonth(date) {
6052
- if (!date) {
6053
- return new Date().getMonth() + 1;
6054
- }
6055
- if (typeof date === 'string') {
6056
- date = new Date(date);
6057
- }
6058
- return date.getMonth() + 1;
6059
- };
6060
-
6118
+ */
6119
+ const getMonth = function (date) {
6120
+ if (!date) {
6121
+ return new Date().getMonth() + 1;
6122
+ }
6123
+ if (typeof date === 'string') {
6124
+ date = new Date(date);
6125
+ }
6126
+ return date.getMonth() + 1;
6127
+ };
6128
+
6061
6129
  /**
6062
6130
  * 获取秒
6063
6131
  * @date 2022年5月7日
6064
6132
  * @param {Date|string} [date] - 日期对象或日期字符串
6065
6133
  * @returns {number} 秒数(0-59)
6066
- */
6067
- var getSecond = function getSecond(date) {
6068
- if (!date) {
6069
- return new Date().getSeconds();
6070
- }
6071
- if (typeof date === 'string') {
6072
- date = new Date(date);
6073
- }
6074
- return date.getSeconds();
6075
- };
6076
-
6134
+ */
6135
+ const getSecond = function (date) {
6136
+ if (!date) {
6137
+ return new Date().getSeconds();
6138
+ }
6139
+ if (typeof date === 'string') {
6140
+ date = new Date(date);
6141
+ }
6142
+ return date.getSeconds();
6143
+ };
6144
+
6077
6145
  /**
6078
6146
  * 获取星期几
6079
6147
  * @date 2022年5月7日
6080
6148
  * @param {Date|string} [date] - 日期对象或日期字符串
6081
6149
  * @returns {number} 星期几(0-6,0表示星期日)
6082
- */
6083
- var getWeekday = function getWeekday(date) {
6084
- if (!date) {
6085
- return new Date().getDay();
6086
- }
6087
- if (typeof date === 'string') {
6088
- date = new Date(date);
6089
- }
6090
- return date.getDay();
6091
- };
6092
-
6150
+ */
6151
+ const getWeekday = function (date) {
6152
+ if (!date) {
6153
+ return new Date().getDay();
6154
+ }
6155
+ if (typeof date === 'string') {
6156
+ date = new Date(date);
6157
+ }
6158
+ return date.getDay();
6159
+ };
6160
+
6161
+
6093
6162
  /**
6094
6163
  * @desc 获取上午/下午/晚上
6095
6164
  * @author huangbo
6096
6165
  * @date 2022年5月7日
6097
6166
  * @param {String} [time] - 时间
6098
- **/
6099
- var timeCycle = function timeCycle(time) {
6100
- var hour = 0;
6101
- if (!time) {
6102
- hour = new Date().getHours();
6103
- } else if (typeof time === 'string') {
6104
- // 从时间字符串中提取小时
6105
- var match = time.match(/^(\d{1,2})/);
6106
- if (match) {
6107
- hour = parseInt(match[1], 10);
6108
- }
6109
- } else if (typeof time === 'number') {
6110
- hour = time;
6111
- }
6112
- // 判断时间段
6113
- if (hour >= 5 && hour < 12) {
6114
- return '上午';
6115
- } else if (hour >= 12 && hour < 18) {
6116
- return '下午';
6117
- } else {
6118
- return '晚上';
6119
- }
6167
+ **/
6168
+ const timeCycle = function (time) {
6169
+ let hour = 0;
6170
+ if (!time) {
6171
+ hour = new Date().getHours();
6172
+ } else if (typeof time === 'string') {
6173
+ // 从时间字符串中提取小时
6174
+ const match = time.match(/^(\d{1,2})/);
6175
+ if (match) {
6176
+ hour = parseInt(match[1], 10);
6177
+ }
6178
+ } else if (typeof time === 'number') {
6179
+ hour = time;
6180
+ }
6181
+ // 判断时间段
6182
+ if (hour >= 5 && hour < 12) {
6183
+ return '上午';
6184
+ } else if (hour >= 12 && hour < 18) {
6185
+ return '下午';
6186
+ } else {
6187
+ return '晚上';
6188
+ }
6120
6189
  };
6121
6190
 
6122
6191
  /***/ }),