@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,366 @@
|
|
|
1
|
+
import { isArray, isDef, isFunction } from '../common/util'
|
|
2
|
+
import type { ChooseFile, ChooseFileOption, UploadFileItem, UploadMethod, UploadStatusType, UploadSuccessStatus } from '../components/wd-upload/types'
|
|
3
|
+
|
|
4
|
+
export const UPLOAD_STATUS: Record<string, UploadStatusType> = {
|
|
5
|
+
PENDING: 'pending',
|
|
6
|
+
LOADING: 'loading',
|
|
7
|
+
SUCCESS: 'success',
|
|
8
|
+
FAIL: 'fail'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface UseUploadReturn {
|
|
12
|
+
// 开始上传文件
|
|
13
|
+
startUpload: (file: UploadFileItem, options: UseUploadOptions) => UniApp.UploadTask | void | Promise<void>
|
|
14
|
+
// 中断上传
|
|
15
|
+
abort: (task?: UniApp.UploadTask) => void
|
|
16
|
+
// 上传状态常量
|
|
17
|
+
UPLOAD_STATUS: Record<string, UploadStatusType>
|
|
18
|
+
// 选择文件
|
|
19
|
+
chooseFile: (options: ChooseFileOption) => Promise<ChooseFile[]>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface UseUploadOptions {
|
|
23
|
+
// 上传地址
|
|
24
|
+
action: string
|
|
25
|
+
// 请求头
|
|
26
|
+
header?: Record<string, any>
|
|
27
|
+
// 文件对应的 key
|
|
28
|
+
name?: string
|
|
29
|
+
// 其它表单数据
|
|
30
|
+
formData?: Record<string, any>
|
|
31
|
+
// 文件类型 仅支付宝支持且在支付宝平台必填
|
|
32
|
+
fileType?: 'image' | 'video' | 'audio'
|
|
33
|
+
// 成功状态码
|
|
34
|
+
statusCode?: UploadSuccessStatus
|
|
35
|
+
// 文件状态的key
|
|
36
|
+
statusKey?: string
|
|
37
|
+
// 自定义上传方法
|
|
38
|
+
uploadMethod?: UploadMethod
|
|
39
|
+
// 上传成功回调
|
|
40
|
+
onSuccess?: (res: UniApp.UploadFileSuccessCallbackResult, file: UploadFileItem, formData: Record<string, any>) => void
|
|
41
|
+
// 上传失败回调
|
|
42
|
+
onError?: (res: UniApp.GeneralCallbackResult, file: UploadFileItem, formData: Record<string, any>) => void
|
|
43
|
+
// 上传进度回调
|
|
44
|
+
onProgress?: (res: UniApp.OnProgressUpdateResult, file: UploadFileItem) => void
|
|
45
|
+
// 是否自动中断之前的上传任务
|
|
46
|
+
abortPrevious?: boolean
|
|
47
|
+
// 根据文件拓展名过滤(H5支持全部类型过滤,微信小程序支持all和file时过滤,其余平台不支持)
|
|
48
|
+
extension?: string[]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function useUpload(): UseUploadReturn {
|
|
52
|
+
let currentTask: UniApp.UploadTask | null = null
|
|
53
|
+
|
|
54
|
+
// 中断上传
|
|
55
|
+
const abort = (task?: UniApp.UploadTask) => {
|
|
56
|
+
if (task) {
|
|
57
|
+
task.abort()
|
|
58
|
+
} else if (currentTask) {
|
|
59
|
+
currentTask.abort()
|
|
60
|
+
currentTask = null
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 默认上传方法
|
|
66
|
+
*/
|
|
67
|
+
const defaultUpload: UploadMethod = (file, formData, options) => {
|
|
68
|
+
// 如果配置了自动中断,则中断之前的上传任务
|
|
69
|
+
if (options.abortPrevious) {
|
|
70
|
+
abort()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const uploadTask = uni.uploadFile({
|
|
74
|
+
url: options.action,
|
|
75
|
+
header: options.header,
|
|
76
|
+
name: options.name,
|
|
77
|
+
fileName: options.name,
|
|
78
|
+
fileType: options.fileType,
|
|
79
|
+
formData,
|
|
80
|
+
filePath: file.url,
|
|
81
|
+
success(res) {
|
|
82
|
+
const successStatus = options.statusCode
|
|
83
|
+
const isSuccess = isArray(successStatus) ? successStatus.includes(res.statusCode) : res.statusCode === successStatus
|
|
84
|
+
if (isSuccess) {
|
|
85
|
+
// 上传成功
|
|
86
|
+
options.onSuccess(res, file, formData)
|
|
87
|
+
} else {
|
|
88
|
+
// 上传失败
|
|
89
|
+
options.onError({ ...res, errMsg: res.errMsg || '' }, file, formData)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
fail(err) {
|
|
93
|
+
// 上传失败
|
|
94
|
+
options.onError(err, file, formData)
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
currentTask = uploadTask
|
|
99
|
+
|
|
100
|
+
// 获取当前文件加载的百分比
|
|
101
|
+
uploadTask.onProgressUpdate((res) => {
|
|
102
|
+
options.onProgress(res, file)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// 返回上传任务实例,让外部可以控制上传过程
|
|
106
|
+
return uploadTask
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 开始上传文件
|
|
111
|
+
*/
|
|
112
|
+
const startUpload = (file: UploadFileItem, options: UseUploadOptions) => {
|
|
113
|
+
const {
|
|
114
|
+
uploadMethod,
|
|
115
|
+
formData = {},
|
|
116
|
+
action,
|
|
117
|
+
name = 'file',
|
|
118
|
+
header = {},
|
|
119
|
+
fileType = 'image',
|
|
120
|
+
statusCode = 200,
|
|
121
|
+
statusKey = 'status',
|
|
122
|
+
abortPrevious = false
|
|
123
|
+
} = options
|
|
124
|
+
|
|
125
|
+
// 设置上传中状态
|
|
126
|
+
file[statusKey] = UPLOAD_STATUS.LOADING
|
|
127
|
+
|
|
128
|
+
const uploadOptions = {
|
|
129
|
+
action,
|
|
130
|
+
header,
|
|
131
|
+
name,
|
|
132
|
+
fileName: name,
|
|
133
|
+
fileType,
|
|
134
|
+
statusCode,
|
|
135
|
+
abortPrevious,
|
|
136
|
+
onSuccess: (res: UniApp.UploadFileSuccessCallbackResult, file: UploadFileItem, formData: Record<string, any>) => {
|
|
137
|
+
// 更新文件状态
|
|
138
|
+
file[statusKey] = UPLOAD_STATUS.SUCCESS
|
|
139
|
+
currentTask = null
|
|
140
|
+
options.onSuccess?.(res, file, formData)
|
|
141
|
+
},
|
|
142
|
+
onError: (error: UniApp.GeneralCallbackResult, file: UploadFileItem, formData: Record<string, any>) => {
|
|
143
|
+
// 更新文件状态和错误信息
|
|
144
|
+
file[statusKey] = UPLOAD_STATUS.FAIL
|
|
145
|
+
file.error = error.errMsg
|
|
146
|
+
currentTask = null
|
|
147
|
+
options.onError?.(error, file, formData)
|
|
148
|
+
},
|
|
149
|
+
onProgress: (res: UniApp.OnProgressUpdateResult, file: UploadFileItem) => {
|
|
150
|
+
// 更新上传进度
|
|
151
|
+
file.percent = res.progress
|
|
152
|
+
options.onProgress?.(res, file)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 返回上传任务实例,支持外部获取uploadTask进行操作
|
|
157
|
+
if (isFunction(uploadMethod)) {
|
|
158
|
+
return uploadMethod(file, formData, uploadOptions)
|
|
159
|
+
} else {
|
|
160
|
+
return defaultUpload(file, formData, uploadOptions)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 格式化图片信息
|
|
166
|
+
*/
|
|
167
|
+
function formatImage(res: UniApp.ChooseImageSuccessCallbackResult): ChooseFile[] {
|
|
168
|
+
// #ifdef MP-DINGTALK
|
|
169
|
+
// 钉钉文件在files中
|
|
170
|
+
res.tempFiles = isDef((res as any).files) ? (res as any).files : res.tempFiles
|
|
171
|
+
// #endif
|
|
172
|
+
if (isArray(res.tempFiles)) {
|
|
173
|
+
return res.tempFiles.map((item: any) => ({
|
|
174
|
+
path: item.path || '',
|
|
175
|
+
name: item.name || '',
|
|
176
|
+
size: item.size,
|
|
177
|
+
type: 'image',
|
|
178
|
+
thumb: item.path || ''
|
|
179
|
+
}))
|
|
180
|
+
}
|
|
181
|
+
return [
|
|
182
|
+
{
|
|
183
|
+
path: (res.tempFiles as any).path || '',
|
|
184
|
+
name: (res.tempFiles as any).name || '',
|
|
185
|
+
size: (res.tempFiles as any).size,
|
|
186
|
+
type: 'image',
|
|
187
|
+
thumb: (res.tempFiles as any).path || ''
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 格式化视频信息
|
|
194
|
+
*/
|
|
195
|
+
function formatVideo(res: UniApp.ChooseVideoSuccess): ChooseFile[] {
|
|
196
|
+
return [
|
|
197
|
+
{
|
|
198
|
+
path: res.tempFilePath || (res as any).filePath || '',
|
|
199
|
+
name: res.name || '',
|
|
200
|
+
size: res.size,
|
|
201
|
+
type: 'video',
|
|
202
|
+
thumb: (res as any).thumbTempFilePath || '',
|
|
203
|
+
duration: res.duration
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 格式化媒体信息
|
|
210
|
+
*/
|
|
211
|
+
function formatMedia(res: UniApp.ChooseMediaSuccessCallbackResult): ChooseFile[] {
|
|
212
|
+
return res.tempFiles.map((item) => ({
|
|
213
|
+
type: item.fileType,
|
|
214
|
+
path: item.tempFilePath,
|
|
215
|
+
thumb: item.fileType === 'video' ? item.thumbTempFilePath : item.tempFilePath,
|
|
216
|
+
size: item.size,
|
|
217
|
+
duration: item.duration
|
|
218
|
+
}))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 选择文件
|
|
223
|
+
*/
|
|
224
|
+
function chooseFile({
|
|
225
|
+
multiple,
|
|
226
|
+
sizeType,
|
|
227
|
+
sourceType,
|
|
228
|
+
maxCount,
|
|
229
|
+
accept,
|
|
230
|
+
compressed,
|
|
231
|
+
maxDuration,
|
|
232
|
+
camera,
|
|
233
|
+
extension
|
|
234
|
+
}: ChooseFileOption): Promise<ChooseFile[]> {
|
|
235
|
+
return new Promise((resolve, reject) => {
|
|
236
|
+
switch (accept) {
|
|
237
|
+
case 'image':
|
|
238
|
+
// #ifdef MP-WEIXIN
|
|
239
|
+
uni.chooseMedia({
|
|
240
|
+
count: multiple ? maxCount : 1,
|
|
241
|
+
mediaType: ['image'],
|
|
242
|
+
sourceType,
|
|
243
|
+
sizeType,
|
|
244
|
+
camera,
|
|
245
|
+
success: (res) => resolve(formatMedia(res)),
|
|
246
|
+
fail: reject
|
|
247
|
+
})
|
|
248
|
+
// #endif
|
|
249
|
+
// #ifndef MP-WEIXIN
|
|
250
|
+
uni.chooseImage({
|
|
251
|
+
count: multiple ? maxCount : 1,
|
|
252
|
+
sizeType,
|
|
253
|
+
sourceType,
|
|
254
|
+
// #ifdef H5
|
|
255
|
+
extension,
|
|
256
|
+
// #endif
|
|
257
|
+
success: (res) => resolve(formatImage(res)),
|
|
258
|
+
fail: reject
|
|
259
|
+
})
|
|
260
|
+
// #endif
|
|
261
|
+
break
|
|
262
|
+
case 'video':
|
|
263
|
+
// #ifdef MP-WEIXIN
|
|
264
|
+
uni.chooseMedia({
|
|
265
|
+
count: multiple ? maxCount : 1,
|
|
266
|
+
mediaType: ['video'],
|
|
267
|
+
sourceType,
|
|
268
|
+
camera,
|
|
269
|
+
maxDuration,
|
|
270
|
+
success: (res) => resolve(formatMedia(res)),
|
|
271
|
+
fail: reject
|
|
272
|
+
})
|
|
273
|
+
// #endif
|
|
274
|
+
// #ifndef MP-WEIXIN
|
|
275
|
+
uni.chooseVideo({
|
|
276
|
+
sourceType,
|
|
277
|
+
compressed,
|
|
278
|
+
maxDuration,
|
|
279
|
+
camera,
|
|
280
|
+
// #ifdef H5
|
|
281
|
+
extension,
|
|
282
|
+
// #endif
|
|
283
|
+
success: (res) => resolve(formatVideo(res)),
|
|
284
|
+
fail: reject
|
|
285
|
+
})
|
|
286
|
+
// #endif
|
|
287
|
+
break
|
|
288
|
+
// #ifdef MP-WEIXIN
|
|
289
|
+
case 'media':
|
|
290
|
+
uni.chooseMedia({
|
|
291
|
+
count: multiple ? maxCount : 1,
|
|
292
|
+
sourceType,
|
|
293
|
+
sizeType,
|
|
294
|
+
camera,
|
|
295
|
+
maxDuration,
|
|
296
|
+
success: (res) => resolve(formatMedia(res)),
|
|
297
|
+
fail: reject
|
|
298
|
+
})
|
|
299
|
+
break
|
|
300
|
+
case 'file':
|
|
301
|
+
uni.chooseMessageFile({
|
|
302
|
+
count: multiple ? (isDef(maxCount) ? maxCount : 100) : 1,
|
|
303
|
+
type: accept,
|
|
304
|
+
extension,
|
|
305
|
+
success: (res) => resolve(res.tempFiles),
|
|
306
|
+
fail: reject
|
|
307
|
+
})
|
|
308
|
+
break
|
|
309
|
+
// #endif
|
|
310
|
+
case 'all':
|
|
311
|
+
// #ifdef H5
|
|
312
|
+
uni.chooseFile({
|
|
313
|
+
count: multiple ? maxCount : 1,
|
|
314
|
+
type: accept,
|
|
315
|
+
extension,
|
|
316
|
+
success: (res) => resolve(res.tempFiles as ChooseFile[]),
|
|
317
|
+
fail: reject
|
|
318
|
+
})
|
|
319
|
+
// #endif
|
|
320
|
+
// #ifdef MP-WEIXIN
|
|
321
|
+
uni.chooseMessageFile({
|
|
322
|
+
count: multiple ? Number(maxCount) : 1,
|
|
323
|
+
type: accept,
|
|
324
|
+
extension,
|
|
325
|
+
success: (res) => resolve(res.tempFiles),
|
|
326
|
+
fail: reject
|
|
327
|
+
})
|
|
328
|
+
// #endif
|
|
329
|
+
|
|
330
|
+
break
|
|
331
|
+
default:
|
|
332
|
+
// #ifdef MP-WEIXIN
|
|
333
|
+
uni.chooseMedia({
|
|
334
|
+
count: multiple ? maxCount : 1,
|
|
335
|
+
mediaType: ['image'],
|
|
336
|
+
sourceType,
|
|
337
|
+
sizeType,
|
|
338
|
+
camera,
|
|
339
|
+
success: (res) => resolve(formatMedia(res)),
|
|
340
|
+
fail: reject
|
|
341
|
+
})
|
|
342
|
+
// #endif
|
|
343
|
+
// #ifndef MP-WEIXIN
|
|
344
|
+
uni.chooseImage({
|
|
345
|
+
count: multiple ? maxCount : 1,
|
|
346
|
+
sizeType,
|
|
347
|
+
sourceType,
|
|
348
|
+
// #ifdef H5
|
|
349
|
+
extension,
|
|
350
|
+
// #endif
|
|
351
|
+
success: (res) => resolve(formatImage(res)),
|
|
352
|
+
fail: reject
|
|
353
|
+
})
|
|
354
|
+
// #endif
|
|
355
|
+
break
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return {
|
|
361
|
+
startUpload,
|
|
362
|
+
abort,
|
|
363
|
+
UPLOAD_STATUS,
|
|
364
|
+
chooseFile
|
|
365
|
+
}
|
|
366
|
+
}
|
package/global.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
declare module 'vue' {
|
|
2
|
+
// Helper for Volar
|
|
3
|
+
export interface GlobalComponents {
|
|
4
|
+
WdActionSheet: typeof import('./components/wd-action-sheet/wd-action-sheet.vue')['default']
|
|
5
|
+
WdBadge: typeof import('./components/wd-badge/wd-badge.vue')['default']
|
|
6
|
+
WdButton: typeof import('./components/wd-button/wd-button.vue')['default']
|
|
7
|
+
WdCalendar: typeof import('./components/wd-calendar/wd-calendar.vue')['default']
|
|
8
|
+
WdCalendarView: typeof import('./components/wd-calendar-view/wd-calendar-view.vue')['default']
|
|
9
|
+
WdCard: typeof import('./components/wd-card/wd-card.vue')['default']
|
|
10
|
+
WdCell: typeof import('./components/wd-cell/wd-cell.vue')['default']
|
|
11
|
+
WdCellGroup: typeof import('./components/wd-cell-group/wd-cell-group.vue')['default']
|
|
12
|
+
WdCheckbox: typeof import('./components/wd-checkbox/wd-checkbox.vue')['default']
|
|
13
|
+
WdCheckboxGroup: typeof import('./components/wd-checkbox-group/wd-checkbox-group.vue')['default']
|
|
14
|
+
WdCol: typeof import('./components/wd-col/wd-col.vue')['default']
|
|
15
|
+
WdCascader: typeof import('./components/wd-cascader/wd-cascader.vue')['default']
|
|
16
|
+
WdCollapse: typeof import('./components/wd-collapse/wd-collapse.vue')['default']
|
|
17
|
+
WdCollapseItem: typeof import('./components/wd-collapse-item/wd-collapse-item.vue')['default']
|
|
18
|
+
WdConfigProvider: typeof import('./components/wd-config-provider/wd-config-provider.vue')['default']
|
|
19
|
+
WdCurtain: typeof import('./components/wd-curtain/wd-curtain.vue')['default']
|
|
20
|
+
WdDatetimePicker: typeof import('./components/wd-datetime-picker/wd-datetime-picker.vue')['default']
|
|
21
|
+
WdDatetimePickerView: typeof import('./components/wd-datetime-picker-view/wd-datetime-picker-view.vue')['default']
|
|
22
|
+
WdDivider: typeof import('./components/wd-divider/wd-divider.vue')['default']
|
|
23
|
+
WdDropMenu: typeof import('./components/wd-drop-menu/wd-drop-menu.vue')['default']
|
|
24
|
+
WdDropMenuItem: typeof import('./components/wd-drop-menu-item/wd-drop-menu-item.vue')['default']
|
|
25
|
+
WdGrid: typeof import('./components/wd-grid/wd-grid.vue')['default']
|
|
26
|
+
WdGridItem: typeof import('./components/wd-grid-item/wd-grid-item.vue')['default']
|
|
27
|
+
WdIcon: typeof import('./components/wd-icon/wd-icon.vue')['default']
|
|
28
|
+
WdImg: typeof import('./components/wd-img/wd-img.vue')['default']
|
|
29
|
+
WdImgCropper: typeof import('./components/wd-img-cropper/wd-img-cropper.vue')['default']
|
|
30
|
+
WdInput: typeof import('./components/wd-input/wd-input.vue')['default']
|
|
31
|
+
WdInputNumber: typeof import('./components/wd-input-number/wd-input-number.vue')['default']
|
|
32
|
+
WdLoading: typeof import('./components/wd-loading/wd-loading.vue')['default']
|
|
33
|
+
WdLoadmore: typeof import('./components/wd-loadmore/wd-loadmore.vue')['default']
|
|
34
|
+
WdDialog: typeof import('./components/wd-dialog/wd-dialog.vue')['default']
|
|
35
|
+
WdOverlay: typeof import('./components/wd-overlay/wd-overlay.vue')['default']
|
|
36
|
+
WdNoticeBar: typeof import('./components/wd-notice-bar/wd-notice-bar.vue')['default']
|
|
37
|
+
WdPagination: typeof import('./components/wd-pagination/wd-pagination.vue')['default']
|
|
38
|
+
WdPicker: typeof import('./components/wd-picker/wd-picker.vue')['default']
|
|
39
|
+
WdPickerView: typeof import('./components/wd-picker-view/wd-picker-view.vue')['default']
|
|
40
|
+
WdPopover: typeof import('./components/wd-popover/wd-popover.vue')['default']
|
|
41
|
+
WdPopup: typeof import('./components/wd-popup/wd-popup.vue')['default']
|
|
42
|
+
WdProgress: typeof import('./components/wd-progress/wd-progress.vue')['default']
|
|
43
|
+
WdRadio: typeof import('./components/wd-radio/wd-radio.vue')['default']
|
|
44
|
+
WdRadioGroup: typeof import('./components/wd-radio-group/wd-radio-group.vue')['default']
|
|
45
|
+
WdRate: typeof import('./components/wd-rate/wd-rate.vue')['default']
|
|
46
|
+
WdResize: typeof import('./components/wd-resize/wd-resize.vue')['default']
|
|
47
|
+
WdRow: typeof import('./components/wd-row/wd-row.vue')['default']
|
|
48
|
+
WdSearch: typeof import('./components/wd-search/wd-search.vue')['default']
|
|
49
|
+
WdSelectPicker: typeof import('./components/wd-select-picker/wd-select-picker.vue')['default']
|
|
50
|
+
WdSlider: typeof import('./components/wd-slider/wd-slider.vue')['default']
|
|
51
|
+
WdSortButton: typeof import('./components/wd-sort-button/wd-sort-button.vue')['default']
|
|
52
|
+
WdEmpty: typeof import('./components/wd-empty/wd-empty.vue')['default']
|
|
53
|
+
WdStep: typeof import('./components/wd-step/wd-step.vue')['default']
|
|
54
|
+
WdSteps: typeof import('./components/wd-steps/wd-steps.vue')['default']
|
|
55
|
+
WdSticky: typeof import('./components/wd-sticky/wd-sticky.vue')['default']
|
|
56
|
+
WdStickyBox: typeof import('./components/wd-sticky-box/wd-sticky-box.vue')['default']
|
|
57
|
+
WdSwipeAction: typeof import('./components/wd-swipe-action/wd-swipe-action.vue')['default']
|
|
58
|
+
WdSwitch: typeof import('./components/wd-switch/wd-switch.vue')['default']
|
|
59
|
+
WdTab: typeof import('./components/wd-tab/wd-tab.vue')['default']
|
|
60
|
+
WdTabs: typeof import('./components/wd-tabs/wd-tabs.vue')['default']
|
|
61
|
+
WdTag: typeof import('./components/wd-tag/wd-tag.vue')['default']
|
|
62
|
+
WdToast: typeof import('./components/wd-toast/wd-toast.vue')['default']
|
|
63
|
+
WdTooltip: typeof import('./components/wd-tooltip/wd-tooltip.vue')['default']
|
|
64
|
+
WdTransition: typeof import('./components/wd-transition/wd-transition.vue')['default']
|
|
65
|
+
WdUpload: typeof import('./components/wd-upload/wd-upload.vue')['default']
|
|
66
|
+
WdNotify: typeof import('./components/wd-notify/wd-notify.vue')['default']
|
|
67
|
+
WdWatermark: typeof import('./components/wd-watermark/wd-watermark.vue')['default']
|
|
68
|
+
WdCircle: typeof import('./components/wd-circle/wd-circle.vue')['default']
|
|
69
|
+
WdSwiper: typeof import('./components/wd-swiper/wd-swiper.vue')['default']
|
|
70
|
+
WdSwiperNav: typeof import('./components/wd-swiper-nav/wd-swiper-nav.vue')['default']
|
|
71
|
+
WdSegmented: typeof import('./components/wd-segmented/wd-segmented.vue')['default']
|
|
72
|
+
WdTabbar: typeof import('./components/wd-tabbar/wd-tabbar.vue')['default']
|
|
73
|
+
WdTabbarItem: typeof import('./components/wd-tabbar-item/wd-tabbar-item.vue')['default']
|
|
74
|
+
WdNavbar: typeof import('./components/wd-navbar/wd-navbar.vue')['default']
|
|
75
|
+
WdNavbarCapsule: typeof import('./components/wd-navbar-capsule/wd-navbar-capsule.vue')['default']
|
|
76
|
+
WdTable: typeof import('./components/wd-table/wd-table.vue')['default']
|
|
77
|
+
WdTableColumn: typeof import('./components/wd-table-column/wd-table-column.vue')['default']
|
|
78
|
+
WdSidebar: typeof import('./components/wd-sidebar/wd-sidebar.vue')['default']
|
|
79
|
+
WdSidebarItem: typeof import('./components/wd-sidebar-item/wd-sidebar-item.vue')['default']
|
|
80
|
+
WdFab: typeof import('./components/wd-fab/wd-fab.vue')['default']
|
|
81
|
+
WdCountDown: typeof import('./components/wd-count-down/wd-count-down.vue')['default']
|
|
82
|
+
WdKeyboard: typeof import('./components/wd-keyboard/wd-keyboard.vue')['default']
|
|
83
|
+
WdGap: typeof import('./components/wd-gap/wd-gap.vue')['default']
|
|
84
|
+
WdPasswordInput: typeof import('./components/wd-password-input/wd-password-input.vue')['default']
|
|
85
|
+
WdForm: typeof import('./components/wd-form/wd-form.vue')['default']
|
|
86
|
+
WdFormItem: typeof import('./components/wd-form-item/wd-form-item.vue')['default']
|
|
87
|
+
WdTextarea: typeof import('./components/wd-textarea/wd-textarea.vue')['default']
|
|
88
|
+
WdVideoPreview: typeof import('./components/wd-video-preview/wd-video-preview.vue')['default']
|
|
89
|
+
WdBacktop: typeof import('./components/wd-backtop/wd-backtop.vue')['default']
|
|
90
|
+
WdSkeleton: typeof import('./components/wd-skeleton/wd-skeleton.vue')['default']
|
|
91
|
+
WdIndexBar: typeof import('./components/wd-index-bar/wd-index-bar.vue')['default']
|
|
92
|
+
WdIndexAnchor: typeof import('./components/wd-index-anchor/wd-index-anchor.vue')['default']
|
|
93
|
+
WdText: typeof import('./components/wd-text/wd-text.vue')['default']
|
|
94
|
+
WdCountTo: typeof import('./components/wd-count-to/wd-count-to.vue')['default']
|
|
95
|
+
WdFloatingPanel: typeof import('./components/wd-floating-panel/wd-floating-panel.vue')['default']
|
|
96
|
+
WdSignature: typeof import('./components/wd-signature/wd-signature.vue')['default']
|
|
97
|
+
WdRootPortal: typeof import('./components/wd-root-portal/wd-root-portal.vue')['default']
|
|
98
|
+
WdTour: typeof import('./components/wd-tour/wd-tour.vue')['default']
|
|
99
|
+
WdAvatar: typeof import('./components/wd-avatar/wd-avatar.vue')['default']
|
|
100
|
+
WdAvatarGroup: typeof import('./components/wd-avatar-group/wd-avatar-group.vue')['default']
|
|
101
|
+
WdImagePreview: typeof import('./components/wd-image-preview/wd-image-preview.vue')['default']
|
|
102
|
+
WdSlideVerify: typeof import('./components/wd-slide-verify/wd-slide-verify.vue')['default']
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {}
|
package/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './composables'
|
|
2
|
+
export { zodAdapter } from './components/wd-form'
|
|
3
|
+
export type { FormSchema, FormSchemaIssue, FormValidateEvent, FormValidateTrigger } from './components/wd-form'
|
|
4
|
+
export * as CommonUtil from './common/util'
|
|
5
|
+
export * from './locale'
|
|
6
|
+
export type { ConfigProviderThemeVars } from './components/wd-config-provider/types'
|
package/locale/index.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { reactive, ref } from 'vue'
|
|
2
|
+
import zhCN from './lang/zh-CN'
|
|
3
|
+
import { deepAssign } from '../common/util'
|
|
4
|
+
|
|
5
|
+
type Message = Record<string, any>
|
|
6
|
+
type Messages = Record<string, Message>
|
|
7
|
+
|
|
8
|
+
const lang = ref<string>('zh-CN')
|
|
9
|
+
const messages = reactive<Messages>({
|
|
10
|
+
'zh-CN': zhCN
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const Locale = {
|
|
14
|
+
messages(): Message {
|
|
15
|
+
return messages[lang.value]
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
use(newLang: string, newMessage?: Message) {
|
|
19
|
+
lang.value = newLang
|
|
20
|
+
if (newMessage) {
|
|
21
|
+
this.add({ [newLang]: newMessage })
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
add(newMessages: Messages = {}) {
|
|
26
|
+
deepAssign(messages, newMessages)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const useCurrentLang = () => lang
|
|
31
|
+
|
|
32
|
+
export default Locale
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
calendar: {
|
|
3
|
+
placeholder: 'حدد التاريخ',
|
|
4
|
+
title: 'حدد التاريخ',
|
|
5
|
+
day: 'يوم',
|
|
6
|
+
week: 'أسبوع',
|
|
7
|
+
month: 'شهر',
|
|
8
|
+
confirm: 'تأكيد',
|
|
9
|
+
startTime: 'وقت البداية',
|
|
10
|
+
endTime: 'وقت النهاية',
|
|
11
|
+
to: 'إلى',
|
|
12
|
+
timeFormat: 'YY-MM-DD HH:mm:ss',
|
|
13
|
+
dateFormat: 'YYYY-MM-DD',
|
|
14
|
+
weekFormat: (year: number, week: number) => `${year} الأسبوع ${week}`,
|
|
15
|
+
startWeek: 'بداية الأسبوع',
|
|
16
|
+
endWeek: 'نهاية الأسبوع',
|
|
17
|
+
startMonth: 'بداية الشهر',
|
|
18
|
+
endMonth: 'نهاية الشهر',
|
|
19
|
+
monthFormat: 'YYYY-MM'
|
|
20
|
+
},
|
|
21
|
+
calendarView: {
|
|
22
|
+
startTime: 'وقت البداية',
|
|
23
|
+
endTime: 'وقت النهاية',
|
|
24
|
+
weeks: {
|
|
25
|
+
sun: 'الأحد',
|
|
26
|
+
mon: 'الاثنين',
|
|
27
|
+
tue: 'الثلاثاء',
|
|
28
|
+
wed: 'الأربعاء',
|
|
29
|
+
thu: 'الخميس',
|
|
30
|
+
fri: 'الجمعة',
|
|
31
|
+
sat: 'السبت'
|
|
32
|
+
},
|
|
33
|
+
rangePrompt: (maxRange: number) => `لا يمكن أن تزيد الأيام المحددة عن ${maxRange} يوم`,
|
|
34
|
+
rangePromptWeek: (maxRange: number) => `لا يمكن أن تزيد الأسابيع المحددة عن ${maxRange} أسبوع`,
|
|
35
|
+
rangePromptMonth: (maxRange: number) => `لا يمكن أن تزيد الشهور المحددة عن ${maxRange} شهر`,
|
|
36
|
+
monthTitle: 'YYYY-MM',
|
|
37
|
+
yearTitle: 'YYYY',
|
|
38
|
+
month: 'MM',
|
|
39
|
+
hour: (value: number) => `${value} ساعة`,
|
|
40
|
+
minute: (value: number) => `${value} دقيقة`,
|
|
41
|
+
second: (value: number) => `${value} ثانية`
|
|
42
|
+
},
|
|
43
|
+
datetimePicker: {
|
|
44
|
+
start: 'من',
|
|
45
|
+
end: 'إلى',
|
|
46
|
+
to: 'إلى',
|
|
47
|
+
placeholder: 'حدد التاريخ والوقت',
|
|
48
|
+
confirm: 'تأكيد',
|
|
49
|
+
cancel: 'إلغاء'
|
|
50
|
+
},
|
|
51
|
+
collapse: {
|
|
52
|
+
expand: 'توسيع',
|
|
53
|
+
retract: 'طي'
|
|
54
|
+
},
|
|
55
|
+
cascader: {
|
|
56
|
+
title: 'حدد لون',
|
|
57
|
+
placeholder: 'حدد لون',
|
|
58
|
+
select: 'حدد',
|
|
59
|
+
confirm: 'تأكيد'
|
|
60
|
+
},
|
|
61
|
+
loadmore: {
|
|
62
|
+
loading: 'جارٍ التحميل...',
|
|
63
|
+
finished: 'التحميل قد انتهى',
|
|
64
|
+
error: 'فشل التحميل...',
|
|
65
|
+
retry: 'إعادة المحاولة'
|
|
66
|
+
},
|
|
67
|
+
imgCropper: {
|
|
68
|
+
confirm: 'تأكيد',
|
|
69
|
+
cancel: 'إلغاء'
|
|
70
|
+
},
|
|
71
|
+
messageBox: {
|
|
72
|
+
inputPlaceholder: 'الرجاء إدخال المعلومات',
|
|
73
|
+
confirm: 'تأكيد',
|
|
74
|
+
cancel: 'إلغاء',
|
|
75
|
+
inputNoValidate: 'الرجاء التأكد من إدخال المعلومات الصحيحة'
|
|
76
|
+
},
|
|
77
|
+
dialog: {
|
|
78
|
+
inputPlaceholder: 'الرجاء إدخال المعلومات',
|
|
79
|
+
confirm: 'تأكيد',
|
|
80
|
+
cancel: 'إلغاء',
|
|
81
|
+
inputNoValidate: 'الرجاء التأكد من إدخال المعلومات الصحيحة'
|
|
82
|
+
},
|
|
83
|
+
numberKeyboard: {
|
|
84
|
+
confirm: 'إنهاء'
|
|
85
|
+
},
|
|
86
|
+
pagination: {
|
|
87
|
+
prev: 'السابق',
|
|
88
|
+
next: 'التالي',
|
|
89
|
+
page: (value: number) => `صفحة: ${value}`,
|
|
90
|
+
total: (total: number) => `المجموع: ${total}`,
|
|
91
|
+
size: (size: number) => `${size} / صفحة`
|
|
92
|
+
},
|
|
93
|
+
picker: {
|
|
94
|
+
cancel: 'إلغاء',
|
|
95
|
+
done: 'إنهاء',
|
|
96
|
+
placeholder: 'حدد'
|
|
97
|
+
},
|
|
98
|
+
search: {
|
|
99
|
+
search: 'بحث',
|
|
100
|
+
cancel: 'إلغاء'
|
|
101
|
+
},
|
|
102
|
+
steps: {
|
|
103
|
+
wait: 'لم يبدأ',
|
|
104
|
+
finished: 'تم',
|
|
105
|
+
process: 'جاري',
|
|
106
|
+
failed: 'فشل'
|
|
107
|
+
},
|
|
108
|
+
tabs: {
|
|
109
|
+
all: 'الجميع'
|
|
110
|
+
},
|
|
111
|
+
upload: {
|
|
112
|
+
error: 'فشل التحميل'
|
|
113
|
+
},
|
|
114
|
+
input: {
|
|
115
|
+
placeholder: 'الرجاء إدخال المعلومات...'
|
|
116
|
+
},
|
|
117
|
+
selectPicker: {
|
|
118
|
+
title: 'حدد',
|
|
119
|
+
placeholder: 'حدد',
|
|
120
|
+
select: 'حدد',
|
|
121
|
+
confirm: 'تأكيد',
|
|
122
|
+
filterPlaceholder: 'بحث'
|
|
123
|
+
},
|
|
124
|
+
tag: {
|
|
125
|
+
placeholder: 'إدخال',
|
|
126
|
+
add: 'إضافة وسم'
|
|
127
|
+
},
|
|
128
|
+
textarea: {
|
|
129
|
+
placeholder: 'الرجاء إدخال نص متعدد الأسطر هنا...'
|
|
130
|
+
},
|
|
131
|
+
tableCol: {
|
|
132
|
+
indexLabel: 'فهرس'
|
|
133
|
+
},
|
|
134
|
+
tour: {
|
|
135
|
+
prev: 'السابق',
|
|
136
|
+
next: 'التالي',
|
|
137
|
+
finish: 'إنهاء',
|
|
138
|
+
skip: 'تخطي'
|
|
139
|
+
},
|
|
140
|
+
signature: {
|
|
141
|
+
confirmText: 'تأكيد',
|
|
142
|
+
clearText: 'مسح',
|
|
143
|
+
revokeText: 'تراجع',
|
|
144
|
+
restoreText: 'استعادة'
|
|
145
|
+
},
|
|
146
|
+
slideVerify: {
|
|
147
|
+
text: 'اسحب لليمين للتحقق',
|
|
148
|
+
successText: 'تم التحقق بنجاح'
|
|
149
|
+
}
|
|
150
|
+
}
|