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