@cloudbase/weda-ui 0.2.15 → 1.0.21

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 (250) hide show
  1. package/README.md +41 -169
  2. package/package.json +28 -15
  3. package/src/configs/components/calendar.json +78 -0
  4. package/src/configs/components/carousel.json +273 -0
  5. package/src/configs/components/chart/bar.json +724 -0
  6. package/src/configs/components/chart/line.json +679 -0
  7. package/src/configs/components/chart/pie.json +497 -0
  8. package/src/configs/components/chart/statisticsCard.json +379 -0
  9. package/src/configs/components/container.json +7 -2
  10. package/src/configs/components/dataView.json +154 -0
  11. package/src/configs/components/form/checkbox.json +97 -5
  12. package/src/configs/components/form/location.json +152 -0
  13. package/src/configs/components/form/radio.json +96 -4
  14. package/src/configs/components/form/select.json +245 -11
  15. package/src/configs/components/form/uploaderFile.json +2 -1
  16. package/src/configs/components/graphicCard.json +410 -0
  17. package/src/configs/components/image.json +7 -2
  18. package/src/configs/components/link.json +20 -4
  19. package/src/configs/components/listView.json +277 -0
  20. package/src/configs/components/modal.json +37 -5
  21. package/src/configs/components/navLayout.json +362 -0
  22. package/src/configs/components/navigationBar.json +59 -0
  23. package/src/configs/components/richtextview.json +4 -1
  24. package/src/configs/components/scrollVeiw.json +74 -22
  25. package/src/configs/components/swiper.json +6 -3
  26. package/src/configs/components/tabs.json +51 -8
  27. package/src/configs/components/text.json +33 -25
  28. package/src/configs/components/wxOpenApi/phone.json +141 -0
  29. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  30. package/src/configs/components/wxOpenApi/share.json +167 -0
  31. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  32. package/src/configs/index.js +34 -0
  33. package/src/mp/components/button/index.js +12 -13
  34. package/src/mp/components/button/index.wxml +1 -1
  35. package/src/mp/components/calendar/arrowright--line.svg +11 -0
  36. package/src/mp/components/calendar/index.js +238 -0
  37. package/src/mp/components/calendar/index.json +4 -0
  38. package/src/mp/components/calendar/index.wxml +37 -0
  39. package/src/mp/components/calendar/index.wxss +178 -0
  40. package/src/mp/components/carousel/index.js +88 -0
  41. package/src/mp/components/carousel/index.json +7 -0
  42. package/src/mp/components/carousel/index.wxml +6 -0
  43. package/src/mp/components/chart/bar/index.js +258 -0
  44. package/src/mp/components/chart/bar/index.json +6 -0
  45. package/src/mp/components/chart/bar/index.wxml +3 -0
  46. package/src/mp/components/chart/bar/index.wxss +9 -0
  47. package/src/mp/components/chart/common/config/bar.js +50 -0
  48. package/src/mp/components/chart/common/config/global.js +16 -0
  49. package/src/mp/components/chart/common/config/line.js +48 -0
  50. package/src/mp/components/chart/common/config/pie.js +36 -0
  51. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  52. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  53. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  54. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  55. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  56. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  57. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  58. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  59. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  60. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  61. package/src/mp/components/chart/line/index.js +247 -0
  62. package/src/mp/components/chart/line/index.json +6 -0
  63. package/src/mp/components/chart/line/index.wxml +3 -0
  64. package/src/mp/components/chart/line/index.wxss +9 -0
  65. package/src/mp/components/chart/pie/index.js +182 -0
  66. package/src/mp/components/chart/pie/index.json +6 -0
  67. package/src/mp/components/chart/pie/index.wxml +4 -0
  68. package/src/mp/components/chart/pie/index.wxss +9 -0
  69. package/src/mp/components/chart/statisticsCard/index.js +253 -0
  70. package/src/mp/components/chart/statisticsCard/index.json +4 -0
  71. package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
  72. package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
  73. package/src/mp/components/dataView/index.js +34 -0
  74. package/src/mp/components/dataView/index.json +7 -0
  75. package/src/mp/components/dataView/index.wxml +15 -0
  76. package/src/mp/components/dataView/index.wxss +0 -0
  77. package/src/mp/components/form/checkbox/index.js +41 -2
  78. package/src/mp/components/form/checkbox/index.wxml +1 -1
  79. package/src/mp/components/form/input/index.js +1 -1
  80. package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
  81. package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
  82. package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
  83. package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
  84. package/src/mp/components/form/location/index.js +382 -0
  85. package/src/mp/components/form/location/index.json +6 -0
  86. package/src/mp/components/form/location/index.wxml +25 -0
  87. package/src/mp/components/form/location/index.wxss +91 -0
  88. package/src/mp/components/form/radio/index.js +38 -0
  89. package/src/mp/components/form/select/index.js +360 -40
  90. package/src/mp/components/form/select/index.wxml +21 -6
  91. package/src/mp/components/form/select/region/index.js +98 -0
  92. package/src/mp/components/form/textarea/index.wxml +6 -5
  93. package/src/mp/components/form/uploader/index.js +84 -48
  94. package/src/mp/components/form/uploader/index.wxml +15 -3
  95. package/src/mp/components/form/uploaderFile/index.js +106 -27
  96. package/src/mp/components/graphicCard/chevron-right.svg +3 -0
  97. package/src/mp/components/graphicCard/index.js +203 -0
  98. package/src/mp/components/graphicCard/index.json +4 -0
  99. package/src/mp/components/graphicCard/index.wxml +29 -0
  100. package/src/mp/components/graphicCard/index.wxss +157 -0
  101. package/src/mp/components/image/index.js +0 -1
  102. package/src/mp/components/listView/arrow-right-line.svg +3 -0
  103. package/src/mp/components/listView/index.js +285 -0
  104. package/src/mp/components/listView/index.json +4 -0
  105. package/src/mp/components/listView/index.wxml +40 -0
  106. package/src/mp/components/listView/index.wxss +155 -0
  107. package/src/mp/components/listView/more-line.svg +3 -0
  108. package/src/mp/components/navLayout/index.js +123 -0
  109. package/src/mp/components/navLayout/index.json +7 -0
  110. package/src/mp/components/navLayout/index.wxml +25 -0
  111. package/src/mp/components/navLayout/index.wxss +1193 -0
  112. package/src/mp/components/navigationBar/index.js +193 -0
  113. package/src/mp/components/navigationBar/index.json +6 -0
  114. package/src/mp/components/navigationBar/index.wxml +88 -0
  115. package/src/mp/components/navigationBar/index.wxss +1257 -0
  116. package/src/mp/components/swiper/index.wxml +2 -0
  117. package/src/mp/components/tabs/index.js +7 -2
  118. package/src/mp/components/tabs/index.wxml +2 -1
  119. package/src/mp/components/text/index.js +0 -25
  120. package/src/mp/components/text/index.wxml +3 -3
  121. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  122. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  123. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  124. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  125. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  126. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  127. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  128. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  129. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  130. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  131. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  132. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  133. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  134. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  135. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  136. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  137. package/src/mp/index.json +18 -2
  138. package/src/mp/style/weda-ui.wxss +2 -0
  139. package/src/mp/utils/debounce.js +133 -0
  140. package/src/mp/utils/destr.js +48 -0
  141. package/src/mp/utils/dr_square_point.js +25 -0
  142. package/src/mp/utils/platform.js +25 -0
  143. package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
  144. package/src/mp/utils/spark-md5.js +776 -0
  145. package/src/mp/utils/tcb.js +62 -0
  146. package/src/setupTests.js +2 -1
  147. package/src/web/components/button/index.css +8 -1
  148. package/src/web/components/button/index.tsx +3 -2
  149. package/src/web/components/calendar/index.css +382 -0
  150. package/src/web/components/calendar/index.jsx +312 -0
  151. package/src/web/components/calendar/util.js +90 -0
  152. package/src/web/components/carousel/index.css +119 -0
  153. package/src/web/components/carousel/index.tsx +417 -0
  154. package/src/web/components/chart/bar/index.tsx +140 -0
  155. package/src/web/components/chart/common/config/bar.js +49 -0
  156. package/src/web/components/chart/common/config/global.js +16 -0
  157. package/src/web/components/chart/common/config/line.js +50 -0
  158. package/src/web/components/chart/common/config/pie.js +37 -0
  159. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  160. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  161. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  162. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  163. package/src/web/components/chart/common/core/type.ts +34 -0
  164. package/src/web/components/chart/common/echart.css +106 -0
  165. package/src/web/components/chart/common/echarts.ts +33 -0
  166. package/src/web/components/chart/common/useChart.tsx +69 -0
  167. package/src/web/components/chart/line/index.tsx +136 -0
  168. package/src/web/components/chart/pie/index.tsx +99 -0
  169. package/src/web/components/chart/statisticsCard/index.css +62 -0
  170. package/src/web/components/chart/statisticsCard/index.tsx +307 -0
  171. package/src/web/components/chart/statisticsCard/interface.ts +14 -0
  172. package/src/web/components/dataView/index.tsx +20 -0
  173. package/src/web/components/dataView/interface.ts +6 -0
  174. package/src/web/components/form/checkbox/index.tsx +55 -23
  175. package/src/web/components/form/location/common/mapChoose.css +178 -0
  176. package/src/web/components/form/location/common/mapChoose.jsx +343 -0
  177. package/src/web/components/form/location/common/mapView.jsx +190 -0
  178. package/src/web/components/form/location/common/propsConfig.js +54 -0
  179. package/src/web/components/form/location/common/selectModal.css +44 -0
  180. package/src/web/components/form/location/common/selectModal.jsx +82 -0
  181. package/src/web/components/form/location/common/useLocationInfo.js +100 -0
  182. package/src/web/components/form/location/components/LocationH5/index.css +243 -0
  183. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
  184. package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
  185. package/src/web/components/form/location/components/LocationPC/index.css +44 -0
  186. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
  187. package/src/web/components/form/location/constants.js +4 -0
  188. package/src/web/components/form/location/index.css +0 -0
  189. package/src/web/components/form/location/index.jsx +25 -0
  190. package/src/web/components/form/radio/index.tsx +84 -53
  191. package/src/web/components/form/select/h5.tsx +389 -71
  192. package/src/web/components/form/select/index.css +10 -0
  193. package/src/web/components/form/select/index.tsx +404 -144
  194. package/src/web/components/form/select/region/index.ts +122 -31
  195. package/src/web/components/form/select/time.jsx +90 -0
  196. package/src/web/components/form/select/year.tsx +170 -0
  197. package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
  198. package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
  199. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
  200. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
  201. package/src/web/components/graphicCard/index.css +159 -0
  202. package/src/web/components/graphicCard/index.tsx +310 -0
  203. package/src/web/components/image/image.tsx +1 -2
  204. package/src/web/components/image/index.tsx +1 -1
  205. package/src/web/components/index.js +24 -2
  206. package/src/web/components/link/index.tsx +6 -3
  207. package/src/web/components/listView/arrow-right-line.svg +3 -0
  208. package/src/web/components/listView/index.css +143 -0
  209. package/src/web/components/listView/index.tsx +359 -0
  210. package/src/web/components/listView/interface.ts +98 -0
  211. package/src/web/components/modal/index.tsx +3 -1
  212. package/src/web/components/navLayout/index.css +332 -0
  213. package/src/web/components/navLayout/index.tsx +247 -0
  214. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  215. package/src/web/components/navigationBar/common.tsx +198 -0
  216. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  217. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  218. package/src/web/components/navigationBar/index.css +762 -0
  219. package/src/web/components/navigationBar/index.tsx +231 -0
  220. package/src/web/components/navigationBar/type.d.ts +111 -0
  221. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  222. package/src/web/components/phone/index.css +0 -0
  223. package/src/web/components/phone/index.tsx +22 -0
  224. package/src/web/components/phoneCode/index.css +0 -0
  225. package/src/web/components/phoneCode/index.tsx +22 -0
  226. package/src/web/components/richTextView/index.tsx +3 -5
  227. package/src/web/components/share/index.css +0 -0
  228. package/src/web/components/share/index.tsx +38 -0
  229. package/src/web/components/tabs/index.tsx +4 -2
  230. package/src/web/components/tabs/tabs.h5.tsx +50 -37
  231. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  232. package/src/web/components/text/index.tsx +6 -14
  233. package/src/web/components/uploaderFileView/index.css +9 -9
  234. package/src/web/components/uploaderFileView/index.jsx +32 -23
  235. package/src/web/components/userInfo/index.css +0 -0
  236. package/src/web/components/userInfo/index.tsx +30 -0
  237. package/src/web/types.d.ts +15 -14
  238. package/src/web/utils/debounce.js +98 -0
  239. package/src/web/utils/platform.js +40 -0
  240. package/src/web/utils/tcb.js +49 -0
  241. package/src/web/utils/tmap.js +4 -0
  242. package/src/web/weda-ui.css +2 -0
  243. package/CHANGELOG.md +0 -240
  244. package/src/.DS_Store +0 -0
  245. package/src/configs/.DS_Store +0 -0
  246. package/src/mp/.gitignore +0 -10
  247. package/src/web/.DS_Store +0 -0
  248. package/src/web/components/form/select/region/cities.ts +0 -2410
  249. package/src/web/components/form/select/region/provinces.ts +0 -240
  250. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,22 @@
