taro-uno-ui 1.0.1 → 1.0.2

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 (414) hide show
  1. package/README.md +67 -30
  2. package/dist/js/{index-CDFsvu80.js → index-QpKiGsEQ.js} +39026 -28023
  3. package/dist/js/index-QpKiGsEQ.js.map +1 -0
  4. package/dist/js/{index-JffnTUrv.js → index-nnTHNhwl.js} +38743 -27720
  5. package/dist/js/index-nnTHNhwl.js.map +1 -0
  6. package/package.json +4 -4
  7. package/dist/js/index-CDFsvu80.js.map +0 -1
  8. package/dist/js/index-DFdcksbe.js +0 -1165
  9. package/dist/js/index-DFdcksbe.js.map +0 -1
  10. package/dist/js/index-DXRIkWX1.js +0 -1148
  11. package/dist/js/index-DXRIkWX1.js.map +0 -1
  12. package/dist/js/index-JffnTUrv.js.map +0 -1
  13. package/dist/utils/http/request.d.ts +0 -280
  14. package/src/app.config.ts +0 -55
  15. package/src/app.scss +0 -508
  16. package/src/app.tsx +0 -44
  17. package/src/components/basic/Button/Button.styles.ts +0 -130
  18. package/src/components/basic/Button/Button.test.tsx +0 -154
  19. package/src/components/basic/Button/Button.tsx +0 -133
  20. package/src/components/basic/Button/Button.types.ts +0 -81
  21. package/src/components/basic/Button/index.tsx +0 -6
  22. package/src/components/basic/Divider/Divider.styles.ts +0 -488
  23. package/src/components/basic/Divider/Divider.test.tsx +0 -551
  24. package/src/components/basic/Divider/Divider.tsx +0 -392
  25. package/src/components/basic/Divider/Divider.types.ts +0 -261
  26. package/src/components/basic/Divider/index.tsx +0 -25
  27. package/src/components/basic/Icon/Icon.data.ts +0 -474
  28. package/src/components/basic/Icon/Icon.styles.ts +0 -359
  29. package/src/components/basic/Icon/Icon.test.tsx +0 -357
  30. package/src/components/basic/Icon/Icon.tsx +0 -167
  31. package/src/components/basic/Icon/Icon.types.ts +0 -210
  32. package/src/components/basic/Icon/IconManager.ts +0 -229
  33. package/src/components/basic/Icon/index.tsx +0 -22
  34. package/src/components/basic/Text/Text.styles.ts +0 -500
  35. package/src/components/basic/Text/Text.test.tsx +0 -299
  36. package/src/components/basic/Text/Text.tsx +0 -340
  37. package/src/components/basic/Text/Text.types.ts +0 -329
  38. package/src/components/basic/Text/index.tsx +0 -27
  39. package/src/components/basic/Typography/Typography.styles.ts +0 -347
  40. package/src/components/basic/Typography/Typography.tsx +0 -207
  41. package/src/components/basic/Typography/Typography.types.ts +0 -296
  42. package/src/components/basic/Typography/index.tsx +0 -14
  43. package/src/components/basic/Video/Video.styles.ts +0 -777
  44. package/src/components/basic/Video/Video.test.tsx +0 -490
  45. package/src/components/basic/Video/Video.tsx +0 -1468
  46. package/src/components/basic/Video/Video.types.ts +0 -500
  47. package/src/components/basic/Video/index.tsx +0 -26
  48. package/src/components/basic/index.tsx +0 -300
  49. package/src/components/common/ErrorBoundary.tsx +0 -87
  50. package/src/components/common/LazyComponent.tsx +0 -247
  51. package/src/components/common/ResponsiveContainer.tsx +0 -93
  52. package/src/components/common/ResponsiveGrid.tsx +0 -183
  53. package/src/components/common/SecurityProvider.tsx +0 -98
  54. package/src/components/common/ThemeProvider.tsx +0 -115
  55. package/src/components/common/VirtualList.tsx +0 -350
  56. package/src/components/common/__tests__/ErrorBoundary.test.tsx +0 -249
  57. package/src/components/common/index.tsx +0 -32
  58. package/src/components/display/Avatar/Avatar.styles.ts +0 -62
  59. package/src/components/display/Avatar/Avatar.test.tsx +0 -390
  60. package/src/components/display/Avatar/Avatar.tsx +0 -66
  61. package/src/components/display/Avatar/Avatar.types.ts +0 -40
  62. package/src/components/display/Avatar/index.ts +0 -3
  63. package/src/components/display/Badge/Badge.tsx +0 -29
  64. package/src/components/display/Badge/Badge.types.ts +0 -29
  65. package/src/components/display/Badge/index.ts +0 -2
  66. package/src/components/display/Calendar/Calendar.styles.ts +0 -255
  67. package/src/components/display/Calendar/Calendar.test.tsx +0 -42
  68. package/src/components/display/Calendar/Calendar.tsx +0 -358
  69. package/src/components/display/Calendar/Calendar.types.ts +0 -91
  70. package/src/components/display/Calendar/index.ts +0 -3
  71. package/src/components/display/Card/Card.styles.ts +0 -89
  72. package/src/components/display/Card/Card.test.tsx +0 -182
  73. package/src/components/display/Card/Card.tsx +0 -135
  74. package/src/components/display/Card/Card.types.ts +0 -55
  75. package/src/components/display/Card/index.ts +0 -3
  76. package/src/components/display/Carousel/Carousel.styles.ts +0 -206
  77. package/src/components/display/Carousel/Carousel.tsx +0 -290
  78. package/src/components/display/Carousel/Carousel.types.ts +0 -57
  79. package/src/components/display/Carousel/index.ts +0 -3
  80. package/src/components/display/List/List.styles.ts +0 -79
  81. package/src/components/display/List/List.tsx +0 -114
  82. package/src/components/display/List/List.types.ts +0 -68
  83. package/src/components/display/List/index.ts +0 -3
  84. package/src/components/display/Rate/Rate.styles.ts +0 -254
  85. package/src/components/display/Rate/Rate.tsx +0 -324
  86. package/src/components/display/Rate/Rate.types.ts +0 -112
  87. package/src/components/display/Rate/index.ts +0 -20
  88. package/src/components/display/Table/Table.styles.ts +0 -269
  89. package/src/components/display/Table/Table.test.tsx +0 -345
  90. package/src/components/display/Table/Table.tsx +0 -426
  91. package/src/components/display/Table/Table.types.ts +0 -256
  92. package/src/components/display/Table/index.tsx +0 -16
  93. package/src/components/display/Tag/Tag.styles.ts +0 -197
  94. package/src/components/display/Tag/Tag.test.tsx +0 -541
  95. package/src/components/display/Tag/Tag.tsx +0 -139
  96. package/src/components/display/Tag/Tag.types.ts +0 -49
  97. package/src/components/display/Tag/index.ts +0 -3
  98. package/src/components/display/Timeline/Timeline.styles.ts +0 -211
  99. package/src/components/display/Timeline/Timeline.tsx +0 -220
  100. package/src/components/display/Timeline/Timeline.types.ts +0 -56
  101. package/src/components/display/Timeline/index.ts +0 -3
  102. package/src/components/display/index.tsx +0 -147
  103. package/src/components/feedback/Loading/Loading.styles.ts +0 -117
  104. package/src/components/feedback/Loading/Loading.test.tsx +0 -534
  105. package/src/components/feedback/Loading/Loading.tsx +0 -132
  106. package/src/components/feedback/Loading/Loading.types.ts +0 -33
  107. package/src/components/feedback/Loading/index.ts +0 -6
  108. package/src/components/feedback/Message/Message.styles.ts +0 -41
  109. package/src/components/feedback/Message/Message.test.tsx +0 -234
  110. package/src/components/feedback/Message/Message.tsx +0 -96
  111. package/src/components/feedback/Message/Message.types.ts +0 -37
  112. package/src/components/feedback/Message/index.ts +0 -6
  113. package/src/components/feedback/Modal/Modal.styles.ts +0 -21
  114. package/src/components/feedback/Modal/Modal.test.tsx +0 -11
  115. package/src/components/feedback/Modal/Modal.tsx +0 -269
  116. package/src/components/feedback/Modal/Modal.types.ts +0 -151
  117. package/src/components/feedback/Modal/index.tsx +0 -11
  118. package/src/components/feedback/Notification/Notification.styles.ts +0 -453
  119. package/src/components/feedback/Notification/Notification.test.tsx +0 -401
  120. package/src/components/feedback/Notification/Notification.tsx +0 -347
  121. package/src/components/feedback/Notification/Notification.types.ts +0 -339
  122. package/src/components/feedback/Notification/NotificationManager.tsx +0 -405
  123. package/src/components/feedback/Notification/index.ts +0 -40
  124. package/src/components/feedback/Notification/index.tsx +0 -154
  125. package/src/components/feedback/Progress/Progress.styles.ts +0 -469
  126. package/src/components/feedback/Progress/Progress.test.simple.tsx +0 -14
  127. package/src/components/feedback/Progress/Progress.test.tsx +0 -312
  128. package/src/components/feedback/Progress/Progress.tsx +0 -488
  129. package/src/components/feedback/Progress/Progress.types.ts +0 -163
  130. package/src/components/feedback/Progress/index.ts +0 -3
  131. package/src/components/feedback/Progress/index.tsx +0 -38
  132. package/src/components/feedback/Progress/utils/animation.ts +0 -193
  133. package/src/components/feedback/Progress/utils/index.ts +0 -26
  134. package/src/components/feedback/Progress/utils/progress-calculator.ts +0 -199
  135. package/src/components/feedback/Result/Result.styles.ts +0 -139
  136. package/src/components/feedback/Result/Result.tsx +0 -221
  137. package/src/components/feedback/Result/Result.types.ts +0 -128
  138. package/src/components/feedback/Result/index.tsx +0 -3
  139. package/src/components/feedback/Toast/Toast.styles.ts +0 -17
  140. package/src/components/feedback/Toast/Toast.test.tsx +0 -10
  141. package/src/components/feedback/Toast/Toast.tsx +0 -384
  142. package/src/components/feedback/Toast/Toast.types.ts +0 -86
  143. package/src/components/feedback/Toast/index.tsx +0 -3
  144. package/src/components/feedback/Tooltip/Tooltip.examples.tsx +0 -435
  145. package/src/components/feedback/Tooltip/Tooltip.styles.ts +0 -340
  146. package/src/components/feedback/Tooltip/Tooltip.test.tsx +0 -446
  147. package/src/components/feedback/Tooltip/Tooltip.tsx +0 -302
  148. package/src/components/feedback/Tooltip/Tooltip.types.ts +0 -166
  149. package/src/components/feedback/Tooltip/index.ts +0 -3
  150. package/src/components/feedback/Tooltip/index.tsx +0 -246
  151. package/src/components/feedback/index.tsx +0 -176
  152. package/src/components/form/Cascader/Cascader.styles.ts +0 -526
  153. package/src/components/form/Cascader/Cascader.test.tsx +0 -77
  154. package/src/components/form/Cascader/Cascader.tsx +0 -581
  155. package/src/components/form/Cascader/Cascader.types.ts +0 -581
  156. package/src/components/form/Cascader/hooks/index.ts +0 -3
  157. package/src/components/form/Cascader/hooks/useCascaderFieldNames.ts +0 -19
  158. package/src/components/form/Cascader/hooks/useCascaderOptions.ts +0 -127
  159. package/src/components/form/Cascader/hooks/useCascaderState.ts +0 -139
  160. package/src/components/form/Cascader/index.ts +0 -25
  161. package/src/components/form/Cascader/utils/formatDisplayValue.ts +0 -19
  162. package/src/components/form/Cascader/utils/index.ts +0 -1
  163. package/src/components/form/Checkbox/Checkbox.styles.ts +0 -607
  164. package/src/components/form/Checkbox/Checkbox.test.tsx +0 -1140
  165. package/src/components/form/Checkbox/Checkbox.tsx +0 -489
  166. package/src/components/form/Checkbox/Checkbox.types.ts +0 -472
  167. package/src/components/form/Checkbox/CheckboxGroup.tsx +0 -444
  168. package/src/components/form/Checkbox/index.tsx +0 -27
  169. package/src/components/form/DatePicker/DatePicker.styles.ts +0 -393
  170. package/src/components/form/DatePicker/DatePicker.test.tsx +0 -407
  171. package/src/components/form/DatePicker/DatePicker.tsx +0 -376
  172. package/src/components/form/DatePicker/DatePicker.types.ts +0 -250
  173. package/src/components/form/DatePicker/index.tsx +0 -15
  174. package/src/components/form/Form/Form.styles.ts +0 -357
  175. package/src/components/form/Form/Form.test.tsx +0 -122
  176. package/src/components/form/Form/Form.tsx +0 -257
  177. package/src/components/form/Form/Form.types.ts +0 -422
  178. package/src/components/form/Form/index.tsx +0 -31
  179. package/src/components/form/Form/useFormLogic.ts +0 -497
  180. package/src/components/form/Input/Input.styles.ts +0 -445
  181. package/src/components/form/Input/Input.test.tsx +0 -494
  182. package/src/components/form/Input/Input.tsx +0 -305
  183. package/src/components/form/Input/Input.types.ts +0 -297
  184. package/src/components/form/Input/index.tsx +0 -26
  185. package/src/components/form/Input/useInputLogic.test.ts +0 -82
  186. package/src/components/form/Input/useInputLogic.ts +0 -260
  187. package/src/components/form/InputNumber/InputNumber.styles.ts +0 -716
  188. package/src/components/form/InputNumber/InputNumber.tsx +0 -402
  189. package/src/components/form/InputNumber/InputNumber.types.ts +0 -336
  190. package/src/components/form/InputNumber/components/InputNumberClearButton.tsx +0 -24
  191. package/src/components/form/InputNumber/components/InputNumberControls.tsx +0 -33
  192. package/src/components/form/InputNumber/components/index.ts +0 -2
  193. package/src/components/form/InputNumber/hooks/index.ts +0 -4
  194. package/src/components/form/InputNumber/hooks/useInputNumberState.ts +0 -313
  195. package/src/components/form/InputNumber/hooks/useInputNumberValidation.ts +0 -148
  196. package/src/components/form/InputNumber/index.ts +0 -25
  197. package/src/components/form/Radio/Radio.styles.ts +0 -451
  198. package/src/components/form/Radio/Radio.test.tsx +0 -547
  199. package/src/components/form/Radio/Radio.tsx +0 -277
  200. package/src/components/form/Radio/Radio.types.ts +0 -414
  201. package/src/components/form/Radio/index.tsx +0 -21
  202. package/src/components/form/Select/Select.styles.ts +0 -518
  203. package/src/components/form/Select/Select.test.tsx +0 -648
  204. package/src/components/form/Select/Select.tsx +0 -474
  205. package/src/components/form/Select/Select.types.ts +0 -429
  206. package/src/components/form/Select/index.tsx +0 -30
  207. package/src/components/form/Slider/Slider.styles.ts +0 -139
  208. package/src/components/form/Slider/Slider.test.tsx +0 -553
  209. package/src/components/form/Slider/Slider.tsx +0 -312
  210. package/src/components/form/Slider/Slider.types.ts +0 -110
  211. package/src/components/form/Slider/index.tsx +0 -3
  212. package/src/components/form/Switch/Switch.styles.ts +0 -534
  213. package/src/components/form/Switch/Switch.test.tsx +0 -345
  214. package/src/components/form/Switch/Switch.tsx +0 -458
  215. package/src/components/form/Switch/Switch.types.ts +0 -386
  216. package/src/components/form/Switch/index.tsx +0 -26
  217. package/src/components/form/Textarea/Textarea.styles.ts +0 -592
  218. package/src/components/form/Textarea/Textarea.test.tsx +0 -1075
  219. package/src/components/form/Textarea/Textarea.tsx +0 -608
  220. package/src/components/form/Textarea/Textarea.types.ts +0 -374
  221. package/src/components/form/Textarea/index.tsx +0 -26
  222. package/src/components/form/TimePicker/TimePicker.styles.ts +0 -434
  223. package/src/components/form/TimePicker/TimePicker.test.tsx +0 -306
  224. package/src/components/form/TimePicker/TimePicker.tsx +0 -250
  225. package/src/components/form/TimePicker/TimePicker.types.ts +0 -385
  226. package/src/components/form/TimePicker/index.ts +0 -21
  227. package/src/components/form/Transfer/Transfer.styles.ts +0 -490
  228. package/src/components/form/Transfer/Transfer.test.tsx +0 -316
  229. package/src/components/form/Transfer/Transfer.tsx +0 -414
  230. package/src/components/form/Transfer/Transfer.types.ts +0 -565
  231. package/src/components/form/Transfer/components/TransferItem.tsx +0 -94
  232. package/src/components/form/Transfer/components/TransferList.tsx +0 -298
  233. package/src/components/form/Transfer/components/TransferOperations.tsx +0 -81
  234. package/src/components/form/Transfer/components/TransferPagination.tsx +0 -139
  235. package/src/components/form/Transfer/components/TransferSearch.tsx +0 -85
  236. package/src/components/form/Transfer/components/index.ts +0 -6
  237. package/src/components/form/Transfer/hooks/index.ts +0 -3
  238. package/src/components/form/Transfer/hooks/useTransferData.ts +0 -202
  239. package/src/components/form/Transfer/hooks/useTransferState.ts +0 -120
  240. package/src/components/form/Transfer/index.ts +0 -27
  241. package/src/components/form/Upload/Upload.styles.ts +0 -145
  242. package/src/components/form/Upload/Upload.test.tsx +0 -10
  243. package/src/components/form/Upload/Upload.tsx +0 -498
  244. package/src/components/form/Upload/Upload.types.ts +0 -200
  245. package/src/components/form/Upload/index.tsx +0 -12
  246. package/src/components/form/index.tsx +0 -152
  247. package/src/components/index.tsx +0 -145
  248. package/src/components/layout/Affix/Affix.styles.ts +0 -42
  249. package/src/components/layout/Affix/Affix.test.tsx +0 -10
  250. package/src/components/layout/Affix/Affix.tsx +0 -83
  251. package/src/components/layout/Affix/Affix.types.ts +0 -29
  252. package/src/components/layout/Affix/index.tsx +0 -3
  253. package/src/components/layout/Col/Col.styles.ts +0 -185
  254. package/src/components/layout/Col/Col.test.tsx +0 -537
  255. package/src/components/layout/Col/Col.tsx +0 -97
  256. package/src/components/layout/Col/Col.types.ts +0 -59
  257. package/src/components/layout/Col/index.tsx +0 -3
  258. package/src/components/layout/Container/Container.styles.ts +0 -163
  259. package/src/components/layout/Container/Container.test.tsx +0 -380
  260. package/src/components/layout/Container/Container.tsx +0 -123
  261. package/src/components/layout/Container/Container.types.ts +0 -63
  262. package/src/components/layout/Container/index.tsx +0 -3
  263. package/src/components/layout/Grid/Grid.styles.ts +0 -183
  264. package/src/components/layout/Grid/Grid.test.tsx +0 -637
  265. package/src/components/layout/Grid/Grid.tsx +0 -123
  266. package/src/components/layout/Grid/Grid.types.ts +0 -78
  267. package/src/components/layout/Grid/index.tsx +0 -3
  268. package/src/components/layout/Layout/Content.tsx +0 -30
  269. package/src/components/layout/Layout/Footer.tsx +0 -30
  270. package/src/components/layout/Layout/Header.tsx +0 -30
  271. package/src/components/layout/Layout/Layout.styles.ts +0 -84
  272. package/src/components/layout/Layout/Layout.test.tsx +0 -10
  273. package/src/components/layout/Layout/Layout.tsx +0 -28
  274. package/src/components/layout/Layout/Layout.types.ts +0 -58
  275. package/src/components/layout/Layout/Sider.tsx +0 -44
  276. package/src/components/layout/Layout/index.tsx +0 -22
  277. package/src/components/layout/Row/Row.styles.ts +0 -159
  278. package/src/components/layout/Row/Row.test.tsx +0 -467
  279. package/src/components/layout/Row/Row.tsx +0 -111
  280. package/src/components/layout/Row/Row.types.ts +0 -60
  281. package/src/components/layout/Row/index.tsx +0 -3
  282. package/src/components/layout/Space/Space.styles.ts +0 -255
  283. package/src/components/layout/Space/Space.test.tsx +0 -682
  284. package/src/components/layout/Space/Space.tsx +0 -203
  285. package/src/components/layout/Space/Space.types.ts +0 -92
  286. package/src/components/layout/Space/index.tsx +0 -12
  287. package/src/components/layout/index.tsx +0 -78
  288. package/src/components/navigation/Menu/Menu.constants.ts +0 -69
  289. package/src/components/navigation/Menu/Menu.stories.tsx +0 -107
  290. package/src/components/navigation/Menu/Menu.styles.ts +0 -767
  291. package/src/components/navigation/Menu/Menu.tsx +0 -352
  292. package/src/components/navigation/Menu/Menu.types.ts +0 -231
  293. package/src/components/navigation/Menu/Menu.utils.ts +0 -187
  294. package/src/components/navigation/Menu/MenuItem.tsx +0 -124
  295. package/src/components/navigation/Menu/SubMenu.tsx +0 -150
  296. package/src/components/navigation/Menu/index.tsx +0 -59
  297. package/src/components/navigation/NavBar/NavBar.styles.ts +0 -129
  298. package/src/components/navigation/NavBar/NavBar.test.tsx +0 -287
  299. package/src/components/navigation/NavBar/NavBar.tsx +0 -228
  300. package/src/components/navigation/NavBar/NavBar.types.ts +0 -54
  301. package/src/components/navigation/NavBar/index.tsx +0 -3
  302. package/src/components/navigation/Pagination/Pagination.styles.ts +0 -187
  303. package/src/components/navigation/Pagination/Pagination.test.tsx +0 -672
  304. package/src/components/navigation/Pagination/Pagination.tsx +0 -395
  305. package/src/components/navigation/Pagination/Pagination.types.ts +0 -87
  306. package/src/components/navigation/Pagination/index.ts +0 -24
  307. package/src/components/navigation/Pagination/index.tsx +0 -9
  308. package/src/components/navigation/Steps/Step.tsx +0 -36
  309. package/src/components/navigation/Steps/Steps.styles.ts +0 -169
  310. package/src/components/navigation/Steps/Steps.test.tsx +0 -14
  311. package/src/components/navigation/Steps/Steps.tsx +0 -112
  312. package/src/components/navigation/Steps/Steps.types.ts +0 -47
  313. package/src/components/navigation/Steps/index.tsx +0 -3
  314. package/src/components/navigation/Tabs/Tabs.styles.ts +0 -199
  315. package/src/components/navigation/Tabs/Tabs.test.tsx +0 -662
  316. package/src/components/navigation/Tabs/Tabs.tsx +0 -253
  317. package/src/components/navigation/Tabs/Tabs.types.ts +0 -115
  318. package/src/components/navigation/Tabs/index.tsx +0 -3
  319. package/src/components/navigation/index.tsx +0 -88
  320. package/src/constants/index.ts +0 -785
  321. package/src/hooks/index.ts +0 -60
  322. package/src/hooks/types.ts +0 -9
  323. package/src/hooks/useAsync.ts +0 -64
  324. package/src/hooks/useClickOutside.ts +0 -52
  325. package/src/hooks/useCounter.ts +0 -87
  326. package/src/hooks/useDebounce.ts +0 -150
  327. package/src/hooks/useDeepCompareEffect.ts +0 -88
  328. package/src/hooks/useEventHandling.ts +0 -444
  329. package/src/hooks/useEventListener.ts +0 -77
  330. package/src/hooks/useLifecycle.ts +0 -399
  331. package/src/hooks/useMediaQuery.ts +0 -75
  332. package/src/hooks/useMutation.ts +0 -233
  333. package/src/hooks/usePerformance.ts +0 -378
  334. package/src/hooks/usePerformanceMonitor.ts +0 -348
  335. package/src/hooks/usePlatform.ts +0 -64
  336. package/src/hooks/usePrevious.ts +0 -25
  337. package/src/hooks/useRequest.test.ts +0 -11
  338. package/src/hooks/useRequest.ts +0 -140
  339. package/src/hooks/useStateManagement.ts +0 -300
  340. package/src/hooks/useStorage.ts +0 -169
  341. package/src/hooks/useStyle.ts +0 -543
  342. package/src/hooks/useTheme.ts +0 -347
  343. package/src/hooks/useToggle.ts +0 -54
  344. package/src/hooks/useVirtualScroll.ts +0 -331
  345. package/src/index.ts +0 -323
  346. package/src/platform/index.ts +0 -1188
  347. package/src/providers/AppProvider.test.tsx +0 -63
  348. package/src/providers/AppProvider.tsx +0 -155
  349. package/src/providers/index.ts +0 -1
  350. package/src/theme/ThemeProvider.tsx +0 -279
  351. package/src/theme/ThemeProvider.types.ts +0 -26
  352. package/src/theme/animations.tsx +0 -660
  353. package/src/theme/defaults.ts +0 -188
  354. package/src/theme/design-system.ts +0 -562
  355. package/src/theme/design-tokens.ts +0 -1122
  356. package/src/theme/generated/dark-theme.scss +0 -120
  357. package/src/theme/generated/tokens.css +0 -441
  358. package/src/theme/generated/tokens.scss +0 -384
  359. package/src/theme/index.ts +0 -99
  360. package/src/theme/responsive.tsx +0 -195
  361. package/src/theme/styles/mixins.scss +0 -612
  362. package/src/theme/styles/variables.scss +0 -295
  363. package/src/theme/styles.ts +0 -403
  364. package/src/theme/tokens/colors.ts +0 -256
  365. package/src/theme/tokens/effects.ts +0 -260
  366. package/src/theme/tokens/index.ts +0 -217
  367. package/src/theme/tokens/spacing.ts +0 -137
  368. package/src/theme/tokens/typography.ts +0 -186
  369. package/src/theme/types.ts +0 -188
  370. package/src/theme/useThemeUtils.ts +0 -313
  371. package/src/theme/utils.ts +0 -501
  372. package/src/theme/variables.ts +0 -602
  373. package/src/types/accessibility.ts +0 -50
  374. package/src/types/button.ts +0 -560
  375. package/src/types/component-props.ts +0 -322
  376. package/src/types/env.d.ts +0 -20
  377. package/src/types/glob.d.ts +0 -4
  378. package/src/types/index.ts +0 -427
  379. package/src/types/modules.d.ts +0 -40
  380. package/src/types/standardized-components.ts +0 -550
  381. package/src/types/taro-adapter.d.ts +0 -174
  382. package/src/types/taro-components.d.ts +0 -73
  383. package/src/types/utils.ts +0 -400
  384. package/src/utils/__tests__/inputValidator.test.ts +0 -338
  385. package/src/utils/__tests__/responsiveUtils.test.ts +0 -311
  386. package/src/utils/__tests__/xssProtection.test.ts +0 -268
  387. package/src/utils/abort-controller.ts +0 -48
  388. package/src/utils/cache.ts +0 -79
  389. package/src/utils/createNamespace.ts +0 -24
  390. package/src/utils/environment.ts +0 -115
  391. package/src/utils/error-handler.ts +0 -88
  392. package/src/utils/errorLogger.ts +0 -193
  393. package/src/utils/formatUtils.ts +0 -412
  394. package/src/utils/http/error-codes.ts +0 -314
  395. package/src/utils/http/http-client.test.ts +0 -63
  396. package/src/utils/http/http-client.ts +0 -161
  397. package/src/utils/http/request-cache.ts +0 -127
  398. package/src/utils/http/request.ts +0 -954
  399. package/src/utils/http/taro-adapter.test.ts +0 -74
  400. package/src/utils/http/taro-adapter.ts +0 -24
  401. package/src/utils/http/types.ts +0 -414
  402. package/src/utils/http/web-adapter.ts +0 -33
  403. package/src/utils/index.ts +0 -112
  404. package/src/utils/inputValidator.ts +0 -264
  405. package/src/utils/performance/performance.ts +0 -839
  406. package/src/utils/responsiveUtils.ts +0 -348
  407. package/src/utils/rtl-support.ts +0 -354
  408. package/src/utils/security/api-security.ts +0 -394
  409. package/src/utils/security/xss-protection.ts +0 -69
  410. package/src/utils/securityHeaders.ts +0 -308
  411. package/src/utils/typeHelpers.ts +0 -16
  412. package/src/utils/types/dataProcessing.ts +0 -544
  413. package/src/utils/types/typeHelpers.ts +0 -197
  414. package/src/utils/xssProtection.ts +0 -468
