fusions-ui 1.2.7 → 1.2.8
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 +1 -1
- package/changelog.md +2 -0
- package/components/avatar/index.ts +1 -0
- package/components/avatar/src/avatar.ts +131 -0
- package/components/avatar/src/avatar.vue +104 -0
- package/components/avatar/src/composables/index.ts +1 -0
- package/components/avatar/src/composables/use-avatar.ts +61 -0
- package/components/avatar-group/index.ts +1 -0
- package/components/avatar-group/src/avatar-group.ts +86 -0
- package/components/{fu-avatar-group/fu-avatar-group.vue → avatar-group/src/avatar-group.vue} +27 -34
- package/components/avatar-group/src/composables/index.ts +1 -0
- package/components/avatar-group/src/composables/use-avatar-group.ts +17 -0
- package/components/badge/index.ts +1 -0
- package/components/badge/src/badge.ts +126 -0
- package/components/{fu-badge/fu-badge.vue → badge/src/badge.vue} +26 -62
- package/components/badge/src/composables/badge-custom.ts +51 -0
- package/components/badge/src/composables/index.ts +1 -0
- package/components/banner-arc/index.ts +1 -0
- package/components/banner-arc/src/banner-arc.ts +41 -0
- package/components/banner-arc/src/banner-arc.vue +49 -0
- package/components/banner-arc/src/composables/banner-arc-custom.ts +19 -0
- package/components/banner-arc/src/composables/index.ts +1 -0
- package/components/button/index.ts +1 -0
- package/components/button/src/button.ts +332 -0
- package/components/{fu-button/fu-button.vue → button/src/button.vue} +57 -163
- package/components/button/src/composables/button-custom.ts +90 -0
- package/components/button/src/composables/index.ts +2 -0
- package/components/button/src/composables/use-button.ts +137 -0
- package/components/cell/index.ts +1 -0
- package/components/cell/src/cell.ts +167 -0
- package/components/{fu-cell/fu-cell.vue → cell/src/cell.vue} +29 -38
- package/components/cell/src/composables/index.ts +1 -0
- package/components/cell/src/composables/use-cell.ts +20 -0
- package/components/cell-group/index.ts +1 -0
- package/components/cell-group/src/cell-group.ts +23 -0
- package/components/{fu-cell-group/fu-cell-group.vue → cell-group/src/cell-group.vue} +8 -13
- package/components/checkbox/index.ts +1 -0
- package/components/checkbox/src/checkbox.ts +144 -0
- package/components/checkbox/src/checkbox.vue +270 -0
- package/components/checkbox/src/composables/checkbox-custom.ts +15 -0
- package/components/checkbox/src/composables/index.ts +2 -0
- package/components/checkbox/src/composables/use-checkbox.ts +200 -0
- package/components/code-input/index.ts +1 -0
- package/components/code-input/src/code-input.ts +157 -0
- package/components/code-input/src/code-input.vue +158 -0
- package/components/code-input/src/composables/code-input-custom.ts +74 -0
- package/components/code-input/src/composables/index.ts +2 -0
- package/components/code-input/src/composables/use-code-input.ts +67 -0
- package/components/code-verify/index.ts +1 -0
- package/components/code-verify/src/code-verify.ts +160 -0
- package/components/code-verify/src/code-verify.vue +87 -0
- package/components/code-verify/src/composables/code-verify-custom.ts +23 -0
- package/components/code-verify/src/composables/index.ts +2 -0
- package/components/code-verify/src/composables/use-code-verify.ts +132 -0
- package/components/collapse/index.ts +1 -0
- package/components/collapse/src/collapse.ts +41 -0
- package/components/collapse/src/collapse.vue +48 -0
- package/components/collapse/src/composables/index.ts +1 -0
- package/components/collapse/src/composables/use-collapse.ts +150 -0
- package/components/collapse-item/index.ts +1 -0
- package/components/collapse-item/src/collapse-item.ts +102 -0
- package/components/{fu-collapse-item/fu-collapse-item.vue → collapse-item/src/collapse-item.vue} +20 -159
- package/components/collapse-item/src/composables/index.ts +1 -0
- package/components/collapse-item/src/composables/use-collapse-item.ts +139 -0
- package/components/countdown/index.ts +1 -0
- package/components/countdown/src/composables/index.ts +1 -0
- package/components/countdown/src/composables/use-countdown.ts +133 -0
- package/components/countdown/src/countdown.ts +63 -0
- package/components/countdown/src/countdown.vue +60 -0
- package/components/{fu-countdown/util.js → countdown/src/util.ts} +5 -5
- package/components/datetime-picker/index.ts +1 -0
- package/components/datetime-picker/src/composables/index.ts +1 -0
- package/components/datetime-picker/src/composables/use-datetime-picker.ts +325 -0
- package/components/datetime-picker/src/datetime-picker.ts +223 -0
- package/components/datetime-picker/src/datetime-picker.vue +96 -0
- package/components/form/index.ts +1 -0
- package/components/form/src/composables/index.ts +1 -0
- package/components/form/src/composables/use-form.ts +256 -0
- package/components/form/src/form.ts +108 -0
- package/components/form/src/form.vue +64 -0
- package/components/{fu-form/utils.js → form/src/utils.ts} +49 -42
- package/components/{fu-form/validate.js → form/src/validate.ts} +58 -49
- package/components/form-item/index.ts +1 -0
- package/components/form-item/src/composables/index.ts +1 -0
- package/components/form-item/src/composables/use-form-item.ts +292 -0
- package/components/form-item/src/form-item.ts +81 -0
- package/components/form-item/src/form-item.vue +229 -0
- package/components/fusions-ui/src/fusions-ui.vue +8 -0
- package/components/grid/index.ts +1 -0
- package/components/grid/src/composables/index.ts +1 -0
- package/components/grid/src/composables/use-grid.ts +67 -0
- package/components/grid/src/grid.ts +54 -0
- package/components/grid/src/grid.vue +69 -0
- package/components/grid-item/index.ts +1 -0
- package/components/grid-item/src/composables/grid-item-custom.ts +16 -0
- package/components/grid-item/src/composables/index.ts +2 -0
- package/components/grid-item/src/composables/use-grid-item.ts +55 -0
- package/components/grid-item/src/grid-item.ts +15 -0
- package/components/grid-item/src/grid-item.vue +102 -0
- package/components/icon/index.ts +1 -0
- package/components/icon/src/composables/icon-custom.ts +41 -0
- package/components/icon/src/composables/index.ts +2 -0
- package/components/icon/src/composables/use-icon.ts +14 -0
- package/components/{fu-icon → icon/src}/fuicon.css +584 -584
- package/components/icon/src/fuicon.ts +1023 -0
- package/components/icon/src/icon.ts +84 -0
- package/components/icon/src/icon.vue +92 -0
- package/components/image/index.ts +1 -0
- package/components/image/src/composables/image-custom.ts +36 -0
- package/components/image/src/composables/index.ts +2 -0
- package/components/image/src/composables/use-image.ts +135 -0
- package/components/image/src/image.ts +185 -0
- package/components/image/src/image.vue +152 -0
- package/components/index-anchor/index.ts +1 -0
- package/components/index-anchor/src/composables/index.ts +1 -0
- package/components/index-anchor/src/composables/use-index-anchor.ts +44 -0
- package/components/index-anchor/src/index-anchor.ts +45 -0
- package/components/index-anchor/src/index-anchor.vue +60 -0
- package/components/index-item/index.ts +1 -0
- package/components/index-item/src/composables/index.ts +1 -0
- package/components/index-item/src/composables/use-index-item.ts +75 -0
- package/components/index-item/src/index-item.ts +13 -0
- package/components/index-item/src/index-item.vue +32 -0
- package/components/index-list/index.ts +1 -0
- package/components/index-list/src/composables/index.ts +1 -0
- package/components/index-list/src/composables/use-index-list.ts +297 -0
- package/components/index-list/src/index-list.ts +52 -0
- package/components/index-list/src/index-list.vue +178 -0
- package/components/index.ts +62 -0
- package/components/input/index.ts +1 -0
- package/components/input/src/composables/index.ts +2 -0
- package/components/input/src/composables/input-custom.ts +69 -0
- package/components/input/src/composables/use-input.ts +117 -0
- package/components/input/src/input.ts +360 -0
- package/components/input/src/input.vue +241 -0
- package/components/keyboard/index.ts +1 -0
- package/components/keyboard/src/composables/index.ts +3 -0
- package/components/keyboard/src/composables/use-keyboard-car.ts +99 -0
- package/components/keyboard/src/composables/use-keyboard-number.ts +81 -0
- package/components/keyboard/src/composables/use-keyboard.ts +61 -0
- package/components/keyboard/src/keyboard-car.ts +53 -0
- package/components/{fu-keyboard → keyboard/src}/keyboard-car.vue +37 -199
- package/components/keyboard/src/keyboard-number.ts +44 -0
- package/components/keyboard/src/keyboard-number.vue +108 -0
- package/components/keyboard/src/keyboard.ts +174 -0
- package/components/{fu-keyboard/fu-keyboard.vue → keyboard/src/keyboard.vue} +38 -63
- package/components/line/index.ts +1 -0
- package/components/line/src/composables/index.ts +1 -0
- package/components/line/src/composables/line-custom.ts +30 -0
- package/components/line/src/line.ts +82 -0
- package/components/line/src/line.vue +44 -0
- package/components/link/index.ts +1 -0
- package/components/link/src/composables/index.ts +2 -0
- package/components/link/src/composables/link-custom.ts +19 -0
- package/components/link/src/composables/use-link.ts +33 -0
- package/components/link/src/link.ts +61 -0
- package/components/link/src/link.vue +62 -0
- package/components/loading/index.ts +1 -0
- package/{libs/function/colorGradient.js → components/loading/src/composables/colorGradient.ts} +4 -4
- package/components/loading/src/composables/index.ts +2 -0
- package/components/loading/src/composables/loading-custom.ts +21 -0
- package/components/loading/src/composables/use-loading.ts +100 -0
- package/components/loading/src/loading.ts +77 -0
- package/components/{fu-loading/fu-loading.vue → loading/src/loading.vue} +23 -119
- package/components/loading-more/index.ts +1 -0
- package/components/loading-more/src/loading-more.ts +75 -0
- package/components/{fu-loading-more/fu-loading-more.vue → loading-more/src/loading-more.vue} +18 -19
- package/components/modal/index.ts +1 -0
- package/components/modal/src/composables/index.ts +2 -0
- package/components/modal/src/composables/modal-custom.ts +17 -0
- package/components/modal/src/composables/use-modal.ts +56 -0
- package/components/modal/src/modal.ts +152 -0
- package/components/{fu-modal/fu-modal.vue → modal/src/modal.vue} +41 -69
- package/components/navbar/index.ts +1 -0
- package/components/navbar/src/composables/index.ts +2 -0
- package/components/navbar/src/composables/navbar-custom.ts +62 -0
- package/components/navbar/src/composables/use-navbar.ts +42 -0
- package/components/navbar/src/navbar.ts +151 -0
- package/components/navbar/src/navbar.vue +249 -0
- package/components/notice-bar/index.ts +3 -0
- package/components/notice-bar/src/composables/index.ts +5 -0
- package/components/notice-bar/src/composables/notice-column-custom.ts +43 -0
- package/components/notice-bar/src/composables/notice-row-custom.ts +26 -0
- package/components/notice-bar/src/composables/use-notice-bar.ts +34 -0
- package/components/notice-bar/src/composables/use-notice-column.ts +31 -0
- package/components/notice-bar/src/composables/use-notice-row.ts +88 -0
- package/components/notice-bar/src/notice-bar.ts +197 -0
- package/components/{fu-notice-bar/fu-notice-bar.vue → notice-bar/src/notice-bar.vue} +28 -41
- package/components/notice-bar/src/notice-column.ts +172 -0
- package/components/notice-bar/src/notice-column.vue +129 -0
- package/components/notice-bar/src/notice-row.ts +155 -0
- package/components/notice-bar/src/notice-row.vue +135 -0
- package/components/number-box/index.ts +1 -0
- package/components/number-box/src/composables/index.ts +2 -0
- package/components/number-box/src/composables/number-box-custom.ts +16 -0
- package/components/number-box/src/composables/use-number-box.ts +84 -0
- package/components/number-box/src/number-box.ts +98 -0
- package/components/number-box/src/number-box.vue +123 -0
- package/components/parse/index.ts +1 -0
- package/components/parse/src/app-plus/html/js/handler.js +254 -0
- package/components/parse/src/app-plus/html/js/uni.webview.min.js +188 -0
- package/components/parse/src/app-plus/html/local.html +32 -0
- package/components/parse/src/composables/index.ts +1 -0
- package/components/parse/src/composables/use-parse.ts +428 -0
- package/components/parse/src/node/node.vue +635 -0
- package/components/parse/src/parse.ts +156 -0
- package/components/parse/src/parse.vue +131 -0
- package/components/parse/src/parser.ts +1402 -0
- package/components/picker/index.ts +1 -0
- package/components/picker/src/composables/index.ts +2 -0
- package/components/picker/src/composables/picker-custom.ts +40 -0
- package/components/picker/src/composables/use-picker.ts +179 -0
- package/components/picker/src/picker.ts +172 -0
- package/components/picker/src/picker.vue +197 -0
- package/components/popup/index.ts +1 -0
- package/components/popup/src/composables/index.ts +1 -0
- package/components/popup/src/composables/use-popup.ts +346 -0
- package/components/popup/src/keypress.ts +55 -0
- package/components/popup/src/popup.ts +101 -0
- package/components/popup/src/popup.vue +204 -0
- package/components/progress/index.ts +1 -0
- package/components/progress/src/composables/index.ts +2 -0
- package/components/progress/src/composables/progress-custom.ts +24 -0
- package/components/progress/src/composables/use-progress.ts +159 -0
- package/components/progress/src/progress.ts +84 -0
- package/components/progress/src/progress.vue +150 -0
- package/components/rate/index.ts +1 -0
- package/components/rate/src/composables/index.ts +1 -0
- package/components/rate/src/composables/use-rate.ts +196 -0
- package/components/rate/src/rate.ts +114 -0
- package/components/rate/src/rate.vue +113 -0
- package/components/read-more/index.ts +1 -0
- package/components/read-more/src/composables/index.ts +2 -0
- package/components/read-more/src/composables/read-more-custom.ts +46 -0
- package/components/read-more/src/composables/use-read-more.ts +72 -0
- package/components/read-more/src/read-more.ts +102 -0
- package/components/read-more/src/read-more.vue +104 -0
- package/components/safe-bottom/index.ts +1 -0
- package/components/safe-bottom/src/composables/index.ts +2 -0
- package/components/safe-bottom/src/composables/safe-bottom-custom.ts +18 -0
- package/components/safe-bottom/src/composables/use-safe-bottom.ts +17 -0
- package/components/safe-bottom/src/safe-bottom.ts +8 -0
- package/components/safe-bottom/src/safe-bottom.vue +43 -0
- package/components/scroll-list/index.ts +1 -0
- package/components/scroll-list/src/composables/index.ts +2 -0
- package/components/scroll-list/src/composables/scroll-list-custom.ts +41 -0
- package/components/scroll-list/src/composables/use-scroll-list.ts +126 -0
- package/components/scroll-list/src/scroll-list.ts +57 -0
- package/components/scroll-list/src/scroll-list.vue +143 -0
- package/components/{fu-scroll-list/scrollWxs.wxs → scroll-list/src/scroll-wxs.wxs} +2 -2
- package/components/search/index.ts +1 -0
- package/components/search/src/composables/index.ts +2 -0
- package/components/search/src/composables/search-custom.ts +25 -0
- package/components/search/src/composables/use-search.ts +106 -0
- package/components/search/src/search.ts +186 -0
- package/components/{fu-search/fu-search.vue → search/src/search.vue} +42 -154
- package/components/section/index.ts +1 -0
- package/components/section/src/composables/index.ts +1 -0
- package/components/section/src/composables/use-section.ts +19 -0
- package/components/section/src/section.ts +83 -0
- package/components/{fu-section/fu-section.vue → section/src/section.vue} +36 -35
- package/components/sign-board/index.ts +1 -0
- package/components/sign-board/src/composables/index.ts +1 -0
- package/components/sign-board/src/composables/use-sign-board.ts +552 -0
- package/components/sign-board/src/sign-board.ts +48 -0
- package/components/sign-board/src/sign-board.vue +191 -0
- package/components/skeleton/index.ts +1 -0
- package/components/skeleton/src/composables/index.ts +2 -0
- package/components/skeleton/src/composables/skeleton-custom.ts +23 -0
- package/components/skeleton/src/composables/use-skeleton.ts +102 -0
- package/components/skeleton/src/skeleton.ts +37 -0
- package/components/skeleton/src/skeleton.vue +147 -0
- package/components/status-bar/src/composables/index.ts +1 -0
- package/components/status-bar/src/composables/use-status-bar.ts +29 -0
- package/components/status-bar/src/status-bar.vue +21 -0
- package/components/steps/index.ts +1 -0
- package/components/steps/src/composables/index.ts +1 -0
- package/components/steps/src/composables/use-steps.ts +27 -0
- package/components/steps/src/steps.ts +65 -0
- package/components/steps/src/steps.vue +46 -0
- package/components/steps-item/index.ts +1 -0
- package/components/steps-item/src/composables/index.ts +2 -0
- package/components/steps-item/src/composables/steps-item-custom.ts +81 -0
- package/components/steps-item/src/composables/use-steps-item.ts +87 -0
- package/components/steps-item/src/steps-item.ts +38 -0
- package/components/steps-item/src/steps-item.vue +224 -0
- package/components/sticky/index.ts +1 -0
- package/components/sticky/src/composables/index.ts +2 -0
- package/components/sticky/src/composables/sticky-custom.ts +57 -0
- package/components/sticky/src/composables/use-sticky.ts +152 -0
- package/components/sticky/src/sticky.ts +62 -0
- package/components/sticky/src/sticky.vue +65 -0
- package/components/subsection/index.ts +1 -0
- package/components/subsection/src/composables/index.ts +2 -0
- package/components/subsection/src/composables/subsection-custom.ts +71 -0
- package/components/subsection/src/composables/use-subsection.ts +85 -0
- package/components/subsection/src/subsection.ts +107 -0
- package/components/subsection/src/subsection.vue +165 -0
- package/components/swipe-action/src/composables/index.ts +1 -0
- package/components/swipe-action/src/composables/use-swipe-action.ts +58 -0
- package/components/swipe-action/src/swipe-action.vue +81 -0
- package/components/swipe-action-item/index.ts +1 -0
- package/components/{fu-swipe-action-item/mpwxs.js → swipe-action-item/src/mpwxs.ts} +22 -27
- package/components/swipe-action-item/src/swipe-action-item.ts +68 -0
- package/components/{fu-swipe-action-item/fu-swipe-action-item.vue → swipe-action-item/src/swipe-action-item.vue} +24 -17
- package/components/{fu-swipe-action-item → swipe-action-item/src}/wx.wxs +2 -2
- package/components/swiper/index.ts +1 -0
- package/components/swiper/src/composables/index.ts +2 -0
- package/components/swiper/src/composables/swiper-custom.ts +40 -0
- package/components/swiper/src/composables/use-swiper.ts +75 -0
- package/components/swiper/src/swiper.ts +189 -0
- package/components/{fu-swiper/fu-swiper.vue → swiper/src/swiper.vue} +49 -118
- package/components/switch/index.ts +1 -0
- package/components/switch/src/composables/index.ts +2 -0
- package/components/switch/src/composables/switch-custom.ts +32 -0
- package/components/switch/src/composables/use-switch.ts +38 -0
- package/components/switch/src/switch.ts +115 -0
- package/components/{fu-switch/fu-switch.vue → switch/src/switch.vue} +25 -73
- package/components/tabs/index.ts +1 -0
- package/components/tabs/src/composables/index.ts +2 -0
- package/components/tabs/src/composables/tabs-custom.ts +43 -0
- package/components/tabs/src/composables/use-tabs.ts +210 -0
- package/components/tabs/src/tabs.ts +123 -0
- package/components/tabs/src/tabs.vue +153 -0
- package/components/tag/index.ts +1 -0
- package/components/tag/src/composables/index.ts +2 -0
- package/components/tag/src/composables/tag-custom.ts +61 -0
- package/components/tag/src/composables/use-tag.ts +23 -0
- package/components/tag/src/tag.ts +159 -0
- package/components/{fu-tag/fu-tag.vue → tag/src/tag.vue} +53 -93
- package/components/text/index.ts +1 -0
- package/components/text/src/composables/index.ts +2 -0
- package/components/text/src/composables/text-custom.ts +120 -0
- package/components/text/src/composables/use-text.ts +83 -0
- package/components/text/src/text.ts +261 -0
- package/components/text/src/text.vue +186 -0
- package/components/textarea/index.ts +1 -0
- package/components/textarea/src/composables/index.ts +2 -0
- package/components/textarea/src/composables/textarea-custom.ts +50 -0
- package/components/textarea/src/composables/use-textarea.ts +88 -0
- package/components/textarea/src/textarea.ts +250 -0
- package/components/textarea/src/textarea.vue +162 -0
- package/components/{fu-timeaxis/fu-timeaxis.vue → timeaxis/src/timeaxis.vue} +3 -9
- package/components/timeaxis-item/index.ts +1 -0
- package/components/timeaxis-item/src/timeaxis-item.ts +20 -0
- package/components/timeaxis-item/src/timeaxis-item.vue +50 -0
- package/components/transition/index.ts +1 -0
- package/components/transition/src/composables/createAnimation.ts +171 -0
- package/components/transition/src/composables/index.ts +2 -0
- package/components/transition/src/composables/transform-custom.ts +18 -0
- package/components/transition/src/composables/use-transition.ts +251 -0
- package/components/transition/src/transition.ts +64 -0
- package/components/transition/src/transition.vue +70 -0
- package/components/upload/index.ts +1 -0
- package/components/upload/src/composables/index.ts +5 -0
- package/components/upload/src/composables/upload-file-custom.ts +68 -0
- package/components/upload/src/composables/upload-image-custom.ts +76 -0
- package/components/upload/src/composables/use-upload-file.ts +27 -0
- package/components/upload/src/composables/use-upload-image.ts +38 -0
- package/components/upload/src/composables/use-upload.ts +388 -0
- package/components/upload/src/upload-file.ts +84 -0
- package/components/upload/src/upload-file.vue +193 -0
- package/components/upload/src/upload-image.ts +90 -0
- package/components/upload/src/upload-image.vue +158 -0
- package/components/upload/src/upload.ts +196 -0
- package/components/upload/src/upload.vue +151 -0
- package/components/{fu-upload/utils.js → upload/src/utils.ts} +12 -12
- package/components/vtabs/index.ts +1 -0
- package/components/vtabs/src/composables/index.ts +2 -0
- package/components/vtabs/src/composables/use-vtabs.ts +276 -0
- package/components/vtabs/src/composables/vtabs-custom.ts +54 -0
- package/components/vtabs/src/vtabs.ts +130 -0
- package/components/vtabs/src/vtabs.vue +189 -0
- package/components/vtabs-item/index.ts +1 -0
- package/components/vtabs-item/src/composables/index.ts +1 -0
- package/components/vtabs-item/src/composables/use-vtabs-item.ts +60 -0
- package/components/vtabs-item/src/vtabs-item.ts +10 -0
- package/components/vtabs-item/src/vtabs-item.vue +20 -0
- package/components/waterfall/index.ts +1 -0
- package/components/waterfall/src/composables/index.ts +2 -0
- package/components/waterfall/src/composables/use-waterfall.ts +139 -0
- package/components/waterfall/src/composables/waterfall-custom.ts +18 -0
- package/components/waterfall/src/waterfall.ts +114 -0
- package/components/waterfall/src/waterfall.vue +104 -0
- package/{libs/config/config.js → config/config.ts} +13 -7
- package/constants/images.ts +18 -0
- package/constants/index.ts +6 -0
- package/constants/open-types.ts +33 -0
- package/constants/props.ts +18 -0
- package/constants/shapes.ts +6 -0
- package/constants/types.ts +10 -0
- package/constants/z-index.ts +27 -0
- package/global.d.ts +103 -0
- package/hooks/index.ts +25 -0
- package/index.scss +3 -5
- package/index.ts +56 -0
- package/package.json +1 -1
- package/{libs/route/min.route.config.js → route/min.route.config.ts} +62 -23
- package/route/route.config.ts +93 -0
- package/style/color.scss +26 -0
- package/{libs/style → style}/common.scss +1 -14
- package/{libs/function/applyEven.js → utils/applyEven.ts} +21 -12
- package/utils/check.ts +276 -0
- package/{libs/function/chooseUploadFile.js → utils/chooseUploadFile.ts} +22 -26
- package/utils/common.ts +609 -0
- package/{libs/function/digit.js → utils/digit.ts} +63 -33
- package/{components/fu-swipe-action-item/isPC.js → utils/isPC.ts} +1 -1
- package/utils/toast.ts +42 -0
- package/components/fu-avatar/fu-avatar.vue +0 -157
- package/components/fu-avatar/props.js +0 -117
- package/components/fu-avatar-group/props.js +0 -74
- package/components/fu-badge/props.js +0 -112
- package/components/fu-banner-arc/fu-banner-arc.vue +0 -58
- package/components/fu-banner-arc/props.js +0 -35
- package/components/fu-button/props.js +0 -228
- package/components/fu-cell/props.js +0 -108
- package/components/fu-cell-group/props.js +0 -19
- package/components/fu-checkbox/fu-checkbox.vue +0 -469
- package/components/fu-checkbox/props.js +0 -126
- package/components/fu-code-input/fu-code-input.vue +0 -269
- package/components/fu-code-input/props.js +0 -136
- package/components/fu-code-verify/fu-code-verify.vue +0 -221
- package/components/fu-code-verify/props.js +0 -136
- package/components/fu-collapse/fu-collapse.vue +0 -143
- package/components/fu-collapse/props.js +0 -29
- package/components/fu-collapse-item/props.js +0 -101
- package/components/fu-countdown/fu-countdown.vue +0 -164
- package/components/fu-countdown/props.js +0 -35
- package/components/fu-datetime-picker/fu-datetime-picker.vue +0 -375
- package/components/fu-datetime-picker/props.js +0 -194
- package/components/fu-form/fu-form.vue +0 -284
- package/components/fu-form/props.js +0 -74
- package/components/fu-form-item/fu-form-item.vue +0 -535
- package/components/fu-form-item/props.js +0 -66
- package/components/fu-grid/fu-grid.vue +0 -113
- package/components/fu-grid/props.js +0 -44
- package/components/fu-grid-item/fu-grid-item.vue +0 -136
- package/components/fu-grid-item/props.js +0 -27
- package/components/fu-icon/fu-icon.vue +0 -110
- package/components/fu-icon/fuicon.js +0 -1031
- package/components/fu-icon/props.js +0 -55
- package/components/fu-image/fu-image.vue +0 -268
- package/components/fu-image/props.js +0 -145
- package/components/fu-index-anchor/fu-index-anchor.vue +0 -91
- package/components/fu-index-anchor/props.js +0 -43
- package/components/fu-index-item/fu-index-item.vue +0 -79
- package/components/fu-index-list/fu-index-list.vue +0 -426
- package/components/fu-index-list/props.js +0 -42
- package/components/fu-input/fu-input.vue +0 -393
- package/components/fu-input/props.js +0 -291
- package/components/fu-keyboard/keyboard-number.vue +0 -195
- package/components/fu-keyboard/props.js +0 -138
- package/components/fu-line/fu-line.vue +0 -64
- package/components/fu-line/props.js +0 -58
- package/components/fu-link/fu-link.vue +0 -91
- package/components/fu-link/props.js +0 -49
- package/components/fu-loading/props.js +0 -60
- package/components/fu-loading-more/props.js +0 -59
- package/components/fu-modal/props.js +0 -128
- package/components/fu-navbar/fu-navbar.vue +0 -271
- package/components/fu-navbar/props.js +0 -72
- package/components/fu-navbar/status-bar.vue +0 -27
- package/components/fu-notice-bar/notice-column.vue +0 -313
- package/components/fu-notice-bar/notice-row.vue +0 -363
- package/components/fu-notice-bar/props.js +0 -173
- package/components/fu-number-box/fu-number-box.vue +0 -210
- package/components/fu-number-box/props.js +0 -79
- package/components/fu-parse/fu-parse.vue +0 -508
- package/components/fu-parse/node/node.vue +0 -576
- package/components/fu-parse/parser.js +0 -1335
- package/components/fu-picker/fu-picker.vue +0 -347
- package/components/fu-picker/props.js +0 -150
- package/components/fu-popup/fu-popup.vue +0 -475
- package/components/fu-popup/keypress.js +0 -45
- package/components/fu-popup/props.js +0 -83
- package/components/fu-progress/fu-progress.vue +0 -292
- package/components/fu-progress/props.js +0 -76
- package/components/fu-rate/fu-rate.vue +0 -301
- package/components/fu-rate/props.js +0 -103
- package/components/fu-read-more/fu-read-more.vue +0 -191
- package/components/fu-read-more/props.js +0 -72
- package/components/fu-ribbon/fu-ribbon.vue +0 -106
- package/components/fu-ribbon/props.js +0 -35
- package/components/fu-safe-area/fu-safe-area.vue +0 -61
- package/components/fu-scroll-list/fu-scroll-list.vue +0 -196
- package/components/fu-scroll-list/nvue.js +0 -28
- package/components/fu-scroll-list/props.js +0 -43
- package/components/fu-search/props.js +0 -149
- package/components/fu-section/props.js +0 -59
- package/components/fu-sign-board/fu-sign-board.vue +0 -730
- package/components/fu-sign-board/props.js +0 -34
- package/components/fu-skeleton/fu-skeleton.vue +0 -238
- package/components/fu-skeleton/props.js +0 -35
- package/components/fu-steps/fu-steps.vue +0 -81
- package/components/fu-steps/props.js +0 -55
- package/components/fu-steps-item/fu-steps-item.vue +0 -274
- package/components/fu-steps-item/props.js +0 -34
- package/components/fu-sticky/fu-sticky.vue +0 -232
- package/components/fu-sticky/props.js +0 -54
- package/components/fu-subsection/fu-subsection.vue +0 -288
- package/components/fu-subsection/props.js +0 -88
- package/components/fu-swipe-action/fu-swipe-action.vue +0 -64
- package/components/fu-swipe-action-item/props.js +0 -54
- package/components/fu-swiper/props.js +0 -163
- package/components/fu-switch/props.js +0 -102
- package/components/fu-tabs/fu-tabs.vue +0 -361
- package/components/fu-tabs/props.js +0 -109
- package/components/fu-tag/props.js +0 -135
- package/components/fu-text/button.js +0 -13
- package/components/fu-text/fu-text.vue +0 -254
- package/components/fu-text/openType.js +0 -47
- package/components/fu-text/props.js +0 -173
- package/components/fu-text/value.js +0 -88
- package/components/fu-textarea/fu-textarea.vue +0 -288
- package/components/fu-textarea/props.js +0 -206
- package/components/fu-timeaxis-item/fu-timeaxis-item.vue +0 -68
- package/components/fu-transition/createAnimation.js +0 -131
- package/components/fu-transition/fu-transition.vue +0 -292
- package/components/fu-transition/props.js +0 -21
- package/components/fu-upload/fu-upload.vue +0 -563
- package/components/fu-upload/props.js +0 -171
- package/components/fu-upload/upload-file.vue +0 -332
- package/components/fu-upload/upload-image.vue +0 -304
- package/components/fu-vtabs/fu-vtabs.vue +0 -443
- package/components/fu-vtabs/props.js +0 -114
- package/components/fu-vtabs-item/fu-vtabs-item.vue +0 -71
- package/components/fu-waterfall/fu-waterfall.vue +0 -238
- package/components/fu-waterfall/props.js +0 -85
- package/index.js +0 -71
- package/libs/function/check.js +0 -215
- package/libs/function/common.js +0 -527
- package/libs/function/message.js +0 -47
- package/libs/mixin/button.js +0 -85
- package/libs/mixin/mixin.js +0 -94
- package/libs/mixin/mpMixin.js +0 -8
- package/libs/mixin/mpShare.js +0 -15
- package/libs/route/route.config.js +0 -66
- package/libs/style/color.scss +0 -24
- /package/components/{fu-icon → icon/src}/fuicon.ttf +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/bindingx.js +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/mpalipay.js +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/mpother.js +0 -0
- /package/components/{fu-swipe-action-item → swipe-action-item/src}/render.js +0 -0
- /package/{libs/style → style}/components.scss +0 -0
- /package/{libs/style → style}/style.h5.scss +0 -0
- /package/{libs/style → style}/style.mp.scss +0 -0
- /package/{libs/function → utils}/dayjs.js +0 -0
package/utils/common.ts
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import { getCurrentInstance, type ComponentInternalInstance } from 'vue';
|
|
2
|
+
import check from './check'
|
|
3
|
+
import digit from './digit'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description 获取父组件实例
|
|
7
|
+
*
|
|
8
|
+
* @param {string} componentName 父组件名称
|
|
9
|
+
* @description 获取父组件实例,如果没有找到则返回null
|
|
10
|
+
* @example $parent('components') // => 父组件实例
|
|
11
|
+
* @example $parent() // => 直接父组件实例
|
|
12
|
+
*/
|
|
13
|
+
const $parent = (componentName?: string, instance?: ComponentInternalInstance) => {
|
|
14
|
+
const componentInstance: ComponentInternalInstance = instance || getCurrentInstance();
|
|
15
|
+
if (!componentInstance) return null;
|
|
16
|
+
let parent = componentInstance.parent;
|
|
17
|
+
if (!componentName) return parent;
|
|
18
|
+
while (parent) {
|
|
19
|
+
if (
|
|
20
|
+
(parent.type && parent.type.name === componentName) ||
|
|
21
|
+
(parent.type && parent.type.__name === componentName)
|
|
22
|
+
) {
|
|
23
|
+
return parent;
|
|
24
|
+
}
|
|
25
|
+
parent = parent.parent;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @description 样式转换, 对象转字符串, 或者字符串转对象
|
|
32
|
+
*
|
|
33
|
+
* @param {string|object} customStyle 需要转换的目标
|
|
34
|
+
* @param {string} target 转换的目的,object-转为对象,string-转为字符串
|
|
35
|
+
* @returns {object|string}
|
|
36
|
+
* @example addStyle('font-size: 14px; color: red;') // => {fontSize: '14px', color: 'red'}
|
|
37
|
+
* @example addStyle('font-size: 14px; color: red;', 'string') // => 'font-size: 14px; color: red;'
|
|
38
|
+
*/
|
|
39
|
+
function addStyle(customStyle : string | object, target : 'object' | 'string' = 'object') : string | object {
|
|
40
|
+
// 字符串转字符串,对象转对象情形,直接返回
|
|
41
|
+
if (check.isNull(customStyle) || typeof (customStyle) === 'object' && target === 'object' || target === 'string' && typeof (customStyle) === 'string') {
|
|
42
|
+
return customStyle
|
|
43
|
+
}
|
|
44
|
+
// 字符串转对象
|
|
45
|
+
if (target === 'object') {
|
|
46
|
+
if (typeof customStyle !== 'string') {
|
|
47
|
+
return customStyle; // 如果不是字符串,直接返回
|
|
48
|
+
}
|
|
49
|
+
// 去除字符串样式中的两端空格(中间的空格不能去掉,比如padding: 14px 0如果去掉了就错了),空格是无用的
|
|
50
|
+
customStyle = trim(customStyle);
|
|
51
|
+
// 根据";"将字符串转为数组形式
|
|
52
|
+
const styleArray = customStyle.split(';');
|
|
53
|
+
const style = {};
|
|
54
|
+
// 历遍数组,拼接成对象
|
|
55
|
+
for (let i = 0; i < styleArray.length; i++) {
|
|
56
|
+
// 'font-size:14px;color:red;',如此最后字符串有";"的话,会导致styleArray最后一个元素为空字符串,这里需要过滤
|
|
57
|
+
if (styleArray[i]) {
|
|
58
|
+
const item = styleArray[i].split(':')
|
|
59
|
+
style[trim(item[0])] = trim(item[1])
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return style
|
|
63
|
+
}
|
|
64
|
+
// 这里为对象转字符串形式
|
|
65
|
+
let string = '';
|
|
66
|
+
if (customStyle && typeof customStyle === 'object') {
|
|
67
|
+
for (const i in customStyle) {
|
|
68
|
+
// 驼峰转为中划线的形式,否则css内联样式,无法识别驼峰样式属性名
|
|
69
|
+
const key = i.replace(/([A-Z])/g, '-$1').toLowerCase()
|
|
70
|
+
string += `${key}:${customStyle[i]};`
|
|
71
|
+
}
|
|
72
|
+
// 去除两端空格
|
|
73
|
+
return trim(string);
|
|
74
|
+
}
|
|
75
|
+
return ''
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @description 添加单位,如果有rpx,upx,%,px等单位结尾或者值为auto,直接返回,否则加上px单位结尾
|
|
80
|
+
*
|
|
81
|
+
* @param {string|number} value 需要添加单位的值
|
|
82
|
+
* @param {string} unit 添加的单位名 比如px
|
|
83
|
+
* @example addUnit(14) // => '14px'
|
|
84
|
+
* @example addUnit(14, 'upx') // => '14upx'
|
|
85
|
+
*/
|
|
86
|
+
function addUnit(value : string | number = 'auto', unit : string = uni.$fu.config.unit || 'px') {
|
|
87
|
+
value = String(value)
|
|
88
|
+
// 用Fusions内置验证规则中的checkNumber判断是否为数值
|
|
89
|
+
return check.checkNumber(value) ? `${value}${unit}` : value
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @description 深度克隆
|
|
94
|
+
*
|
|
95
|
+
* @param {object} obj 需要深度克隆的对象
|
|
96
|
+
* @param cache 缓存
|
|
97
|
+
* @returns {*} 克隆后的对象或者原值(不是对象)
|
|
98
|
+
*/
|
|
99
|
+
function deepClone<T>(obj : T, cache = new WeakMap()) : T {
|
|
100
|
+
if (obj === null || typeof obj !== 'object') return obj;
|
|
101
|
+
if (cache.has(obj)) return cache.get(obj);
|
|
102
|
+
if (obj instanceof Date) return new Date(obj.getTime()) as unknown as T;
|
|
103
|
+
if (obj instanceof RegExp) return new RegExp(obj) as unknown as T;
|
|
104
|
+
if (obj instanceof Map) {
|
|
105
|
+
const clone = new Map();
|
|
106
|
+
cache.set(obj, clone);
|
|
107
|
+
obj.forEach((value, key) => {
|
|
108
|
+
clone.set(deepClone(key, cache), deepClone(value, cache));
|
|
109
|
+
});
|
|
110
|
+
return clone as unknown as T;
|
|
111
|
+
}
|
|
112
|
+
if (obj instanceof Set) {
|
|
113
|
+
const clone = new Set();
|
|
114
|
+
cache.set(obj, clone);
|
|
115
|
+
obj.forEach(value => {
|
|
116
|
+
clone.add(deepClone(value, cache));
|
|
117
|
+
});
|
|
118
|
+
return clone as unknown as T;
|
|
119
|
+
}
|
|
120
|
+
if (obj instanceof Symbol) return Object(Symbol.prototype.valueOf.call(obj)) as unknown as T;
|
|
121
|
+
if (obj instanceof Function) return obj;
|
|
122
|
+
|
|
123
|
+
if (Array.isArray(obj)) {
|
|
124
|
+
const clone = [] as unknown as T;
|
|
125
|
+
cache.set(obj, clone);
|
|
126
|
+
obj.forEach((value, index) => {
|
|
127
|
+
(clone as unknown as any[])[index] = deepClone(value, cache);
|
|
128
|
+
});
|
|
129
|
+
return clone;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (Object.prototype.toString.call(obj) === '[object Object]') {
|
|
133
|
+
const clone = Object.create(Object.getPrototypeOf(obj));
|
|
134
|
+
cache.set(obj, clone);
|
|
135
|
+
Object.keys(obj).forEach(key => {
|
|
136
|
+
(clone as any)[key] = deepClone((obj as any)[key], cache);
|
|
137
|
+
});
|
|
138
|
+
return clone;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const clone = Object.assign({}, obj);
|
|
142
|
+
cache.set(obj, clone);
|
|
143
|
+
return clone;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @description 深度合并对象
|
|
148
|
+
*
|
|
149
|
+
* @param {object} target 需要拷贝的对象
|
|
150
|
+
* @param {object} source 拷贝的来源对象
|
|
151
|
+
* @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象)
|
|
152
|
+
*/
|
|
153
|
+
function deepMerge<T extends object, S extends object>(target : T = {} as T, source : S = {} as S) : object | boolean {
|
|
154
|
+
target = deepClone(target);
|
|
155
|
+
if (
|
|
156
|
+
typeof target !== 'object' || target === null || typeof source !== 'object' || source === null
|
|
157
|
+
)
|
|
158
|
+
return target;
|
|
159
|
+
const merged : any = Array.isArray(target) ? target.slice() : Object.assign({}, target);
|
|
160
|
+
for (const prop in source) {
|
|
161
|
+
if (!Object.prototype.hasOwnProperty.call(source, prop)) continue;
|
|
162
|
+
const sourceValue = (source as any)[prop];
|
|
163
|
+
const targetValue = merged[prop];
|
|
164
|
+
|
|
165
|
+
if (sourceValue instanceof Date) {
|
|
166
|
+
merged[prop] = new Date(sourceValue);
|
|
167
|
+
} else if (sourceValue instanceof RegExp) {
|
|
168
|
+
merged[prop] = new RegExp(sourceValue);
|
|
169
|
+
} else if (sourceValue instanceof Map) {
|
|
170
|
+
merged[prop] = new Map(sourceValue);
|
|
171
|
+
} else if (sourceValue instanceof Set) {
|
|
172
|
+
merged[prop] = new Set(sourceValue);
|
|
173
|
+
} else if (typeof sourceValue === 'object' && sourceValue !== null) {
|
|
174
|
+
merged[prop] = deepMerge(targetValue, sourceValue);
|
|
175
|
+
} else {
|
|
176
|
+
merged[prop] = sourceValue;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return merged;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @description 全局唯一标识符
|
|
184
|
+
*
|
|
185
|
+
* @param {Number} len uuid的长度
|
|
186
|
+
* @param {Boolean} firstFu 将返回的首字母置为"Fu"
|
|
187
|
+
* @param {Nubmer} radix 生成uuid的基数(意味着返回的字符串都是这个基数),2-二进制,8-八进制,10-十进制,16-十六进制
|
|
188
|
+
*/
|
|
189
|
+
function uuid(len : number = 32, firstFu : boolean = true, radix : number | null = null) {
|
|
190
|
+
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
|
191
|
+
const uuid = [];
|
|
192
|
+
radix = radix || chars.length;
|
|
193
|
+
if (len) {
|
|
194
|
+
// 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位
|
|
195
|
+
for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]
|
|
196
|
+
} else {
|
|
197
|
+
let r : number;
|
|
198
|
+
// rfc4122标准要求返回的uuid中,某些位为固定的字符
|
|
199
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
200
|
+
uuid[14] = '4';
|
|
201
|
+
for (let i = 0; i < 36; i++) {
|
|
202
|
+
if (!uuid[i]) {
|
|
203
|
+
r = 0 | Math.random() * 16;
|
|
204
|
+
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// 移除第一个字符,并用fu替代,因为第一个字符为数值时,该guid不能用作id或者class
|
|
209
|
+
if (firstFu) {
|
|
210
|
+
uuid.shift()
|
|
211
|
+
return `fu${uuid.join('')}`
|
|
212
|
+
}
|
|
213
|
+
return uuid.join('')
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @description error提示
|
|
218
|
+
*
|
|
219
|
+
* @param {*} err 错误内容
|
|
220
|
+
*/
|
|
221
|
+
function error(err : string) {
|
|
222
|
+
// 开发环境才提示,生产环境不会提示
|
|
223
|
+
if (process.env.NODE_ENV === 'development') {
|
|
224
|
+
console.error(`Fusions提示:${err}`)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @description 返回一个在[min, max]范围内的随机整数
|
|
230
|
+
*
|
|
231
|
+
* @param {number} min 最小值
|
|
232
|
+
* @param {number} max 最大值
|
|
233
|
+
*/
|
|
234
|
+
function random(min : number, max : number) {
|
|
235
|
+
if (min >= 0 && max > 0 && max >= min) {
|
|
236
|
+
const gab = max - min + 1
|
|
237
|
+
return Math.floor(Math.random() * gab + min)
|
|
238
|
+
}
|
|
239
|
+
return 0
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @description 打乱数组
|
|
244
|
+
*
|
|
245
|
+
* @param {array} array 需要打乱的数组
|
|
246
|
+
* @returns {array} 打乱后返回的数组
|
|
247
|
+
*/
|
|
248
|
+
function randomArray(array : any[]) : Array<any> {
|
|
249
|
+
// 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
|
|
250
|
+
return array.sort(() => Math.random() - 0.5)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @description 如果value小于min,取min;如果value大于max,取max
|
|
255
|
+
*
|
|
256
|
+
* @param {number} min
|
|
257
|
+
* @param {number} max
|
|
258
|
+
* @param {number} value
|
|
259
|
+
*/
|
|
260
|
+
function range(min : number, max : number, value : number) {
|
|
261
|
+
return Math.max(min, Math.min(max, Number(value)))
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @description 数字格式化
|
|
266
|
+
* @param {string|number} number 要格式化的数字
|
|
267
|
+
* @param {number} decimals 保留几位小数
|
|
268
|
+
* @param {string} decimalPoint 小数点符号
|
|
269
|
+
* @param {string} thousandsSeparator 千分位符号
|
|
270
|
+
* @returns {string} 格式化后的数字
|
|
271
|
+
*/
|
|
272
|
+
function priceFormat(number : string | number, decimals : number = 0, decimalPoint : string = '.', thousandsSeparator : string = ',') : string {
|
|
273
|
+
number = (`${number}`).replace(/[^0-9+-Ee.]/g, '')
|
|
274
|
+
const n = !isFinite(+number) ? 0 : +number
|
|
275
|
+
const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals)
|
|
276
|
+
const sep = (typeof thousandsSeparator === 'undefined') ? ',' : thousandsSeparator
|
|
277
|
+
const dec = (typeof decimalPoint === 'undefined') ? '.' : decimalPoint
|
|
278
|
+
let s : string[] = [];
|
|
279
|
+
|
|
280
|
+
s = (prec ? digit.round(n, prec) + '' : `${Math.round(n)}`).split('.')
|
|
281
|
+
const re = /(-?\d+)(\d{3})/
|
|
282
|
+
while (re.test(s[0])) {
|
|
283
|
+
s[0] = s[0].replace(re, `$1${sep}$2`)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if ((s[1] || '').length < prec) {
|
|
287
|
+
s[1] = s[1] || ''
|
|
288
|
+
s[1] += new Array(prec - s[1].length + 1).join('0')
|
|
289
|
+
}
|
|
290
|
+
return s.join(dec)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @description 年月日 时分秒转时间戳
|
|
295
|
+
*
|
|
296
|
+
* @param {string} value 日期
|
|
297
|
+
* @returns 毫秒
|
|
298
|
+
*/
|
|
299
|
+
function formatTimestamp(value : string) {
|
|
300
|
+
const time = new Date(value);
|
|
301
|
+
const timestamp = time.getTime();
|
|
302
|
+
return timestamp
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @param {string|number} value:数据转化
|
|
307
|
+
*/
|
|
308
|
+
function formatNumber(value : string | number) {
|
|
309
|
+
value = value.toString()
|
|
310
|
+
|
|
311
|
+
return value[1] ? value : '0' + value
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @description 时间戳转化为年 月 日 时 分 秒
|
|
316
|
+
*
|
|
317
|
+
* @param {string|number} value 传入时间戳(秒/毫秒)
|
|
318
|
+
* @param {String} format 返回格式,支持自定义,但参数必须与formateArr里保持一致
|
|
319
|
+
* @returns {string} 返回格式化后的字符串
|
|
320
|
+
* @example formatTime(时间戳, 'Y-M-D h:m:s')
|
|
321
|
+
*/
|
|
322
|
+
function formatTime(value ?: Date | string | number, format : string = 'Y-M-D h:m:s') : string {
|
|
323
|
+
var formateArr = ['Y', 'M', 'D', 'h', 'm', 's'];
|
|
324
|
+
var date : Date;
|
|
325
|
+
// 判断传入的时间为假值,则取当前时间
|
|
326
|
+
if (!value) {
|
|
327
|
+
date = new Date()
|
|
328
|
+
}
|
|
329
|
+
// 若为unit秒时间戳,则转为毫秒时间戳
|
|
330
|
+
else if (/^\d{10}$/.test(value?.toString().trim())) {
|
|
331
|
+
date = new Date(Number(value) * 1000);
|
|
332
|
+
}
|
|
333
|
+
// 若用户传入字符串格式时间戳,new Date无法解析
|
|
334
|
+
else if (typeof value === 'string' && /^\d+$/.test(value.trim())) {
|
|
335
|
+
date = new Date(Number(value));
|
|
336
|
+
}
|
|
337
|
+
// 处理平台性差异,在Safari/Webkit中,new Date仅支持/作为分割符的字符串时间
|
|
338
|
+
// 处理 '2025-12-15 05:15:25',跳过 '2025-12-15T05:15:25'
|
|
339
|
+
else if (typeof value === 'string' && value.includes('-') && !value.includes('T')) {
|
|
340
|
+
date = new Date(value.replace(/-/g, '/'))
|
|
341
|
+
}
|
|
342
|
+
// 其他都认为符合 RFC 2822 规范
|
|
343
|
+
else {
|
|
344
|
+
date = new Date(value)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const returnArr = [
|
|
348
|
+
date.getFullYear().toString(),
|
|
349
|
+
formatNumber(date.getMonth() + 1),
|
|
350
|
+
formatNumber(date.getDate()),
|
|
351
|
+
formatNumber(date.getHours()),
|
|
352
|
+
formatNumber(date.getMinutes()),
|
|
353
|
+
formatNumber(date.getSeconds())
|
|
354
|
+
];
|
|
355
|
+
|
|
356
|
+
for (var i in returnArr) {
|
|
357
|
+
format = format.replace(formateArr[i], returnArr[i]);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return format;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* @description 时间戳转为多久之前
|
|
365
|
+
* @param {string|number} value 时间戳
|
|
366
|
+
* @param {string|boolean} format
|
|
367
|
+
* 格式化规则如果为时间格式字符串,超出一定时间范围,返回固定的时间格式;
|
|
368
|
+
* 如果为布尔值false,无论什么时间,都返回多久以前的格式
|
|
369
|
+
* @returns {string} 转化后的内容
|
|
370
|
+
* @example timeAgo(时间戳, format)
|
|
371
|
+
*/
|
|
372
|
+
function timeAgo(value : string | number | Date, format : string | false = 'Y-M-D') : string {
|
|
373
|
+
// 获取时间戳
|
|
374
|
+
const timestamp = new Date(value).getTime();
|
|
375
|
+
if (isNaN(timestamp)) return '无效日期';
|
|
376
|
+
|
|
377
|
+
// 处理秒级时间戳
|
|
378
|
+
const ms = timestamp.toString().length === 10 ? timestamp * 1000 : timestamp;
|
|
379
|
+
|
|
380
|
+
// 计算时间差(秒)
|
|
381
|
+
const diff = Math.floor((Date.now() - ms) / 1000);
|
|
382
|
+
|
|
383
|
+
// 时间单位
|
|
384
|
+
const units = [
|
|
385
|
+
[60, '刚刚', 5], // 5分钟内
|
|
386
|
+
[3600, '分钟前', 60],
|
|
387
|
+
[86400, '小时前', 3600],
|
|
388
|
+
[2592000, '天前', 86400],
|
|
389
|
+
[31536000, '个月前', 2592000],
|
|
390
|
+
[Infinity, '年前', 31536000]
|
|
391
|
+
] as const;
|
|
392
|
+
|
|
393
|
+
for (const [limit, text, divisor] of units) {
|
|
394
|
+
if (diff < limit) {
|
|
395
|
+
return divisor === 5 ? text : `${Math.floor(diff / divisor)}${text}`;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// 超过1年且format为false时显示年前
|
|
400
|
+
if (format === false) {
|
|
401
|
+
return `${Math.floor(diff / 31536000)}年前`;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return formatTime(new Date(ms), format as string);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @description 去除空格
|
|
409
|
+
* @param {string} value 需要去除空格的字符串
|
|
410
|
+
* @param {string} pos both(左右)|left|right|all 默认both
|
|
411
|
+
*/
|
|
412
|
+
function trim(value : string, pos : 'both' | 'left' | 'right' | 'all' = 'both') : string {
|
|
413
|
+
value = String(value)
|
|
414
|
+
if (pos == 'both') {
|
|
415
|
+
return value.replace(/^\s+|\s+$/g, '')
|
|
416
|
+
}
|
|
417
|
+
if (pos == 'left') {
|
|
418
|
+
return value.replace(/^\s*/, '')
|
|
419
|
+
}
|
|
420
|
+
if (pos == 'right') {
|
|
421
|
+
return value.replace(/(\s*$)/g, '')
|
|
422
|
+
}
|
|
423
|
+
if (pos == 'all') {
|
|
424
|
+
return value.replace(/\s+/g, '')
|
|
425
|
+
}
|
|
426
|
+
return value
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.upx2px进行转换
|
|
431
|
+
* @param {number|string} value 用户传递值的px值
|
|
432
|
+
* @param {boolean} unit
|
|
433
|
+
* @returns {number|string}
|
|
434
|
+
*/
|
|
435
|
+
function getPx(value : string | number, unit : boolean = false) : number | string {
|
|
436
|
+
if (check.checkNumber(value)) {
|
|
437
|
+
return unit ? `${value}px` : Number(value)
|
|
438
|
+
}
|
|
439
|
+
// 如果带有rpx,先取出其数值部分,再转为px值
|
|
440
|
+
if (/(rpx|upx)$/.test(value.toString())) {
|
|
441
|
+
return unit ? `${uni.upx2px(parseInt(value.toString()))}px` : Number(uni.upx2px(parseInt(value.toString())))
|
|
442
|
+
}
|
|
443
|
+
return unit ? `${parseInt(value.toString())}px` : parseInt(value.toString())
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* @description 进行延时,以达到可以简写代码的目的
|
|
448
|
+
* @param {number} value 堵塞时间 单位ms 毫秒
|
|
449
|
+
* @example await sleep(2000);
|
|
450
|
+
@example sleep(2000).then(() => { console.log('延迟执行'); });
|
|
451
|
+
*/
|
|
452
|
+
function sleep(value : number = 30) {
|
|
453
|
+
return new Promise((resolve) => {
|
|
454
|
+
setTimeout(() => {
|
|
455
|
+
resolve(true)
|
|
456
|
+
}, value)
|
|
457
|
+
})
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @description 日期的月或日补零操作
|
|
462
|
+
* @param {string} value 需要补零的值
|
|
463
|
+
*/
|
|
464
|
+
function padZero(value : string) {
|
|
465
|
+
return `00${value}`.slice(-2)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @description 获取系统信息同步接口
|
|
470
|
+
* @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
|
|
471
|
+
*/
|
|
472
|
+
function sys() {
|
|
473
|
+
return uni.getSystemInfoSync()
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* @description 获取操作系统类型
|
|
478
|
+
* @returns {string} 返回操作系统类型,例如:'android', 'ios', 'windows'等(小写)
|
|
479
|
+
* @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台
|
|
480
|
+
* @example os() // => 'android'
|
|
481
|
+
*/
|
|
482
|
+
function os() : string {
|
|
483
|
+
// #ifdef APP || H5 || MP-WEIXIN
|
|
484
|
+
return uni.getDeviceInfo().platform.toLowerCase();
|
|
485
|
+
// #endif
|
|
486
|
+
// 微信小程序 从基础库 2.20.1 开始,本接口停止维护
|
|
487
|
+
// #ifndef APP || H5 || MP-WEIXIN
|
|
488
|
+
return uni.getSystemInfoSync().platform.toLowerCase();
|
|
489
|
+
// #endif
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @description 获取某个对象下的属性,用于通过类似'a.b.c'的形式去获取一个对象的的属性的形式
|
|
494
|
+
* @param {object} obj 对象
|
|
495
|
+
* @param {string} key 需要获取的属性字段
|
|
496
|
+
* @returns {*}
|
|
497
|
+
*/
|
|
498
|
+
function getProperty(obj : Record<string, any>, key : string) : any {
|
|
499
|
+
if (!obj) {
|
|
500
|
+
return
|
|
501
|
+
}
|
|
502
|
+
if (typeof key !== 'string' || key === '') {
|
|
503
|
+
return ''
|
|
504
|
+
}
|
|
505
|
+
if (key.indexOf('.') !== -1) {
|
|
506
|
+
const keys = key.split('.')
|
|
507
|
+
let firstObj = obj[keys[0]] || {}
|
|
508
|
+
|
|
509
|
+
for (let i = 1; i < keys.length; i++) {
|
|
510
|
+
if (firstObj) {
|
|
511
|
+
firstObj = firstObj[keys[i]]
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return firstObj
|
|
515
|
+
}
|
|
516
|
+
return obj[key]
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @description 设置对象的属性值,如果'a.b.c'的形式进行设置
|
|
521
|
+
* @param {object} obj 对象
|
|
522
|
+
* @param {string} key 需要设置的属性
|
|
523
|
+
* @param {string} value 设置的值
|
|
524
|
+
*/
|
|
525
|
+
function setProperty(obj : Record<string, any>, key : string, value : any) {
|
|
526
|
+
if (!obj) {
|
|
527
|
+
return
|
|
528
|
+
}
|
|
529
|
+
// 递归赋值
|
|
530
|
+
const inFn = function (_obj : Record<string, any>, keys : string[], v : any) {
|
|
531
|
+
// 最后一个属性key
|
|
532
|
+
if (keys.length === 1) {
|
|
533
|
+
_obj[keys[0]] = v
|
|
534
|
+
return
|
|
535
|
+
}
|
|
536
|
+
// 0~length-1个key
|
|
537
|
+
while (keys.length > 1) {
|
|
538
|
+
const k = keys[0]
|
|
539
|
+
if (!_obj[k] || (typeof _obj[k] !== 'object')) {
|
|
540
|
+
_obj[k] = {}
|
|
541
|
+
}
|
|
542
|
+
// 自调用判断是否存在属性,不存在则自动创建对象
|
|
543
|
+
inFn(_obj[k], keys, v)
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (typeof key !== 'string' || key === '') {
|
|
548
|
+
|
|
549
|
+
} else if (key.indexOf('.') !== -1) { // 支持多层级赋值操作
|
|
550
|
+
const keys = key.split('.')
|
|
551
|
+
inFn(obj, keys, value)
|
|
552
|
+
} else {
|
|
553
|
+
obj[key] = value
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* 公共类型声明
|
|
559
|
+
*/
|
|
560
|
+
export type Common = {
|
|
561
|
+
[key : string] : any;
|
|
562
|
+
$parent : typeof $parent;
|
|
563
|
+
addStyle : typeof addStyle;
|
|
564
|
+
addUnit : typeof addUnit;
|
|
565
|
+
deepClone : typeof deepClone;
|
|
566
|
+
deepMerge : typeof deepMerge;
|
|
567
|
+
uuid : typeof uuid;
|
|
568
|
+
error : typeof error;
|
|
569
|
+
random : typeof random;
|
|
570
|
+
randomArray : typeof randomArray;
|
|
571
|
+
range : typeof range;
|
|
572
|
+
priceFormat : typeof priceFormat;
|
|
573
|
+
formatTimestamp : typeof formatTimestamp;
|
|
574
|
+
formatTime : typeof formatTime;
|
|
575
|
+
timeAgo : typeof timeAgo;
|
|
576
|
+
trim : typeof trim;
|
|
577
|
+
getPx : typeof getPx;
|
|
578
|
+
sleep : typeof sleep;
|
|
579
|
+
padZero : typeof padZero;
|
|
580
|
+
sys : typeof sys;
|
|
581
|
+
os : typeof os;
|
|
582
|
+
getProperty : typeof getProperty;
|
|
583
|
+
setProperty : typeof setProperty;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export {
|
|
587
|
+
$parent,
|
|
588
|
+
addStyle,
|
|
589
|
+
addUnit,
|
|
590
|
+
deepClone,
|
|
591
|
+
deepMerge,
|
|
592
|
+
uuid,
|
|
593
|
+
error,
|
|
594
|
+
random,
|
|
595
|
+
randomArray,
|
|
596
|
+
range,
|
|
597
|
+
priceFormat,
|
|
598
|
+
formatTimestamp,
|
|
599
|
+
formatTime,
|
|
600
|
+
timeAgo,
|
|
601
|
+
trim,
|
|
602
|
+
getPx,
|
|
603
|
+
sleep,
|
|
604
|
+
padZero,
|
|
605
|
+
sys,
|
|
606
|
+
os,
|
|
607
|
+
getProperty,
|
|
608
|
+
setProperty
|
|
609
|
+
}
|