1
+ @import '../../../style/weda-ui.wxss';
2
+
3
+ .weui-btn.weui-btn_primary:not(.weui-btn_disabled):active {
4
+ background-color: var(--weui-TAG-TEXT-BLUE);
5
+ }
6
+
7
+ .weui-btn.weui-btn_primary.weui-btn_wechat:not(.weui-btn_disabled):active {
8
+ background-color: var(--weui-TAG-TEXT-GREEN);
9
+ }
10
+
11
+ .weui-btn.weui-btn_primary.weui-btn_wechat {
12
+ background-color: var(--weui-WECHAT);
13
+ }
14
+
15
+ .weda-ui.weui-btn.weui-btn_large {
16
+ font-size: large;
17
+ display: block;
18
+ padding-left: 14rpx;
19
+ padding-right: 14rpx;
20
+ text-align: center;
21
+ width: 100%;
22
+ }
package/src/mp/index.json CHANGED
@@ -9,6 +9,7 @@
9
9
  "Checkbox": "components/form/checkbox/index",
10
10
  "Switch": "components/form/switch/index",
11
11
  "Input": "components/form/input/index",
12
+ "Location": "components/form/location/index",
12
13
  "Textarea": "components/form/textarea/index",
13
14
  "Select": "components/form/select/index",