@@ -1,1188 +0,0 @@
1
- /**
2
- * Taro-Uno UI 组件库平台适配工具
3
- * 提供跨平台开发的统一接口和适配器
4
- */
5
-
6
- import * as Taro from '@tarojs/taro';
7
- import type { Platform, PlatformInfo, RequestConfig, RequestResponse, RequestError } from '../types';
8
- import { PLATFORM_APIS, PLATFORM_FEATURES, PLATFORM_NAMES } from '../constants';
9
-
10
- // 全局类型声明
11
- declare global {
12
- interface Window {
13
- wx?: any;
14
- my?: any;
15
- swan?: any;
16
- tt?: any;
17
- qq?: any;
18
- jd?: any;
19
- }
20
- }
21
-
22
- // ==================== 平台适配器接口 ====================
23
-
24
- /** 平台适配器接口 */
25
- export interface PlatformAdapter {
26
- /** 获取平台信息 */
27
- getPlatformInfo(): PlatformInfo;
28
-
29
- /** 网络请求 */
30
- request<T = any>(config: RequestConfig): Promise<RequestResponse<T>>;
31
-
32
- /** 存储操作 */
33
- storage: {
34
- set(key: string, value: any): Promise<void>;
35
- get(key: string): Promise<any>;
36
- remove(key: string): Promise<void>;
37
- clear(): Promise<void>;
38
- getInfo(): Promise<{ currentSize: number; limitSize: number }>;
39
- };
40
-
41
- /** 位置服务 */
42
- location: {
43
- getCurrentPosition(): Promise<Taro.getLocation.SuccessCallbackResult>;
44
- openLocation(options: Taro.openLocation.Option): Promise<void>;
45
- chooseLocation(): Promise<Taro.chooseLocation.SuccessCallbackResult>;
46
- };
47
-
48
- /** 相机服务 */
49
- camera: {
50
- takePhoto(options?: any): Promise<any>;
51
- chooseImage(options?: Taro.chooseImage.Option): Promise<Taro.chooseImage.SuccessCallbackResult>;
52
- chooseVideo(options?: Taro.chooseVideo.Option): Promise<Taro.chooseVideo.SuccessCallbackResult>;
53
- };
54
-
55
- /** 支付服务 */
56
- payment: {
57
- requestPayment(options: Taro.requestPayment.Option): Promise<void>;
58
- };
59
-
60
- /** 分享服务 */
61
- share: {
62
- shareAppMessage(options?: any): Promise<void>;
63
- shareToTimeline(options?: any): Promise<void>;
64
- };
65
-
66
- /** 生物识别 */
67
- biometrics: {
68
- checkIsAvailable(): Promise<boolean>;
69
- startVerify(
70
- options: Taro.startSoterAuthentication.Option,
71
- ): Promise<Taro.startSoterAuthentication.SuccessCallbackResult>;
72
- };
73
-
74
- /** 系统信息 */
75
- system: {
76
- getSystemInfo(): Promise<Taro.getSystemInfoSync.Result>;
77
- getNetworkType(): Promise<Taro.getNetworkType.SuccessCallbackResult>;
78
- getBatteryInfo(): Promise<Taro.getBatteryInfo.SuccessCallbackResult>;
79
- getScreenBrightness(): Promise<number>;
80
- setScreenBrightness(value: number): Promise<void>;
81
- keepScreenOn(keepScreenOn: boolean): Promise<void>;
82
- vibrate(): Promise<void>;
83
- };
84
-
85
- /** 剪贴板 */
86
- clipboard: {
87
- set(text: string): Promise<void>;
88
- get(): Promise<string>;
89
- };
90
-
91
- /** 扫码 */
92
- scan: {
93
- scanCode(options?: Taro.scanCode.Option): Promise<Taro.scanCode.SuccessCallbackResult>;
94
- };
95
-
96
- /** 文件操作 */
97
- file: {
98
- saveFile(options: Taro.saveFile.Option): Promise<Taro.saveFile.SuccessCallbackResult>;
99
- getFileInfo(options: Taro.getFileInfo.Option): Promise<Taro.getFileInfo.SuccessCallbackResult>;
100
- getSavedFileList(): Promise<Taro.getSavedFileList.SuccessCallbackResult>;
101
- removeSavedFile(options: Taro.removeSavedFile.Option): Promise<void>;
102
- };
103
- }
104
-
105
- // ==================== 微信小程序适配器 ====================
106
-
107
- class WeappAdapter implements PlatformAdapter {
108
- getPlatformInfo(): PlatformInfo {
109
- const system = Taro.getSystemInfoSync();
110
- const accountInfo = Taro.getAccountInfoSync();
111
-
112
- return {
113
- platform: 'weapp',
114
- isMiniProgram: true,
115
- isH5: false,
116
- isRN: false,
117
- system,
118
- SDKVersion: (accountInfo.miniProgram as any).sdkVersion || accountInfo.miniProgram.version,
119
- version: accountInfo.miniProgram.version,
120
- };
121
- }
122
-
123
- async request<T = any>(config: RequestConfig): Promise<RequestResponse<T>> {
124
- return new Promise((resolve, reject) => {
125
- Taro.request({
126
- url: config.url,
127
- method: (config.method as any) || 'GET',
128
- header: config.header,
129
- data: config.data,
130
- timeout: config.timeout,
131
- success: (res) => {
132
- resolve({
133
- data: res.data as T,
134
- statusCode: res.statusCode,
135
- statusMessage: res.errMsg,
136
- header: res.header,
137
- });
138
- },
139
- fail: (err) => {
140
- const error: RequestError = {
141
- message: err.errMsg || 'Request failed',
142
- code: (err as any).errCode,
143
- detail: err,
144
- };
145
- reject(error);
146
- },
147
- });
148
- });
149
- }
150
-
151
- storage = {
152
- async set(key: string, value: any): Promise<void> {
153
- return new Promise((resolve, reject) => {
154
- Taro.setStorage({
155
- key,
156
- data: value,
157
- success: () => resolve(),
158
- fail: reject,
159
- });
160
- });
161
- },
162
-
163
- async get(key: string): Promise<any> {
164
- return new Promise((resolve, reject) => {
165
- Taro.getStorage({
166
- key,
167
- success: (res) => resolve(res.data),
168
- fail: reject,
169
- });
170
- });
171
- },
172
-
173
- async remove(key: string): Promise<void> {
174
- return new Promise((resolve, reject) => {
175
- Taro.removeStorage({
176
- key,
177
- success: () => resolve(),
178
- fail: reject,
179
- });
180
- });
181
- },
182
-
183
- async clear(): Promise<void> {
184
- return new Promise((resolve, reject) => {
185
- Taro.clearStorage({
186
- success: () => resolve(),
187
- fail: reject,
188
- });
189
- });
190
- },
191
-
192
- async getInfo(): Promise<{ currentSize: number; limitSize: number }> {
193
- return new Promise((resolve, reject) => {
194
- Taro.getStorageInfo({
195
- success: (res) =>
196
- resolve({
197
- currentSize: res.currentSize,
198
- limitSize: res.limitSize,
199
- }),
200
- fail: reject,
201
- });
202
- });
203
- },
204
- };
205
-
206
- location = {
207
- async getCurrentPosition(): Promise<Taro.getLocation.SuccessCallbackResult> {
208
- return new Promise((resolve, reject) => {
209
- Taro.getLocation({
210
- success: resolve,
211
- fail: reject,
212
- });
213
- });
214
- },
215
-
216
- async openLocation(options: Taro.openLocation.Option): Promise<void> {
217
- return new Promise((resolve, reject) => {
218
- Taro.openLocation({
219
- ...options,
220
- success: () => resolve(),
221
- fail: reject,
222
- });
223
- });
224
- },
225
-
226
- async chooseLocation(): Promise<Taro.chooseLocation.SuccessCallbackResult> {
227
- return new Promise((resolve, reject) => {
228
- Taro.chooseLocation({
229
- success: resolve,
230
- fail: reject,
231
- });
232
- });
233
- },
234
- };
235
-
236
- camera = {
237
- async takePhoto(options?: any): Promise<any> {
238
- return new Promise((resolve, reject) => {
239
- (Taro as any).cameraTakePhoto({
240
- ...options,
241
- success: resolve,
242
- fail: reject,
243
- });
244
- });
245
- },
246
-
247
- async chooseImage(options?: Taro.chooseImage.Option): Promise<Taro.chooseImage.SuccessCallbackResult> {
248
- return new Promise((resolve, reject) => {
249
- Taro.chooseImage({
250
- ...options,
251
- success: resolve,
252
- fail: reject,
253
- });
254
- });
255
- },
256
-
257
- async chooseVideo(options?: Taro.chooseVideo.Option): Promise<Taro.chooseVideo.SuccessCallbackResult> {
258
- return new Promise((resolve, reject) => {
259
- Taro.chooseVideo({
260
- ...options,
261
- success: resolve,
262
- fail: reject,
263
- });
264
- });
265
- },
266
- };
267
-
268
- payment = {
269
- async requestPayment(options: Taro.requestPayment.Option): Promise<void> {
270
- return new Promise((resolve, reject) => {
271
- Taro.requestPayment({
272
- ...options,
273
- success: () => resolve(),
274
- fail: reject,
275
- });
276
- });
277
- },
278
- };
279
-
280
- share = {
281
- async shareAppMessage(options?: any): Promise<void> {
282
- return new Promise((resolve, reject) => {
283
- (Taro as any).shareAppMessage({
284
- ...options,
285
- success: () => resolve(),
286
- fail: reject,
287
- });
288
- });
289
- },
290
-
291
- async shareToTimeline(options?: any): Promise<void> {
292
- return new Promise((resolve, reject) => {
293
- (Taro as any).shareToTimeline({
294
- ...options,
295
- success: () => resolve(),
296
- fail: reject,
297
- });
298
- });
299
- },
300
- };
301
-
302
- biometrics = {
303
- async checkIsAvailable(): Promise<boolean> {
304
- return new Promise((resolve) => {
305
- Taro.checkIsSoterEnrolledInDevice({
306
- checkAuthMode: 'fingerPrint',
307
- success: (res) => resolve(res.isEnrolled),
308
- fail: () => resolve(false),
309
- });
310
- });
311
- },
312
-
313
- async startVerify(
314
- options: Taro.startSoterAuthentication.Option,
315
- ): Promise<Taro.startSoterAuthentication.SuccessCallbackResult> {
316
- return new Promise((resolve, reject) => {
317
- Taro.startSoterAuthentication({
318
- ...options,
319
- success: resolve,
320
- fail: reject,
321
- });
322
- });
323
- },
324
- };
325
-
326
- system = {
327
- async getSystemInfo(): Promise<Taro.getSystemInfoSync.Result> {
328
- return Promise.resolve(Taro.getSystemInfoSync());
329
- },
330
-
331
- async getNetworkType(): Promise<Taro.getNetworkType.SuccessCallbackResult> {
332
- return new Promise((resolve, reject) => {
333
- Taro.getNetworkType({
334
- success: resolve,
335
- fail: reject,
336
- });
337
- });
338
- },
339
-
340
- async getBatteryInfo(): Promise<Taro.getBatteryInfo.SuccessCallbackResult> {
341
- return new Promise((resolve, reject) => {
342
- Taro.getBatteryInfo({
343
- success: resolve,
344
- fail: reject,
345
- });
346
- });
347
- },
348
-
349
- async getScreenBrightness(): Promise<number> {
350
- return new Promise((resolve, reject) => {
351
- Taro.getScreenBrightness({
352
- success: (res) => resolve(res.value),
353
- fail: reject,
354
- });
355
- });
356
- },
357
-
358
- async setScreenBrightness(value: number): Promise<void> {
359
- return new Promise((resolve, reject) => {
360
- Taro.setScreenBrightness({
361
- value,
362
- success: () => resolve(),
363
- fail: reject,
364
- });
365
- });
366
- },
367
-
368
- async keepScreenOn(keepScreenOn: boolean): Promise<void> {
369
- return new Promise((resolve, reject) => {
370
- Taro.setKeepScreenOn({
371
- keepScreenOn,
372
- success: () => resolve(),
373
- fail: reject,
374
- });
375
- });
376
- },
377
-
378
- async vibrate(): Promise<void> {
379
- return new Promise((resolve, reject) => {
380
- (Taro as any).vibrate({
381
- success: () => resolve(),
382
- fail: reject,
383
- });
384
- });
385
- },
386
- };
387
-
388
- clipboard = {
389
- async set(text: string): Promise<void> {
390
- return new Promise((resolve, reject) => {
391
- Taro.setClipboardData({
392
- data: text,
393
- success: () => resolve(),
394
- fail: reject,
395
- });
396
- });
397
- },
398
-
399
- async get(): Promise<string> {
400
- return new Promise((resolve, reject) => {
401
- Taro.getClipboardData({
402
- success: (res) => resolve(res.data),
403
- fail: reject,
404
- });
405
- });
406
- },
407
- };
408
-
409
- scan = {
410
- async scanCode(options?: Taro.scanCode.Option): Promise<Taro.scanCode.SuccessCallbackResult> {
411
- return new Promise((resolve, reject) => {
412
- Taro.scanCode({
413
- ...options,
414
- success: resolve,
415
- fail: reject,
416
- });
417
- });
418
- },
419
- };
420
-
421
- file = {
422
- async saveFile(options: Taro.saveFile.Option): Promise<Taro.saveFile.SuccessCallbackResult> {
423
- return new Promise((resolve, reject) => {
424
- Taro.saveFile({
425
- ...options,
426
- success: resolve,
427
- fail: reject,
428
- });
429
- });
430
- },
431
-
432
- async getFileInfo(options: Taro.getFileInfo.Option): Promise<Taro.getFileInfo.SuccessCallbackResult> {
433
- return new Promise((resolve, reject) => {
434
- Taro.getFileInfo({
435
- ...options,
436
- success: resolve,
437
- fail: reject,
438
- });
439
- });
440
- },
441
-
442
- async getSavedFileList(): Promise<Taro.getSavedFileList.SuccessCallbackResult> {
443
- return new Promise((resolve, reject) => {
444
- Taro.getSavedFileList({
445
- success: resolve,
446
- fail: reject,
447
- });
448
- });
449
- },
450
-
451
- async removeSavedFile(options: Taro.removeSavedFile.Option): Promise<void> {
452
- return new Promise((resolve, reject) => {
453
- Taro.removeSavedFile({
454
- ...options,
455
- success: () => resolve(),
456
- fail: reject,
457
- });
458
- });
459
- },
460
- };
461
- }
462
-
463
- // ==================== H5适配器 ====================
464
-
465
- class H5Adapter implements PlatformAdapter {
466
- getPlatformInfo(): PlatformInfo {
467
- const system = Taro.getSystemInfoSync();
468
-
469
- return {
470
- platform: 'h5',
471
- isMiniProgram: false,
472
- isH5: true,
473
- isRN: false,
474
- system,
475
- };
476
- }
477
-
478
- /** Headers对象转普通对象 */
479
- private headersToObject(headers: Headers): Record<string, string> {
480
- const result: Record<string, string> = {};
481
- headers.forEach((value, key) => {
482
- result[key] = value;
483
- });
484
- return result;
485
- }
486
-
487
- async request<T = any>(config: RequestConfig): Promise<RequestResponse<T>> {
488
- const url = new URL(config.url, window.location.origin);
489
-
490
- // 添加查询参数
491
- if (config.params) {
492
- Object.entries(config.params).forEach(([key, value]) => {
493
- url.searchParams.append(key, String(value));
494
- });
495
- }
496
-
497
- const options: RequestInit = {
498
- method: config.method || 'GET',
499
- headers: {
500
- 'Content-Type': 'application/json',
501
- ...config.header,
502
- },
503
- };
504
-
505
- if (config.data && ['POST', 'PUT', 'PATCH'].includes(config.method || 'GET')) {
506
- options.body = JSON.stringify(config.data);
507
- }
508
-
509
- try {
510
- const response = await fetch(url.toString(), options);
511
- const data = await response.json();
512
-
513
- return {
514
- data,
515
- statusCode: response.status,
516
- statusMessage: response.statusText,
517
- header: this.headersToObject(response.headers),
518
- };
519
- } catch (error) {
520
- const requestError: RequestError = {
521
- message: error instanceof Error ? error.message : 'Network error',
522
- detail: error,
523
- };
524
- throw requestError;
525
- }
526
- }
527
-
528
- storage = {
529
- async set(key: string, value: any): Promise<void> {
530
- localStorage.setItem(key, JSON.stringify(value));
531
- },
532
-
533
- async get(key: string): Promise<any> {
534
- const value = localStorage.getItem(key);
535
- return value ? JSON.parse(value) : null;
536
- },
537
-
538
- async remove(key: string): Promise<void> {
539
- localStorage.removeItem(key);
540
- },
541
-
542
- async clear(): Promise<void> {
543
- localStorage.clear();
544
- },
545
-
546
- async getInfo(): Promise<{ currentSize: number; limitSize: number }> {
547
- // 估算localStorage使用空间
548
- let size = 0;
549
- for (let i = 0; i < localStorage.length; i++) {
550
- const key = localStorage.key(i);
551
- if (key) {
552
- size += (key + localStorage.getItem(key)).length;
553
- }
554
- }
555
-
556
- return {
557
- currentSize: size,
558
- limitSize: 5 * 1024 * 1024, // 5MB 估算
559
- };
560
- },
561
- };
562
-
563
- location = {
564
- async getCurrentPosition(): Promise<Taro.getLocation.SuccessCallbackResult> {
565
- return new Promise((resolve, reject) => {
566
- if (!navigator.geolocation) {
567
- reject(new Error('Geolocation is not supported'));
568
- return;
569
- }
570
-
571
- navigator.geolocation.getCurrentPosition(
572
- (position) => {
573
- resolve({
574
- latitude: position.coords.latitude || 0,
575
- longitude: position.coords.longitude || 0,
576
- accuracy: position.coords.accuracy || 0,
577
- altitude: position.coords.altitude || 0,
578
- verticalAccuracy: position.coords.altitudeAccuracy || 0,
579
- horizontalAccuracy: position.coords.accuracy || 0,
580
- speed: position.coords.speed || 0,
581
- errMsg: 'getLocation:ok',
582
- });
583
- },
584
- (error) => {
585
- reject(error);
586
- },
587
- );
588
- });
589
- },
590
-
591
- async openLocation(options: Taro.openLocation.Option): Promise<void> {
592
- const url = `https://maps.google.com/maps?q=${options.latitude},${options.longitude}`;
593
- window.open(url, '_blank');
594
- },
595
-
596
- async chooseLocation(): Promise<Taro.chooseLocation.SuccessCallbackResult> {
597
- // H5环境下需要用户手动输入或使用地图选择
598
- throw new Error('chooseLocation is not supported in H5 environment');
599
- },
600
- };
601
-
602
- camera = {
603
- async takePhoto(): Promise<any> {
604
- throw new Error('takePhoto is not supported in H5 environment');
605
- },
606
-
607
- async chooseImage(options?: Taro.chooseImage.Option): Promise<Taro.chooseImage.SuccessCallbackResult> {
608
- return new Promise((resolve, reject) => {
609
- const input = document.createElement('input');
610
- input.type = 'file';
611
- input.accept = 'image/*';
612
-
613
- if (options?.count && options.count > 1) {
614
- input.multiple = true;
615
- }
616
-
617
- input.onchange = (event) => {
618
- const files = Array.from((event.target as HTMLInputElement).files || []);
619
- const tempFilePaths = files.map((file) => URL.createObjectURL(file));
620
-
621
- resolve({
622
- tempFilePaths,
623
- tempFiles: files.map((file) => ({
624
- path: URL.createObjectURL(file),
625
- size: file.size,
626
- type: file.type,
627
- originalFileObj: file,
628
- })),
629
- errMsg: 'chooseImage:ok',
630
- });
631
- };
632
-
633
- input.onerror = () => {
634
- reject(new Error('Failed to choose image'));
635
- };
636
-
637
- input.click();
638
- });
639
- },
640
-
641
- async chooseVideo(): Promise<Taro.chooseVideo.SuccessCallbackResult> {
642
- return new Promise((resolve, reject) => {
643
- const input = document.createElement('input');
644
- input.type = 'file';
645
- input.accept = 'video/*';
646
-
647
- input.onchange = (event) => {
648
- const file = (event.target as HTMLInputElement).files?.[0];
649
- if (!file) {
650
- reject(new Error('No file selected'));
651
- return;
652
- }
653
-
654
- resolve({
655
- tempFilePath: URL.createObjectURL(file),
656
- duration: 0, // 需要额外的逻辑获取视频时长
657
- size: file.size,
658
- height: 0, // 需要额外的逻辑获取视频尺寸
659
- width: 0,
660
- errMsg: 'chooseVideo:ok',
661
- });
662
- };
663
-
664
- input.onerror = () => {
665
- reject(new Error('Failed to choose video'));
666
- };
667
-
668
- input.click();
669
- });
670
- },
671
- };
672
-
673
- payment = {
674
- async requestPayment(): Promise<void> {
675
- throw new Error('Payment is not supported in H5 environment');
676
- },
677
- };
678
-
679
- share = {
680
- async shareAppMessage(): Promise<void> {
681
- // 使用Web Share API如果可用
682
- if (navigator.share) {
683
- await navigator.share({
684
- title: document.title,
685
- url: window.location.href,
686
- });
687
- } else {
688
- throw new Error('Web Share API is not supported');
689
- }
690
- },
691
-
692
- async shareToTimeline(): Promise<void> {
693
- throw new Error('shareToTimeline is not supported in H5 environment');
694
- },
695
- };
696
-
697
- biometrics = {
698
- async checkIsAvailable(): Promise<boolean> {
699
- return false;
700
- },
701
-
702
- async startVerify(): Promise<Taro.startSoterAuthentication.SuccessCallbackResult> {
703
- throw new Error('Biometric authentication is not supported in H5 environment');
704
- },
705
- };
706
-
707
- system = {
708
- async getSystemInfo(): Promise<Taro.getSystemInfoSync.Result> {
709
- return Promise.resolve(Taro.getSystemInfoSync());
710
- },
711
-
712
- async getNetworkType(): Promise<Taro.getNetworkType.SuccessCallbackResult> {
713
- // 估算网络类型
714
- const connection = (navigator as any).connection;
715
- let networkType = 'unknown';
716
-
717
- if (connection) {
718
- if (connection.effectiveType) {
719
- networkType = connection.effectiveType;
720
- }
721
- }
722
-
723
- return {
724
- networkType: networkType as any,
725
- errMsg: 'getNetworkType:ok',
726
- };
727
- },
728
-
729
- async getBatteryInfo(): Promise<Taro.getBatteryInfo.SuccessCallbackResult> {
730
- // 需要Battery API支持
731
- throw new Error('Battery API is not supported');
732
- },
733
-
734
- async getScreenBrightness(): Promise<number> {
735
- // H5环境下无法获取屏幕亮度
736
- return 1;
737
- },
738
-
739
- async setScreenBrightness(): Promise<void> {
740
- // H5环境下无法设置屏幕亮度
741
- },
742
-
743
- async keepScreenOn(): Promise<void> {
744
- // H5环境下无法保持屏幕常亮
745
- },
746
-
747
- async vibrate(): Promise<void> {
748
- if (navigator.vibrate) {
749
- navigator.vibrate(200);
750
- }
751
- },
752
- };
753
-
754
- clipboard = {
755
- async set(text: string): Promise<void> {
756
- if (navigator.clipboard) {
757
- await navigator.clipboard.writeText(text);
758
- } else {
759
- // 降级方案
760
- const textArea = document.createElement('textarea');
761
- textArea.value = text;
762
- document.body.appendChild(textArea);
763
- textArea.select();
764
- document.execCommand('copy');
765
- document.body.removeChild(textArea);
766
- }
767
- },
768
-
769
- async get(): Promise<string> {
770
- if (navigator.clipboard) {
771
- return await navigator.clipboard.readText();
772
- } else {
773
- // 降级方案
774
- return '';
775
- }
776
- },
777
- };
778
-
779
- scan = {
780
- async scanCode(): Promise<Taro.scanCode.SuccessCallbackResult> {
781
- throw new Error('scanCode is not supported in H5 environment');
782
- },
783
- };
784
-
785
- file = {
786
- async saveFile(): Promise<Taro.saveFile.SuccessCallbackResult> {
787
- throw new Error('saveFile is not supported in H5 environment');
788
- },
789
-
790
- async getFileInfo(): Promise<Taro.getFileInfo.SuccessCallbackResult> {
791
- throw new Error('getFileInfo is not supported in H5 environment');
792
- },
793
-
794
- async getSavedFileList(): Promise<Taro.getSavedFileList.SuccessCallbackResult> {
795
- throw new Error('getSavedFileList is not supported in H5 environment');
796
- },
797
-
798
- async removeSavedFile(): Promise<void> {
799
- throw new Error('removeSavedFile is not supported in H5 environment');
800
- },
801
- };
802
- }
803
-
804
- // ==================== React Native适配器 ====================
805
-
806
- class RNAdapter implements PlatformAdapter {
807
- getPlatformInfo(): PlatformInfo {
808
- const system = Taro.getSystemInfoSync();
809
-
810
- return {
811
- platform: 'rn',
812
- isMiniProgram: false,
813
- isH5: false,
814
- isRN: true,
815
- system,
816
- };
817
- }
818
-
819
- /** Headers对象转普通对象 */
820
- private headersToObject(headers: Headers): Record<string, string> {
821
- const result: Record<string, string> = {};
822
- headers.forEach((value, key) => {
823
- result[key] = value;
824
- });
825
- return result;
826
- }
827
-
828
- async request<T = any>(config: RequestConfig): Promise<RequestResponse<T>> {
829
- // 使用React Native的fetch实现
830
- const url = new URL(config.url);
831
-
832
- if (config.params) {
833
- Object.entries(config.params).forEach(([key, value]) => {
834
- url.searchParams.append(key, String(value));
835
- });
836
- }
837
-
838
- const options: RequestInit = {
839
- method: config.method || 'GET',
840
- headers: {
841
- 'Content-Type': 'application/json',
842
- ...config.header,
843
- },
844
- };
845
-
846
- if (config.data && ['POST', 'PUT', 'PATCH'].includes(config.method || 'GET')) {
847
- options.body = JSON.stringify(config.data);
848
- }
849
-
850
- try {
851
- const response = await fetch(url.toString(), options);
852
- const data = await response.json();
853
-
854
- return {
855
- data,
856
- statusCode: response.status,
857
- statusMessage: response.statusText,
858
- header: this.headersToObject(response.headers),
859
- };
860
- } catch (error) {
861
- const requestError: RequestError = {
862
- message: error instanceof Error ? error.message : 'Network error',
863
- detail: error,
864
- };
865
- throw requestError;
866
- }
867
- }
868
-
869
- // React Native的存储实现需要使用AsyncStorage
870
- storage = {
871
- async set(_key: string, _value: any): Promise<void> {
872
- // 这里需要导入AsyncStorage
873
- // const { AsyncStorage } = require('react-native')
874
- // await AsyncStorage.setItem(key, JSON.stringify(value))
875
- throw new Error('AsyncStorage not implemented');
876
- },
877
-
878
- async get(_key: string): Promise<any> {
879
- // const { AsyncStorage } = require('react-native')
880
- // const value = await AsyncStorage.getItem(key)
881
- // return value ? JSON.parse(value) : null
882
- throw new Error('AsyncStorage not implemented');
883
- },
884
-
885
- async remove(_key: string): Promise<void> {
886
- // const { AsyncStorage } = require('react-native')
887
- // await AsyncStorage.removeItem(key)
888
- throw new Error('AsyncStorage not implemented');
889
- },
890
-
891
- async clear(): Promise<void> {
892
- // const { AsyncStorage } = require('react-native')
893
- // await AsyncStorage.clear()
894
- throw new Error('AsyncStorage not implemented');
895
- },
896
-
897
- async getInfo(): Promise<{ currentSize: number; limitSize: number }> {
898
- throw new Error('Storage info not available in React Native');
899
- },
900
- };
901
-
902
- // 其他React Native平台的实现...
903
- // 由于React Native的API实现较为复杂,这里只提供基础框架
904
- location = {
905
- async getCurrentPosition(): Promise<Taro.getLocation.SuccessCallbackResult> {
906
- throw new Error('Location service not implemented');
907
- },
908
-
909
- async openLocation(): Promise<void> {
910
- throw new Error('openLocation not implemented');
911
- },
912
-
913
- async chooseLocation(): Promise<Taro.chooseLocation.SuccessCallbackResult> {
914
- throw new Error('chooseLocation not implemented');
915
- },
916
- };
917
-
918
- camera = {
919
- async takePhoto(): Promise<any> {
920
- throw new Error('Camera service not implemented');
921
- },
922
-
923
- async chooseImage(): Promise<Taro.chooseImage.SuccessCallbackResult> {
924
- throw new Error('chooseImage not implemented');
925
- },
926
-
927
- async chooseVideo(): Promise<Taro.chooseVideo.SuccessCallbackResult> {
928
- throw new Error('chooseVideo not implemented');
929
- },
930
- };
931
-
932
- payment = {
933
- async requestPayment(): Promise<void> {
934
- throw new Error('Payment service not implemented');
935
- },
936
- };
937
-
938
- share = {
939
- async shareAppMessage(): Promise<void> {
940
- throw new Error('Share service not implemented');
941
- },
942
-
943
- async shareToTimeline(): Promise<void> {
944
- throw new Error('Share service not implemented');
945
- },
946
- };
947
-
948
- biometrics = {
949
- async checkIsAvailable(): Promise<boolean> {
950
- throw new Error('Biometric service not implemented');
951
- },
952
-
953
- async startVerify(): Promise<Taro.startSoterAuthentication.SuccessCallbackResult> {
954
- throw new Error('Biometric service not implemented');
955
- },
956
- };
957
-
958
- system = {
959
- async getSystemInfo(): Promise<Taro.getSystemInfoSync.Result> {
960
- return Promise.resolve(Taro.getSystemInfoSync());
961
- },
962
-
963
- async getNetworkType(): Promise<Taro.getNetworkType.SuccessCallbackResult> {
964
- throw new Error('Network type service not implemented');
965
- },
966
-
967
- async getBatteryInfo(): Promise<Taro.getBatteryInfo.SuccessCallbackResult> {
968
- throw new Error('Battery service not implemented');
969
- },
970
-
971
- async getScreenBrightness(): Promise<number> {
972
- throw new Error('Screen brightness service not implemented');
973
- },
974
-
975
- async setScreenBrightness(): Promise<void> {
976
- throw new Error('Screen brightness service not implemented');
977
- },
978
-
979
- async keepScreenOn(): Promise<void> {
980
- throw new Error('Keep screen on service not implemented');
981
- },
982
-
983
- async vibrate(): Promise<void> {
984
- throw new Error('Vibrate service not implemented');
985
- },
986
- };
987
-
988
- clipboard = {
989
- async set(_text: string): Promise<void> {
990
- throw new Error('Clipboard service not implemented');
991
- },
992
-
993
- async get(): Promise<string> {
994
- throw new Error('Clipboard service not implemented');
995
- },
996
- };
997
-
998
- scan = {
999
- async scanCode(): Promise<Taro.scanCode.SuccessCallbackResult> {
1000
- throw new Error('Scan service not implemented');
1001
- },
1002
- };
1003
-
1004
- file = {
1005
- async saveFile(): Promise<Taro.saveFile.SuccessCallbackResult> {
1006
- throw new Error('File service not implemented');
1007
- },
1008
-
1009
- async getFileInfo(): Promise<Taro.getFileInfo.SuccessCallbackResult> {
1010
- throw new Error('File service not implemented');
1011
- },
1012
-
1013
- async getSavedFileList(): Promise<Taro.getSavedFileList.SuccessCallbackResult> {
1014
- throw new Error('File service not implemented');
1015
- },
1016
-
1017
- async removeSavedFile(): Promise<void> {
1018
- throw new Error('File service not implemented');
1019
- },
1020
- };
1021
- }
1022
-
1023
- // ==================== 平台管理器 ====================
1024
-
1025
- /** 平台管理器 */
1026
- export class PlatformManager {
1027
- private static instance: PlatformManager;
1028
- private adapter: PlatformAdapter;
1029
- private platformInfo: PlatformInfo;
1030
-
1031
- private constructor() {
1032
- const platform = this.detectPlatform();
1033
- this.adapter = this.createAdapter(platform);
1034
- this.platformInfo = this.adapter.getPlatformInfo();
1035
- }
1036
-
1037
- /** 获取单例实例 */
1038
- static getInstance(): PlatformManager {
1039
- if (!PlatformManager.instance) {
1040
- PlatformManager.instance = new PlatformManager();
1041
- }
1042
- return PlatformManager.instance;
1043
- }
1044
-
1045
- /** 检测当前平台 */
1046
- private detectPlatform(): Platform {
1047
- if (typeof window !== 'undefined' && window.wx && (window.wx as any).getSystemInfo) {
1048
- return 'weapp';
1049
- } else if (typeof window !== 'undefined' && window.my && (window.my as any).getSystemInfo) {
1050
- return 'alipay';
1051
- } else if (typeof window !== 'undefined' && window.swan && (window.swan as any).getSystemInfo) {
1052
- return 'swan';
1053
- } else if (typeof window !== 'undefined' && window.tt && (window.tt as any).getSystemInfo) {
1054
- return 'tt';
1055
- } else if (typeof window !== 'undefined' && window.qq && (window.qq as any).getSystemInfo) {
1056
- return 'qq';
1057
- } else if (typeof window !== 'undefined' && window.jd && (window.jd as any).getSystemInfo) {
1058
- return 'jd';
1059
- } else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
1060
- return 'rn';
1061
- } else {
1062
- return 'h5';
1063
- }
1064
- }
1065
-
1066
- /** 创建平台适配器 */
1067
- private createAdapter(platform: Platform): PlatformAdapter {
1068
- switch (platform) {
1069
- case 'weapp':
1070
- return new WeappAdapter();
1071
- case 'alipay':
1072
- // 支付宝小程序适配器与微信类似,这里使用相同的实现
1073
- return new WeappAdapter();
1074
- case 'swan':
1075
- // 百度小程序适配器与微信类似,这里使用相同的实现
1076
- return new WeappAdapter();
1077
- case 'tt':
1078
- // 字节跳动小程序适配器与微信类似,这里使用相同的实现
1079
- return new WeappAdapter();
1080
- case 'qq':
1081
- // QQ小程序适配器与微信类似,这里使用相同的实现
1082
- return new WeappAdapter();
1083
- case 'jd':
1084
- // 京东小程序适配器与微信类似,这里使用相同的实现
1085
- return new WeappAdapter();
1086
- case 'h5':
1087
- return new H5Adapter();
1088
- case 'rn':
1089
- return new RNAdapter();
1090
- default:
1091
- return new H5Adapter(); // 默认使用H5适配器
1092
- }
1093
- }
1094
-
1095
- /** 获取平台适配器 */
1096
- getAdapter(): PlatformAdapter {
1097
- return this.adapter;
1098
- }
1099
-
1100
- /** 获取平台信息 */
1101
- getPlatformInfo(): PlatformInfo {
1102
- return this.platformInfo;
1103
- }
1104
-
1105
- /** 获取当前平台 */
1106
- getPlatform(): Platform {
1107
- return this.platformInfo.platform;
1108
- }
1109
-
1110
- /** 判断是否为指定平台 */
1111
- isPlatform(targetPlatform: Platform): boolean {
1112
- return this.platformInfo.platform === targetPlatform;
1113
- }
1114
-
1115
- /** 判断是否为小程序环境 */
1116
- isMiniProgram(): boolean {
1117
- return this.platformInfo.isMiniProgram;
1118
- }
1119
-
1120
- /** 判断是否为H5环境 */
1121
- isH5(): boolean {
1122
- return this.platformInfo.isH5;
1123
- }
1124
-
1125
- /** 判断是否为React Native环境 */
1126
- isRN(): boolean {
1127
- return this.platformInfo.isRN;
1128
- }
1129
-
1130
- /** 检查功能支持 */
1131
- isFeatureSupported(feature: keyof typeof PLATFORM_FEATURES.weapp): boolean {
1132
- const platform = this.platformInfo.platform;
1133
- return PLATFORM_FEATURES[platform]?.[feature] || false;
1134
- }
1135
-
1136
- /** 获取平台API映射 */
1137
- getPlatformAPIs(): typeof PLATFORM_APIS.weapp {
1138
- const platform = this.platformInfo.platform;
1139
- return PLATFORM_APIS[platform] || PLATFORM_APIS.h5;
1140
- }
1141
-
1142
- /** 获取平台名称 */
1143
- getPlatformName(): string {
1144
- const platform = this.platformInfo.platform;
1145
- return PLATFORM_NAMES[platform] || 'Unknown';
1146
- }
1147
-
1148
- /** 重置平台管理器(主要用于测试) */
1149
- reset(): void {
1150
- PlatformManager.instance = new PlatformManager();
1151
- }
1152
- }
1153
-
1154
- // ==================== 导出平台工具 ====================
1155
-
1156
- /** 创建平台管理器实例 */
1157
- export const platformManager = PlatformManager.getInstance();
1158
-
1159
- /** 导出平台适配器 */
1160
- export const platformAdapter = platformManager.getAdapter();
1161
-
1162
- /** 导出平台检测工具 */
1163
- export const platformUtils = {
1164
- getPlatform: () => platformManager.getPlatform(),
1165
- getPlatformInfo: () => platformManager.getPlatformInfo(),
1166
- isPlatform: (platform: Platform) => platformManager.isPlatform(platform),
1167
- isMiniProgram: () => platformManager.isMiniProgram(),
1168
- isH5: () => platformManager.isH5(),
1169
- isRN: () => platformManager.isRN(),
1170
- isFeatureSupported: (feature: keyof typeof PLATFORM_FEATURES.weapp) => platformManager.isFeatureSupported(feature),
1171
- getPlatformAPIs: () => platformManager.getPlatformAPIs(),
1172
- getPlatformName: () => platformManager.getPlatformName(),
1173
- };
1174
-
1175
- /** 导出快捷方法 */
1176
- export const {
1177
- getPlatform,
1178
- getPlatformInfo,
1179
- isPlatform,
1180
- isMiniProgram,
1181
- isH5,
1182
- isRN,
1183
- isFeatureSupported,
1184
- getPlatformAPIs,
1185
- getPlatformName,
1186
- } = platformUtils;
1187
-
1188
- // 类型已经在前面导出,这里不需要重复导出