@wot-ui/ui 1.0.0 → 2.0.0-alpha.4
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 +21 -0
- package/README.md +134 -0
- package/attributes.json +1 -0
- package/changelog.md +63 -0
- package/common/AbortablePromise.ts +28 -0
- package/common/canvasHelper.ts +49 -0
- package/common/clickoutside.ts +25 -0
- package/common/event.ts +8 -0
- package/common/formatDate.ts +68 -0
- package/common/interceptor.ts +43 -0
- package/common/props.ts +53 -0
- package/common/util.ts +836 -0
- package/components/wd-action-sheet/index.scss +232 -0
- package/components/wd-action-sheet/types.ts +155 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +176 -0
- package/components/wd-avatar/index.scss +150 -0
- package/components/wd-avatar/types.ts +98 -0
- package/components/wd-avatar/wd-avatar.vue +184 -0
- package/components/wd-avatar-group/index.scss +11 -0
- package/components/wd-avatar-group/types.ts +61 -0
- package/components/wd-avatar-group/wd-avatar-group.vue +115 -0
- package/components/wd-backtop/index.scss +67 -0
- package/components/wd-backtop/types.ts +66 -0
- package/components/wd-backtop/wd-backtop.vue +57 -0
- package/components/wd-badge/index.scss +116 -0
- package/components/wd-badge/types.ts +94 -0
- package/components/wd-badge/wd-badge.vue +78 -0
- package/components/wd-button/index.scss +436 -0
- package/components/wd-button/types.ts +204 -0
- package/components/wd-button/wd-button.vue +210 -0
- package/components/wd-calendar/index.scss +97 -0
- package/components/wd-calendar/types.ts +221 -0
- package/components/wd-calendar/wd-calendar.vue +339 -0
- package/components/wd-calendar-view/index.scss +41 -0
- package/components/wd-calendar-view/month/index.scss +144 -0
- package/components/wd-calendar-view/month/month.vue +389 -0
- package/components/wd-calendar-view/month/types.ts +70 -0
- package/components/wd-calendar-view/monthPanel/index.scss +84 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +541 -0
- package/components/wd-calendar-view/monthPanel/types.ts +151 -0
- package/components/wd-calendar-view/types.ts +166 -0
- package/components/wd-calendar-view/utils.ts +318 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +117 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +74 -0
- package/components/wd-calendar-view/year/year.vue +206 -0
- package/components/wd-calendar-view/yearPanel/index.scss +42 -0
- package/components/wd-calendar-view/yearPanel/types.ts +96 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +249 -0
- package/components/wd-card/index.scss +104 -0
- package/components/wd-card/types.ts +47 -0
- package/components/wd-card/wd-card.vue +38 -0
- package/components/wd-cascader/index.scss +154 -0
- package/components/wd-cascader/types.ts +191 -0
- package/components/wd-cascader/wd-cascader.vue +589 -0
- package/components/wd-cell/index.scss +244 -0
- package/components/wd-cell/types.ts +205 -0
- package/components/wd-cell/wd-cell.vue +172 -0
- package/components/wd-cell-group/index.scss +53 -0
- package/components/wd-cell-group/types.ts +97 -0
- package/components/wd-cell-group/wd-cell-group.vue +48 -0
- package/components/wd-checkbox/index.scss +166 -0
- package/components/wd-checkbox/types.ts +118 -0
- package/components/wd-checkbox/wd-checkbox.vue +216 -0
- package/components/wd-checkbox-group/index.scss +5 -0
- package/components/wd-checkbox-group/types.ts +93 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +148 -0
- package/components/wd-circle/index.scss +28 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +306 -0
- package/components/wd-col/index.scss +5 -0
- package/components/wd-col/types.ts +16 -0
- package/components/wd-col/wd-col.vue +83 -0
- package/components/wd-collapse/index.scss +71 -0
- package/components/wd-collapse/types.ts +68 -0
- package/components/wd-collapse/wd-collapse.vue +165 -0
- package/components/wd-collapse-item/index.scss +86 -0
- package/components/wd-collapse-item/types.ts +62 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +184 -0
- package/components/wd-config-provider/index.scss +10 -0
- package/components/wd-config-provider/types.ts +2061 -0
- package/components/wd-config-provider/wd-config-provider.vue +61 -0
- package/components/wd-count-down/index.scss +16 -0
- package/components/wd-count-down/types.ts +58 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +62 -0
- package/components/wd-count-to/index.scss +25 -0
- package/components/wd-count-to/types.ts +121 -0
- package/components/wd-count-to/wd-count-to.vue +126 -0
- package/components/wd-curtain/index.scss +96 -0
- package/components/wd-curtain/types.ts +82 -0
- package/components/wd-curtain/wd-curtain.vue +172 -0
- package/components/wd-datetime-picker/index.scss +133 -0
- package/components/wd-datetime-picker/types.ts +198 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +526 -0
- package/components/wd-datetime-picker-view/types.ts +171 -0
- package/components/wd-datetime-picker-view/util.ts +30 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +402 -0
- package/components/wd-dialog/index.scss +281 -0
- package/components/wd-dialog/index.ts +168 -0
- package/components/wd-dialog/types.ts +452 -0
- package/components/wd-dialog/wd-dialog.vue +586 -0
- package/components/wd-divider/index.scss +122 -0
- package/components/wd-divider/types.ts +50 -0
- package/components/wd-divider/wd-divider.vue +54 -0
- package/components/wd-drop-menu/index.scss +90 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +168 -0
- package/components/wd-drop-menu-item/index.scss +96 -0
- package/components/wd-drop-menu-item/types.ts +93 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +205 -0
- package/components/wd-empty/index.scss +46 -0
- package/components/wd-empty/types.ts +37 -0
- package/components/wd-empty/wd-empty.vue +47 -0
- package/components/wd-fab/index.scss +124 -0
- package/components/wd-fab/types.ts +119 -0
- package/components/wd-fab/wd-fab.vue +322 -0
- package/components/wd-floating-panel/index.scss +73 -0
- package/components/wd-floating-panel/type.ts +32 -0
- package/components/wd-floating-panel/wd-floating-panel.vue +142 -0
- package/components/wd-form/adapters/zod.ts +56 -0
- package/components/wd-form/index.ts +2 -0
- package/components/wd-form/types.ts +133 -0
- package/components/wd-form/wd-form.vue +121 -0
- package/components/wd-form-item/index.scss +26 -0
- package/components/wd-form-item/types.ts +134 -0
- package/components/wd-form-item/wd-form-item.vue +182 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +26 -0
- package/components/wd-gap/wd-gap.vue +38 -0
- package/components/wd-grid/index.scss +11 -0
- package/components/wd-grid/types.ts +97 -0
- package/components/wd-grid/wd-grid.vue +48 -0
- package/components/wd-grid-item/index.scss +187 -0
- package/components/wd-grid-item/types.ts +98 -0
- package/components/wd-grid-item/wd-grid-item.vue +295 -0
- package/components/wd-icon/index.scss +46 -0
- package/components/wd-icon/types.ts +44 -0
- package/components/wd-icon/wd-icon.vue +66 -0
- package/components/wd-image-preview/index.scss +94 -0
- package/components/wd-image-preview/index.ts +95 -0
- package/components/wd-image-preview/types.ts +165 -0
- package/components/wd-image-preview/wd-image-preview.vue +233 -0
- package/components/wd-img/index.scss +82 -0
- package/components/wd-img/types.ts +96 -0
- package/components/wd-img/wd-img.vue +91 -0
- package/components/wd-img-cropper/index.scss +259 -0
- package/components/wd-img-cropper/types.ts +101 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +653 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +55 -0
- package/components/wd-index-bar/index.scss +68 -0
- package/components/wd-index-bar/type.ts +23 -0
- package/components/wd-index-bar/wd-index-bar.vue +157 -0
- package/components/wd-input/index.scss +129 -0
- package/components/wd-input/types.ts +165 -0
- package/components/wd-input/wd-input.vue +237 -0
- package/components/wd-input-number/index.scss +233 -0
- package/components/wd-input-number/types.ts +131 -0
- package/components/wd-input-number/wd-input-number.vue +473 -0
- package/components/wd-keyboard/constants.ts +81 -0
- package/components/wd-keyboard/index.scss +104 -0
- package/components/wd-keyboard/key/index.scss +103 -0
- package/components/wd-keyboard/key/index.vue +84 -0
- package/components/wd-keyboard/key/types.ts +44 -0
- package/components/wd-keyboard/types.ts +138 -0
- package/components/wd-keyboard/wd-keyboard.vue +236 -0
- package/components/wd-loading/index.scss +205 -0
- package/components/wd-loading/types.ts +61 -0
- package/components/wd-loading/wd-loading.vue +70 -0
- package/components/wd-loadmore/index.scss +62 -0
- package/components/wd-loadmore/types.ts +42 -0
- package/components/wd-loadmore/wd-loadmore.vue +68 -0
- package/components/wd-navbar/index.scss +96 -0
- package/components/wd-navbar/types.ts +74 -0
- package/components/wd-navbar/wd-navbar.vue +136 -0
- package/components/wd-navbar-capsule/index.scss +70 -0
- package/components/wd-navbar-capsule/types.ts +11 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +48 -0
- package/components/wd-notice-bar/index.scss +94 -0
- package/components/wd-notice-bar/types.ts +97 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +270 -0
- package/components/wd-notify/index.scss +114 -0
- package/components/wd-notify/index.ts +63 -0
- package/components/wd-notify/types.ts +130 -0
- package/components/wd-notify/wd-notify.vue +162 -0
- package/components/wd-overlay/index.scss +14 -0
- package/components/wd-overlay/types.ts +42 -0
- package/components/wd-overlay/wd-overlay.vue +55 -0
- package/components/wd-pagination/index.scss +71 -0
- package/components/wd-pagination/types.ts +69 -0
- package/components/wd-pagination/wd-pagination.vue +118 -0
- package/components/wd-password-input/index.scss +134 -0
- package/components/wd-password-input/types.ts +42 -0
- package/components/wd-password-input/wd-password-input.vue +51 -0
- package/components/wd-picker/index.scss +72 -0
- package/components/wd-picker/types.ts +141 -0
- package/components/wd-picker/wd-picker.vue +220 -0
- package/components/wd-picker-view/index.scss +93 -0
- package/components/wd-picker-view/types.ts +145 -0
- package/components/wd-picker-view/useSelection.ts +385 -0
- package/components/wd-picker-view/wd-picker-view.vue +227 -0
- package/components/wd-popover/index.scss +117 -0
- package/components/wd-popover/types.ts +106 -0
- package/components/wd-popover/wd-popover.vue +212 -0
- package/components/wd-popup/index.scss +89 -0
- package/components/wd-popup/types.ts +110 -0
- package/components/wd-popup/wd-popup.vue +174 -0
- package/components/wd-progress/index.scss +155 -0
- package/components/wd-progress/types.ts +94 -0
- package/components/wd-progress/wd-progress.vue +249 -0
- package/components/wd-radio/index.scss +189 -0
- package/components/wd-radio/types.ts +64 -0
- package/components/wd-radio/wd-radio.vue +164 -0
- package/components/wd-radio-group/index.scss +5 -0
- package/components/wd-radio-group/types.ts +70 -0
- package/components/wd-radio-group/wd-radio-group.vue +53 -0
- package/components/wd-rate/index.scss +57 -0
- package/components/wd-rate/types.ts +86 -0
- package/components/wd-rate/wd-rate.vue +168 -0
- package/components/wd-resize/index.scss +31 -0
- package/components/wd-resize/types.ts +14 -0
- package/components/wd-resize/wd-resize.vue +157 -0
- package/components/wd-root-portal/wd-root-portal.vue +77 -0
- package/components/wd-row/index.scss +6 -0
- package/components/wd-row/types.ts +36 -0
- package/components/wd-row/wd-row.vue +88 -0
- package/components/wd-search/index.scss +171 -0
- package/components/wd-search/types.ts +107 -0
- package/components/wd-search/wd-search.vue +198 -0
- package/components/wd-segmented/index.scss +155 -0
- package/components/wd-segmented/types.ts +81 -0
- package/components/wd-segmented/wd-segmented.vue +169 -0
- package/components/wd-select-picker/index.scss +72 -0
- package/components/wd-select-picker/types.ts +72 -0
- package/components/wd-select-picker/wd-select-picker.vue +371 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +34 -0
- package/components/wd-sidebar/wd-sidebar.vue +57 -0
- package/components/wd-sidebar-item/index.scss +91 -0
- package/components/wd-sidebar-item/types.ts +28 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +118 -0
- package/components/wd-signature/index.scss +42 -0
- package/components/wd-signature/types.ts +295 -0
- package/components/wd-signature/wd-signature.vue +664 -0
- package/components/wd-skeleton/index.scss +112 -0
- package/components/wd-skeleton/types.ts +124 -0
- package/components/wd-skeleton/wd-skeleton.vue +110 -0
- package/components/wd-slide-verify/index.scss +112 -0
- package/components/wd-slide-verify/types.ts +98 -0
- package/components/wd-slide-verify/wd-slide-verify.vue +222 -0
- package/components/wd-slider/index.scss +485 -0
- package/components/wd-slider/types.ts +166 -0
- package/components/wd-slider/wd-slider.vue +529 -0
- package/components/wd-sort-button/index.scss +126 -0
- package/components/wd-sort-button/types.ts +68 -0
- package/components/wd-sort-button/wd-sort-button.vue +67 -0
- package/components/wd-step/index.scss +366 -0
- package/components/wd-step/types.ts +43 -0
- package/components/wd-step/wd-step.vue +181 -0
- package/components/wd-steps/index.scss +7 -0
- package/components/wd-steps/types.ts +50 -0
- package/components/wd-steps/wd-steps.vue +39 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +192 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +157 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +87 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +320 -0
- package/components/wd-swiper/index.scss +69 -0
- package/components/wd-swiper/types.ts +275 -0
- package/components/wd-swiper/wd-swiper.vue +332 -0
- package/components/wd-swiper-nav/index.scss +179 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +42 -0
- package/components/wd-switch/index.scss +177 -0
- package/components/wd-switch/types.ts +93 -0
- package/components/wd-switch/wd-switch.vue +107 -0
- package/components/wd-tab/index.scss +16 -0
- package/components/wd-tab/types.ts +45 -0
- package/components/wd-tab/wd-tab.vue +99 -0
- package/components/wd-tabbar/index.scss +71 -0
- package/components/wd-tabbar/types.ts +79 -0
- package/components/wd-tabbar/wd-tabbar.vue +109 -0
- package/components/wd-tabbar-item/index.scss +50 -0
- package/components/wd-tabbar-item/types.ts +45 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +128 -0
- package/components/wd-table/types.ts +160 -0
- package/components/wd-table/wd-table.vue +331 -0
- package/components/wd-table-column/index.scss +15 -0
- package/components/wd-table-column/types.ts +81 -0
- package/components/wd-table-column/wd-table-column.vue +198 -0
- package/components/wd-tabs/index.scss +332 -0
- package/components/wd-tabs/types.ts +155 -0
- package/components/wd-tabs/wd-tabs.vue +508 -0
- package/components/wd-tag/index.scss +325 -0
- package/components/wd-tag/types.ts +90 -0
- package/components/wd-tag/wd-tag.vue +158 -0
- package/components/wd-text/index.scss +52 -0
- package/components/wd-text/types.ts +107 -0
- package/components/wd-text/wd-text.vue +141 -0
- package/components/wd-textarea/index.scss +112 -0
- package/components/wd-textarea/types.ts +151 -0
- package/components/wd-textarea/wd-textarea.vue +212 -0
- package/components/wd-toast/index.scss +92 -0
- package/components/wd-toast/index.ts +97 -0
- package/components/wd-toast/types.ts +190 -0
- package/components/wd-toast/wd-toast.vue +158 -0
- package/components/wd-tooltip/index.scss +77 -0
- package/components/wd-tooltip/types.ts +105 -0
- package/components/wd-tooltip/wd-tooltip.vue +169 -0
- package/components/wd-tour/index.scss +106 -0
- package/components/wd-tour/types.ts +268 -0
- package/components/wd-tour/wd-tour.vue +518 -0
- package/components/wd-transition/index.scss +67 -0
- package/components/wd-transition/types.ts +106 -0
- package/components/wd-transition/wd-transition.vue +238 -0
- package/components/wd-upload/index.scss +204 -0
- package/components/wd-upload/types.ts +390 -0
- package/components/wd-upload/wd-upload.vue +565 -0
- package/components/wd-video-preview/index.scss +54 -0
- package/components/wd-video-preview/index.ts +64 -0
- package/components/wd-video-preview/types.ts +66 -0
- package/components/wd-video-preview/wd-video-preview.vue +141 -0
- package/components/wd-watermark/index.scss +21 -0
- package/components/wd-watermark/types.ts +130 -0
- package/components/wd-watermark/wd-watermark.vue +718 -0
- package/components/wot-ui/wot-ui.vue +5 -0
- package/composables/index.ts +16 -0
- package/composables/useCell.ts +34 -0
- package/composables/useChildren.ts +120 -0
- package/composables/useConfigProvider.ts +45 -0
- package/composables/useCountDown.ts +138 -0
- package/composables/useDeviceInfo.ts +136 -0
- package/composables/useLockScroll.ts +37 -0
- package/composables/useParent.ts +51 -0
- package/composables/usePopover.ts +212 -0
- package/composables/useQueue.ts +52 -0
- package/composables/useRaf.ts +37 -0
- package/composables/useTouch.ts +43 -0
- package/composables/useTranslate.ts +12 -0
- package/composables/useUpload.ts +366 -0
- package/global.d.ts +106 -0
- package/index.ts +6 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +150 -0
- package/locale/lang/de-DE.ts +150 -0
- package/locale/lang/en-US.ts +150 -0
- package/locale/lang/es-ES.ts +150 -0
- package/locale/lang/fr-FR.ts +150 -0
- package/locale/lang/ja-JP.ts +150 -0
- package/locale/lang/ko-KR.ts +150 -0
- package/locale/lang/pt-PT.ts +150 -0
- package/locale/lang/ru-RU.ts +150 -0
- package/locale/lang/th-TH.ts +150 -0
- package/locale/lang/tr-TR.ts +155 -0
- package/locale/lang/ug-CN.ts +154 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +154 -0
- package/locale/lang/zh-HK.ts +78 -0
- package/locale/lang/zh-TW.ts +78 -0
- package/package.json +1 -11
- package/styles/iconfont/iconfont.scss +1243 -0
- package/styles/mixin/_config.scss +7 -0
- package/styles/mixin/_function.scss +44 -0
- package/styles/mixin/_mixin.scss +473 -0
- package/styles/theme/base/color.scss +210 -0
- package/styles/theme/base/font.scss +13 -0
- package/styles/theme/base/index.scss +8 -0
- package/styles/theme/base/insets.scss +32 -0
- package/styles/theme/base/number.scss +36 -0
- package/styles/theme/base/opacity.scss +9 -0
- package/styles/theme/base/radius.scss +13 -0
- package/styles/theme/base/stroke.scss +9 -0
- package/styles/theme/base/typography.scss +44 -0
- package/styles/theme/dark.scss +101 -0
- package/styles/theme/index.scss +16 -0
- package/styles/theme/light.scss +101 -0
- package/styles/variable.scss +472 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeArrayProp, makeBooleanProp, makeNumberProp, makeStringProp } from '../../common/props'
|
|
3
|
+
import type { LoadingType } from '../wd-loading/types'
|
|
4
|
+
import type { ImageMode } from '../wd-img/types'
|
|
5
|
+
|
|
6
|
+
export interface ChooseFileOption {
|
|
7
|
+
// 是否支持多选文件
|
|
8
|
+
multiple?: boolean
|
|
9
|
+
// 所选的图片的尺寸
|
|
10
|
+
sizeType?: UploadSizeType[]
|
|
11
|
+
// 选择文件的来源
|
|
12
|
+
sourceType?: UploadSourceType[]
|
|
13
|
+
// 最大允许上传个数
|
|
14
|
+
maxCount?: number
|
|
15
|
+
// 接受文件类型
|
|
16
|
+
accept?: UploadFileType
|
|
17
|
+
/**
|
|
18
|
+
* 是否压缩视频,当 accept 为 video 时生效。
|
|
19
|
+
*/
|
|
20
|
+
compressed?: boolean
|
|
21
|
+
/**
|
|
22
|
+
* 拍摄视频最长拍摄时间,当 accept 为 video | media 时生效,单位秒。
|
|
23
|
+
*/
|
|
24
|
+
maxDuration?: number
|
|
25
|
+
/**
|
|
26
|
+
* 使用前置或者后置相机,当 accept 为 video | media 时生效,可选值为:back|front。
|
|
27
|
+
*/
|
|
28
|
+
camera?: UploadCameraType
|
|
29
|
+
/**
|
|
30
|
+
* 根据文件拓展名过滤,H5、微信小程序支持
|
|
31
|
+
* 每一项都不能是空字符串, 默认不过滤
|
|
32
|
+
* 例如: ['.jpg'] 表示只选择.jpg文件
|
|
33
|
+
*/
|
|
34
|
+
extension?: string[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type UploadFileItem = {
|
|
38
|
+
[key: string]: any
|
|
39
|
+
// 当前上传文件在列表中的唯一标识
|
|
40
|
+
uid: number
|
|
41
|
+
// 缩略图地址
|
|
42
|
+
thumb?: string
|
|
43
|
+
// 当前文件名称,仅h5支持
|
|
44
|
+
name?: string
|
|
45
|
+
// 上传状态。若自定义了status-key,应取对应字段
|
|
46
|
+
status?: UploadStatusType
|
|
47
|
+
// 文件大小
|
|
48
|
+
size?: number
|
|
49
|
+
// 上传图片/视频的本地地址
|
|
50
|
+
url: string
|
|
51
|
+
// 上传进度
|
|
52
|
+
percent?: number
|
|
53
|
+
// 后端返回的内容,可能是对象,也可能是字符串
|
|
54
|
+
response?: string | Record<string, any>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ChooseFile {
|
|
58
|
+
path: string // 上传临时地址
|
|
59
|
+
size?: number // 上传大小
|
|
60
|
+
name?: string // 当前文件名称,仅h5支持
|
|
61
|
+
type: 'image' | 'video' | 'file' // 上传类型
|
|
62
|
+
duration?: number // 上传时间
|
|
63
|
+
thumb?: string // 缩略图地址
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type UploadSourceType = 'album' | 'camera'
|
|
67
|
+
export type UploadSizeType = 'original' | 'compressed'
|
|
68
|
+
export type UploadFileType = 'image' | 'video' | 'media' | 'all' | 'file'
|
|
69
|
+
export type UploadCameraType = 'front' | 'back'
|
|
70
|
+
export type UploadStatusType = 'pending' | 'loading' | 'success' | 'fail'
|
|
71
|
+
export type UploadSuccessStatus = number | number[]
|
|
72
|
+
|
|
73
|
+
export type UploadBeforePreviewOption = {
|
|
74
|
+
file: UploadFileItem
|
|
75
|
+
index: number
|
|
76
|
+
imgList: string[]
|
|
77
|
+
fileList: UploadFileItem[]
|
|
78
|
+
}
|
|
79
|
+
export type UploadBeforePreview = (option: UploadBeforePreviewOption) => boolean | Promise<boolean>
|
|
80
|
+
|
|
81
|
+
export type UploadOnPreviewFailOption = {
|
|
82
|
+
index: number
|
|
83
|
+
imgList: string[]
|
|
84
|
+
}
|
|
85
|
+
export type UploadOnPreviewFail = (option: UploadOnPreviewFailOption) => void
|
|
86
|
+
|
|
87
|
+
export type UploadBeforeRemoveOption = {
|
|
88
|
+
file: UploadFileItem
|
|
89
|
+
index: number
|
|
90
|
+
fileList: UploadFileItem[]
|
|
91
|
+
}
|
|
92
|
+
export type UploadBeforeRemove = (option: UploadBeforeRemoveOption) => boolean | Promise<boolean>
|
|
93
|
+
|
|
94
|
+
export type UploadBeforeChooseOption = {
|
|
95
|
+
fileList: UploadFileItem[]
|
|
96
|
+
}
|
|
97
|
+
export type UploadBeforeChoose = (option: UploadBeforeChooseOption) => boolean | Promise<boolean>
|
|
98
|
+
|
|
99
|
+
export type UploadBeforeUploadOption = {
|
|
100
|
+
files: Record<string, any>[]
|
|
101
|
+
fileList: UploadFileItem[]
|
|
102
|
+
}
|
|
103
|
+
export type UploadBeforeUpload = (options: UploadBeforeUploadOption) => boolean | Promise<boolean>
|
|
104
|
+
|
|
105
|
+
export type UploadFormData = Record<string, any>
|
|
106
|
+
|
|
107
|
+
export type UploadBuildFormDataOption = {
|
|
108
|
+
file: UploadFileItem
|
|
109
|
+
formData: UploadFormData
|
|
110
|
+
}
|
|
111
|
+
export type UploadBuildFormData = (options: UploadBuildFormDataOption) => Record<string, any> | Promise<Record<string, any>>
|
|
112
|
+
|
|
113
|
+
export type UploadFile = Partial<UploadFileItem> & { url: string }
|
|
114
|
+
|
|
115
|
+
export type UploadMethod = (
|
|
116
|
+
uploadFile: UploadFileItem,
|
|
117
|
+
formData: UploadFormData,
|
|
118
|
+
options: {
|
|
119
|
+
action: string
|
|
120
|
+
header: Record<string, any>
|
|
121
|
+
name: string
|
|
122
|
+
fileName: string
|
|
123
|
+
fileType: 'image' | 'video' | 'audio'
|
|
124
|
+
statusCode: UploadSuccessStatus
|
|
125
|
+
// 添加是否自动中断之前上传的选项
|
|
126
|
+
abortPrevious?: boolean
|
|
127
|
+
onSuccess: (res: UniApp.UploadFileSuccessCallbackResult, file: UploadFileItem, formData: UploadFormData) => void
|
|
128
|
+
onError: (res: UniApp.GeneralCallbackResult, file: UploadFileItem, formData: UploadFormData) => void
|
|
129
|
+
onProgress: (res: UniApp.OnProgressUpdateResult, file: UploadFileItem) => void
|
|
130
|
+
}
|
|
131
|
+
) => UniApp.UploadTask | void | Promise<void> // 修改这里,支持返回 UploadTask 类型
|
|
132
|
+
|
|
133
|
+
export const uploadProps = {
|
|
134
|
+
...baseProps,
|
|
135
|
+
/**
|
|
136
|
+
* 上传的文件列表,例如:[{name:'food.jpg',url:'https://xxx.cdn.com/xxx.jpg'}]
|
|
137
|
+
* 类型:array
|
|
138
|
+
* 默认值:[]
|
|
139
|
+
*/
|
|
140
|
+
fileList: makeArrayProp<UploadFile>(),
|
|
141
|
+
/**
|
|
142
|
+
* 必选参数,上传的地址
|
|
143
|
+
* 类型:string
|
|
144
|
+
* 默认值:''
|
|
145
|
+
*/
|
|
146
|
+
action: makeStringProp(''),
|
|
147
|
+
/**
|
|
148
|
+
* 设置上传的请求头部
|
|
149
|
+
* 类型:object
|
|
150
|
+
* 默认值:{}
|
|
151
|
+
*/
|
|
152
|
+
header: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
|
|
153
|
+
/**
|
|
154
|
+
* 是否支持多选文件
|
|
155
|
+
* 类型:boolean
|
|
156
|
+
* 默认值:false
|
|
157
|
+
*/
|
|
158
|
+
multiple: makeBooleanProp(false),
|
|
159
|
+
/**
|
|
160
|
+
* 是否禁用
|
|
161
|
+
* 类型:boolean
|
|
162
|
+
* 默认值:false
|
|
163
|
+
*/
|
|
164
|
+
disabled: makeBooleanProp(false),
|
|
165
|
+
/**
|
|
166
|
+
* 最大允许上传个数
|
|
167
|
+
* 类型:number
|
|
168
|
+
* 默认值:无
|
|
169
|
+
*/
|
|
170
|
+
limit: Number,
|
|
171
|
+
/**
|
|
172
|
+
* 限制上传个数的情况下,是否展示当前上传的个数
|
|
173
|
+
* 类型:boolean
|
|
174
|
+
* 默认值:true
|
|
175
|
+
*/
|
|
176
|
+
showLimitNum: makeBooleanProp(true),
|
|
177
|
+
/**
|
|
178
|
+
* 文件大小限制,单位为byte
|
|
179
|
+
* 类型:number
|
|
180
|
+
* 默认值:Number.MAX_VALUE
|
|
181
|
+
*/
|
|
182
|
+
maxSize: makeNumberProp(Number.MAX_VALUE),
|
|
183
|
+
/**
|
|
184
|
+
* 选择图片的来源,chooseImage接口详细参数,查看官方手册
|
|
185
|
+
* 类型:array
|
|
186
|
+
* 默认值:['album','camera']
|
|
187
|
+
*/
|
|
188
|
+
sourceType: {
|
|
189
|
+
type: Array as PropType<UploadSourceType[]>,
|
|
190
|
+
default: () => ['album', 'camera']
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* 所选的图片的尺寸,chooseImage接口详细参数,查看官方手册
|
|
194
|
+
* 类型:array
|
|
195
|
+
* 默认值:['original','compressed']
|
|
196
|
+
*/
|
|
197
|
+
sizeType: {
|
|
198
|
+
type: Array as PropType<UploadSizeType[]>,
|
|
199
|
+
// #ifndef MP-DINGTALK
|
|
200
|
+
default: () => ['original', 'compressed']
|
|
201
|
+
// #endif
|
|
202
|
+
},
|
|
203
|
+
/**
|
|
204
|
+
* 文件对应的key,开发者在服务端可以通过这个key获取文件的二进制内容,uploadFile接口详细参数,查看官方手册
|
|
205
|
+
* 类型:string
|
|
206
|
+
* 默认值:'file'
|
|
207
|
+
*/
|
|
208
|
+
name: makeStringProp('file'),
|
|
209
|
+
/**
|
|
210
|
+
* HTTP请求中其他额外的formdata,uploadFile接口详细参数,查看官方手册
|
|
211
|
+
* 类型:object
|
|
212
|
+
* 默认值:{}
|
|
213
|
+
*/
|
|
214
|
+
formData: { type: Object as PropType<UploadFormData>, default: () => ({}) },
|
|
215
|
+
/**
|
|
216
|
+
* 预览失败执行操作
|
|
217
|
+
* 类型:function({index,imgList})
|
|
218
|
+
* 默认值:-
|
|
219
|
+
*/
|
|
220
|
+
onPreviewFail: Function as PropType<UploadOnPreviewFail>,
|
|
221
|
+
/**
|
|
222
|
+
* 上传文件之前的钩子,参数为上传的文件和文件列表,若返回false或者返回Promise且被reject,则停止上传。
|
|
223
|
+
* 类型:function({files,fileList})
|
|
224
|
+
* 默认值:-
|
|
225
|
+
*/
|
|
226
|
+
beforeUpload: Function as PropType<UploadBeforeUpload>,
|
|
227
|
+
/**
|
|
228
|
+
* 选择图片之前的钩子,参数为文件列表,若返回false或者返回Promise且被reject,则停止上传。
|
|
229
|
+
* 类型:function({fileList})
|
|
230
|
+
* 默认值:-
|
|
231
|
+
*/
|
|
232
|
+
beforeChoose: Function as PropType<UploadBeforeChoose>,
|
|
233
|
+
/**
|
|
234
|
+
* 删除文件之前的钩子,参数为要删除的文件和文件列表,若返回false或者返回Promise且被reject,则停止删除。
|
|
235
|
+
* 类型:function({file,index,fileList})
|
|
236
|
+
* 默认值:-
|
|
237
|
+
*/
|
|
238
|
+
beforeRemove: Function as PropType<UploadBeforeRemove>,
|
|
239
|
+
/**
|
|
240
|
+
* 图片预览前的钩子,参数为预览的文件和图片列表,若返回false或者返回Promise且被reject,则停止预览。
|
|
241
|
+
* 类型:function({file,index,imgList,fileList})
|
|
242
|
+
* 默认值:-
|
|
243
|
+
*/
|
|
244
|
+
beforePreview: Function as PropType<UploadBeforePreview>,
|
|
245
|
+
/**
|
|
246
|
+
* 构建上传formData的钩子,参数为上传的文件、待处理的formData,返回值为处理后的formData,若返回Promise且被reject,则停止上传。
|
|
247
|
+
* 类型:function({file,formData})
|
|
248
|
+
* 默认值:-
|
|
249
|
+
* 最低版本:0.1.61
|
|
250
|
+
*/
|
|
251
|
+
buildFormData: Function as PropType<UploadBuildFormData>,
|
|
252
|
+
/**
|
|
253
|
+
* 加载中图标类型
|
|
254
|
+
* 类型:string
|
|
255
|
+
* 默认值:'ring'
|
|
256
|
+
*/
|
|
257
|
+
loadingType: makeStringProp<LoadingType>('circular'),
|
|
258
|
+
/**
|
|
259
|
+
* 加载中图标颜色
|
|
260
|
+
* 类型:string
|
|
261
|
+
* 默认值:'#ffffff'
|
|
262
|
+
*/
|
|
263
|
+
loadingColor: makeStringProp('#ffffff'),
|
|
264
|
+
/**
|
|
265
|
+
* 文件类型,可选值:'image' | 'video' | 'media' | 'all' | 'file'
|
|
266
|
+
* 默认值:image
|
|
267
|
+
* 描述:'media'表示同时支持'image'和'video','file'表示支持除'image'和'video'外的所有文件类型,'all'标识支持全部类型文件
|
|
268
|
+
* 'media'和'file'仅微信支持,'all'仅微信和H5支持
|
|
269
|
+
*/
|
|
270
|
+
accept: makeStringProp<UploadFileType>('image'),
|
|
271
|
+
/**
|
|
272
|
+
* file 数据结构中,status 对应的 key
|
|
273
|
+
* 类型:string
|
|
274
|
+
* 默认值:'status'
|
|
275
|
+
*/
|
|
276
|
+
statusKey: makeStringProp('status'),
|
|
277
|
+
/**
|
|
278
|
+
* 加载中图标尺寸
|
|
279
|
+
* 类型:string
|
|
280
|
+
* 默认值:'24px'
|
|
281
|
+
*/
|
|
282
|
+
loadingSize: makeStringProp('24px'),
|
|
283
|
+
/**
|
|
284
|
+
* 是否压缩视频,当 accept 为 video 时生效。
|
|
285
|
+
* 类型:boolean
|
|
286
|
+
* 默认值:true
|
|
287
|
+
*/
|
|
288
|
+
compressed: makeBooleanProp(true),
|
|
289
|
+
/**
|
|
290
|
+
* 拍摄视频最长拍摄时间,当 accept 为 video | media 时生效,单位秒。
|
|
291
|
+
* 类型:number
|
|
292
|
+
* 默认值:60
|
|
293
|
+
*/
|
|
294
|
+
maxDuration: makeNumberProp(60),
|
|
295
|
+
/**
|
|
296
|
+
* 使用前置或者后置相机,当 accept 为 video | media 时生效,可选值为:back|front。
|
|
297
|
+
* 类型:UploadCameraType
|
|
298
|
+
* 默认值:'back'
|
|
299
|
+
*/
|
|
300
|
+
camera: makeStringProp<UploadCameraType>('back'),
|
|
301
|
+
/**
|
|
302
|
+
* 预览图片的mode属性
|
|
303
|
+
*/
|
|
304
|
+
imageMode: makeStringProp<ImageMode>('aspectFit'),
|
|
305
|
+
/**
|
|
306
|
+
* 接口响应的成功状态(statusCode)值
|
|
307
|
+
*/
|
|
308
|
+
successStatus: {
|
|
309
|
+
type: [Number, Array] as PropType<UploadSuccessStatus>,
|
|
310
|
+
default: 200
|
|
311
|
+
},
|
|
312
|
+
/**
|
|
313
|
+
* 自定义上传按钮样式
|
|
314
|
+
* 类型:string
|
|
315
|
+
*/
|
|
316
|
+
customEvokeClass: makeStringProp(''),
|
|
317
|
+
/**
|
|
318
|
+
* 自定义预览图片列表样式
|
|
319
|
+
* 类型:string
|
|
320
|
+
*/
|
|
321
|
+
customPreviewClass: makeStringProp(''),
|
|
322
|
+
/**
|
|
323
|
+
* 是否选择文件后自动上传
|
|
324
|
+
* 类型:boolean
|
|
325
|
+
*/
|
|
326
|
+
autoUpload: makeBooleanProp(true),
|
|
327
|
+
/**
|
|
328
|
+
* 点击已上传时是否可以重新上传
|
|
329
|
+
* 类型:boolean
|
|
330
|
+
* 默认值:false
|
|
331
|
+
*/
|
|
332
|
+
reupload: makeBooleanProp(false),
|
|
333
|
+
/**
|
|
334
|
+
* 自定义上传文件的请求方法
|
|
335
|
+
* 类型:UploadMethod
|
|
336
|
+
* 默认值:-
|
|
337
|
+
*/
|
|
338
|
+
uploadMethod: Function as PropType<UploadMethod>,
|
|
339
|
+
/**
|
|
340
|
+
* 根据文件拓展名过滤,每一项都不能是空字符串。默认不过滤。
|
|
341
|
+
* H5支持全部类型过滤。
|
|
342
|
+
* 微信小程序支持all和file时过滤,其余平台不支持。
|
|
343
|
+
*/
|
|
344
|
+
extension: Array as PropType<string[]>
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export type UploadProps = ExtractPropTypes<typeof uploadProps>
|
|
348
|
+
|
|
349
|
+
export type UploadExpose = {
|
|
350
|
+
/**
|
|
351
|
+
* 手动触发上传
|
|
352
|
+
*/
|
|
353
|
+
submit: () => void
|
|
354
|
+
/**
|
|
355
|
+
* 取消上传
|
|
356
|
+
* @param task 上传任务
|
|
357
|
+
*/
|
|
358
|
+
abort: (task?: UniApp.UploadTask) => void
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export type UploadErrorEvent = {
|
|
362
|
+
error: any
|
|
363
|
+
file: UploadFileItem
|
|
364
|
+
formData: UploadFormData
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export type UploadChangeEvent = {
|
|
368
|
+
fileList: UploadFileItem[]
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export type UploadSuccessEvent = {
|
|
372
|
+
file: UploadFileItem
|
|
373
|
+
fileList: UploadFileItem[]
|
|
374
|
+
formData: UploadFormData
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export type UploadProgressEvent = {
|
|
378
|
+
response: UniApp.OnProgressUpdateResult
|
|
379
|
+
file: UploadFileItem
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export type UploadOversizeEvent = {
|
|
383
|
+
file: ChooseFile
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export type UploadRemoveEvent = {
|
|
387
|
+
file: UploadFileItem
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export type UploadInstance = ComponentPublicInstance<UploadProps, UploadExpose>
|