14
15
  "Uploader": "components/form/uploader/index",
@@ -22,13 +23,28 @@
22
23
  "type": "native",
23
24
  "path": "swiper"
24
25
  },
26
+ "Carousel": "components/carousel/index",
25
27
  "ScrollView": "components/scrollView/index",
26
28
  "Tips": "components/form/tips/index",
27
29
  "RichTextView": "components/richText/index",
28
- "Tabs": "components/tabs/index"
30
+ "Tabs": "components/tabs/index",
31
+ "ListView": "components/listView/index",
32
+ "NavigationBar": "components/navigationBar/index",
33
+ "DataView": "components/dataView/index",
34
+ "Calendar": "components/calendar/index",
35
+ "NavLayout": "components/navLayout/index",
36
+ "Line": "components/chart/line/index",
37
+ "Bar": "components/chart/bar/index",
38
+ "Pie": "components/chart/pie/index",
39
+ "StatisticsCard": "components/chart/statisticsCard/index",
40
+ "GraphicCard": "components/graphicCard/index",
41
+ "UserInfo": "components/wxOpenApi/userInfo/index",
42
+ "Phone": "components/wxOpenApi/phone/index",
43
+ "PhoneCode": "components/wxOpenApi/phoneCode/index",
44
+ "Share": "components/wxOpenApi/share/index"
29
45
  },
30
46
  "actions": {
31
47
  "showToast": "actions/showToast/index",
32
48
  "showModal": "actions/showModal/index"
33
49
  }
34
- }
50
+ }
@@ -6,6 +6,8 @@ page .weda-ui {
6
6
  --weui-BRAND: #006eff;
7
7
  --weui-TAG-TEXT-BLUE: #0067eb;
8
8
  --weui-BTN-DEFAULT-COLOR: #576b95;
9
+ --weui-WECHAT: #07c160;
10
+ --weui-TAG-TEXT-GREEN: #06ae56;
9
11
  --weui-BG-2: rgba(255, 255, 255, 0);
10
12
  }
11
13
 
@@ -0,0 +1,133 @@
1
+ function isObject(value) {
2
+ const type = typeof value;
3
+ return value != null && (type === 'object' || type === 'function');
4
+ }
5
+
6
+ function debounce(func, wait, options) {
7
+ let lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
8
+
9
+ let lastInvokeTime = 0;
10
+ let leading = false;
11
+ let maxing = false;
12
+ let trailing = true;
13
+
14
+ // 初始化
15
+ if (typeof func !== 'function') {
16
+ throw new TypeError('Expected a function');
17
+ }
18
+ wait = +wait || 0;
19
+ if (isObject(options)) {
20
+ leading = !!options.leading;
21
+ maxing = 'maxWait' in options;
22
+ maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait;
23
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
24
+ }
25
+
26
+ // 调用func
27
+ function invokeFunc(time) {
28
+ const args = lastArgs;
29
+ const thisArg = lastThis;
30
+
31
+ lastArgs = lastThis = undefined;
32
+ lastInvokeTime = time;
33
+ result = func.apply(thisArg, args);
34
+ return result;
35
+ }
36
+
37
+ // 启动延时
38
+ function startTimer(pendingFunc, wait) {
39
+ return setTimeout(pendingFunc, wait);
40
+ }
41
+
42
+ // 延时开始前
43
+ function leadingEdge(time) {
44
+ lastInvokeTime = time;
45
+ // 启动延时
46
+ timerId = startTimer(timerExpired, wait);
47
+ // 如果是leading模式,延时前调用func
48
+ return leading ? invokeFunc(time) : result;
49
+ }
50
+
51
+ //计算剩余的延时时间:
52
+ //1. 不存在maxWait:(上一次debouncedFunc调用后)延时不能超过wait
53
+ //2. 存在maxWait:func调用不能被延时超过maxWait
54
+ //根据这两种情况计算出最短时间
55
+ function remainingWait(time) {
56
+ const timeSinceLastCall = time - lastCallTime;
57
+ const timeSinceLastInvoke = time - lastInvokeTime;
58
+ const timeWaiting = wait - timeSinceLastCall;
59
+
60
+ return maxing
61
+ ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)
62
+ : timeWaiting;
63
+ }
64
+
65
+ //判断当前时间是否能调用func:
66
+ //1.首次调用debouncedFunc
67
+ //2.距离上一次debouncedFunc调用后已延迟wait毫秒
68
+ //3.func调用总延迟达到maxWait毫秒
69
+ //4.系统时间倒退
70
+ function shouldInvoke(time) {
71
+ const timeSinceLastCall = time - lastCallTime;
72
+ const timeSinceLastInvoke = time - lastInvokeTime;
73
+ return (
74
+ lastCallTime === undefined ||
75
+ timeSinceLastCall >= wait ||
76
+ timeSinceLastCall < 0 ||
77
+ (maxing && timeSinceLastInvoke >= maxWait)
78
+ );
79
+ }
80
+
81
+ // 延时器回调
82
+ function timerExpired() {
83
+ const time = Date.now();
84
+ // 如果满足时间条件,结束延时
85
+ if (shouldInvoke(time)) {
86
+ return trailingEdge(time);
87
+ }
88
+ // 没满足时间条件,计算剩余等待时间,继续延时
89
+ timerId = startTimer(timerExpired, remainingWait(time));
90
+ }
91
+
92
+ //延时结束后
93
+ function trailingEdge(time) {
94
+ timerId = undefined;
95
+ //如果是trailing模式,调用func
96
+ if (trailing && lastArgs) {
97
+ return invokeFunc(time);
98
+ }
99
+ lastArgs = lastThis = undefined;
100
+ return result;
101
+ }
102
+
103
+ //debouncedFunc
104
+ function debounced(...args) {
105
+ const time = Date.now();
106
+ const isInvoking = shouldInvoke(time);
107
+
108
+ lastArgs = args;
109
+ lastThis = this;
110
+ lastCallTime = time;
111
+
112
+ if (isInvoking) {
113
+ //timerId不存在有两种原因:
114
+ //1. 首次调用
115
+ //2. 上次延时调用结束
116
+ if (timerId === undefined) {
117
+ return leadingEdge(lastCallTime);
118
+ }
119
+ // 存在func调用最长延时限制时,执行func并启动下一次延时,可实现throttle
120
+ if (maxing) {
121
+ timerId = startTimer(timerExpired, wait);
122
+ return invokeFunc(lastCallTime);
123
+ }
124
+ }
125
+ if (timerId === undefined) {
126
+ timerId = startTimer(timerExpired, wait);
127
+ }
128
+ return result;
129
+ }
130
+ return debounced;
131
+ }
132
+
133
+ export default debounce;
@@ -0,0 +1,48 @@
1
+ // https://github.com/unjs/destr/blob/2f6612533dd798d2ff5786274f2244558f86d09c/src/index.ts
2
+ // https://github.com/fastify/secure-json-parse
3
+ // https://github.com/hapijs/bourne
4
+ const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
5
+ const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
6
+ const JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/;
7
+ function jsonParseTransform(key, value) {
8
+ if (key === '__proto__' || key === 'constructor') {
9
+ return;
10
+ }
11
+ return value;
12
+ }
13
+ export default function destr(val) {
14
+ if (typeof val !== 'string') {
15
+ return val;
16
+ }
17
+ const _lval = val.toLowerCase();
18
+ if (_lval === 'true') {
19
+ return true;
20
+ }
21
+ if (_lval === 'false') {
22
+ return false;
23
+ }
24
+ if (_lval === 'null') {
25
+ return null;
26
+ }
27
+ if (_lval === 'nan') {
28
+ return NaN;
29
+ }
30
+ if (_lval === 'infinity') {
31
+ return Infinity;
32
+ }
33
+ if (_lval === 'undefined') {
34
+ return undefined;
35
+ }
36
+ if (!JsonSigRx.test(val)) {
37
+ return val;
38
+ }
39
+ try {
40
+ if (suspectProtoRx.test(val) || suspectConstructorRx.test(val)) {
41
+ return JSON.parse(val, jsonParseTransform);
42
+ }
43
+ return JSON.parse(val);
44
+ }
45
+ catch (_e) {
46
+ return val;
47
+ }
48
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ *计算某个经纬度的周围某段距离的正方形的四个点
3
+ *
4
+ *@param lng float 经度
5
+ *@param lat float 纬度
6
+ *@param distance float 该点所在圆的半径,该圆与此正方形内切,默认值为0.5千米
7
+ *@return array 正方形的四个点的经纬度坐标
8
+ */
9
+
10
+ function dr_square_point($lng, $lat, $distance = 0.5) {
11
+ $distance = $distance ? $distance : 1;
12
+ let $r = 6371; //地球半径,平均半径为6371km
13
+ let $dlng = 2 * Math.asin(Math.sin($distance / (2 * $r)) / Math.cos($lat * (Math.PI / 180)));
14
+ $dlng = $dlng * (180 / Math.PI);
15
+ let $dlat = $distance / $r;
16
+ $dlat = $dlat * (180 / Math.PI);
17
+ return {
18
+ 'leftTop': [$lat + $dlat, $lng - $dlng],
19
+ 'leftBottom': [$lat - $dlat, $lng - $dlng],
20
+ 'rightBottom': [$lat - $dlat, $lng + $dlng],
21
+ 'rightTop': [$lat + $dlat, $lng + $dlng],
22
+ };
23
+ }
24
+
25
+ export default dr_square_point;
@@ -18,3 +18,28 @@ export const transSize = (size) => {
18
18
  const g = getBig(m);
19
19
  return `${g}G`;
20
20
  };
21
+
22
+ /**
23
+ * 判断是否是url
24
+ */
25
+ const reg =
26
+ // eslint-disable-next-line no-useless-escape
27
+ /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
28
+
29
+ export const isUrl = (path) => reg.test(path);
30
+
31
+ /**
32
+ * 生成随机数
33
+ */
34
+ export const uuid = () => {
35
+ var s = [];
36
+ var hexDigits = '0123456789abcdef';
37
+ for (var i = 0; i < 36; i++) {
38
+ s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
39
+ }
40
+ s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
41
+ s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
42
+ s[8] = s[13] = s[18] = s[23] = '-';
43
+ var uuid = s.join('');
44
+ return uuid;
45
+ };