@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,518 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="wd-tour" v-if="modelValue" :style="rootStyle" @touchmove.stop.prevent="noop">
|
|
3
|
+
<view class="wd-tour__mask" @click.stop="handleMask">
|
|
4
|
+
<slot name="highlight" :elementInfo="highlightElementInfo">
|
|
5
|
+
<view :class="highlightClass" :style="highlightStyle"></view>
|
|
6
|
+
</slot>
|
|
7
|
+
<view class="wd-tour__popover" :style="popoverStyle">
|
|
8
|
+
<view class="wd-tour__info">
|
|
9
|
+
<slot name="content">
|
|
10
|
+
<rich-text :nodes="currentStep.content"></rich-text>
|
|
11
|
+
</slot>
|
|
12
|
+
</view>
|
|
13
|
+
|
|
14
|
+
<view class="wd-tour__buttons" v-if="showTourButtons">
|
|
15
|
+
<!-- 上一步按钮 -->
|
|
16
|
+
<view class="wd-tour__prev" v-if="currentIndex > 0" @click.stop="handlePrev">
|
|
17
|
+
<slot name="prev">
|
|
18
|
+
<wd-button class="wd-tour__prev-default" size="mini" variant="text">
|
|
19
|
+
{{ prevText }}
|
|
20
|
+
</wd-button>
|
|
21
|
+
</slot>
|
|
22
|
+
</view>
|
|
23
|
+
|
|
24
|
+
<!-- 跳过按钮 -->
|
|
25
|
+
<view class="wd-tour__skip" @click.stop="handleSkip">
|
|
26
|
+
<slot name="skip">
|
|
27
|
+
<wd-button class="wd-tour__skip-default" size="mini" variant="text">
|
|
28
|
+
{{ skipText }}
|
|
29
|
+
</wd-button>
|
|
30
|
+
</slot>
|
|
31
|
+
</view>
|
|
32
|
+
|
|
33
|
+
<!-- 下一步按钮 -->
|
|
34
|
+
<view class="wd-tour__next" v-if="currentIndex !== steps.length - 1" @click.stop="handleNext">
|
|
35
|
+
<slot name="next">
|
|
36
|
+
<wd-button class="wd-tour__next-default" size="mini">
|
|
37
|
+
{{ `${nextText}(${currentIndex + 1}/${steps.length})` }}
|
|
38
|
+
</wd-button>
|
|
39
|
+
</slot>
|
|
40
|
+
</view>
|
|
41
|
+
|
|
42
|
+
<!-- 完成按钮 -->
|
|
43
|
+
<view class="wd-tour__finish" v-if="currentIndex === steps.length - 1" @click.stop="handleFinish">
|
|
44
|
+
<slot name="finish">
|
|
45
|
+
<wd-button class="wd-tour__finish-default" size="mini" type="primary">
|
|
46
|
+
{{ finishText }}
|
|
47
|
+
</wd-button>
|
|
48
|
+
</slot>
|
|
49
|
+
</view>
|
|
50
|
+
</view>
|
|
51
|
+
</view>
|
|
52
|
+
</view>
|
|
53
|
+
</view>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script lang="ts">
|
|
57
|
+
export default {
|
|
58
|
+
name: 'wd-tour',
|
|
59
|
+
options: {
|
|
60
|
+
addGlobalClass: true,
|
|
61
|
+
// #ifndef MP-TOUTIAO
|
|
62
|
+
virtualHost: true,
|
|
63
|
+
// #endif
|
|
64
|
+
styleIsolation: 'shared'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<script lang="ts" setup>
|
|
70
|
+
import { ref, computed, watch, nextTick, type CSSProperties } from 'vue'
|
|
71
|
+
import { addUnit, getRect, getSystemInfo, isDef, objToStyle } from '../../common/util'
|
|
72
|
+
import { tourProps, type TourEmits, type TourExpose } from './types'
|
|
73
|
+
import { useRaf } from '../../composables/useRaf'
|
|
74
|
+
import { useTranslate } from '../../composables/useTranslate'
|
|
75
|
+
import wdButton from '../wd-button/wd-button.vue'
|
|
76
|
+
|
|
77
|
+
const props = defineProps(tourProps)
|
|
78
|
+
const emit = defineEmits<TourEmits>()
|
|
79
|
+
const { translate } = useTranslate('tour')
|
|
80
|
+
|
|
81
|
+
const prevText = computed(() => {
|
|
82
|
+
return isDef(props.prevText) ? props.prevText : translate('prev')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const nextText = computed(() => {
|
|
86
|
+
return isDef(props.nextText) ? props.nextText : translate('next')
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const skipText = computed(() => {
|
|
90
|
+
return isDef(props.skipText) ? props.skipText : translate('skip')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const finishText = computed(() => {
|
|
94
|
+
return isDef(props.finishText) ? props.finishText : translate('finish')
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const currentIndex = ref<number>(0) // 当前步骤索引
|
|
98
|
+
const elementInfo = ref<UniApp.NodeInfo>({
|
|
99
|
+
top: 0,
|
|
100
|
+
left: 0,
|
|
101
|
+
width: 0,
|
|
102
|
+
height: 0
|
|
103
|
+
}) // 元素信息
|
|
104
|
+
const windowHeight = ref<number>(0) // 窗口高度
|
|
105
|
+
const windowTop = ref<number>(0) // 窗口顶部位置
|
|
106
|
+
const isElementInTop = ref<boolean>(true) // 判断元素位置,确定提示信息在该元素的上方还是下方,true为上方,false为下方
|
|
107
|
+
const lastScrollTop = ref<number>(0) //记录上一次滚动位置
|
|
108
|
+
const statusBarHeight = ref<number>(0) // 状态栏高度
|
|
109
|
+
const menuButtonInfo = ref(null as UniNamespace.GetMenuButtonBoundingClientRectRes | null)
|
|
110
|
+
const topOffset = ref<number>(0) // 顶部偏移量
|
|
111
|
+
|
|
112
|
+
const rootStyle = computed(() => {
|
|
113
|
+
const style: CSSProperties = {}
|
|
114
|
+
if (isDef(props.zIndex)) {
|
|
115
|
+
style.zIndex = props.zIndex
|
|
116
|
+
}
|
|
117
|
+
return objToStyle(style)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const highlightClass = computed(() => {
|
|
121
|
+
return `wd-tour__highlight ${props.mask ? 'wd-tour__highlight--mask' : ''}`
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// 计算属性
|
|
125
|
+
const currentStep = computed(() => {
|
|
126
|
+
return props.steps[currentIndex.value] || {}
|
|
127
|
+
})
|
|
128
|
+
// 提取公共的默认样式函数
|
|
129
|
+
/**
|
|
130
|
+
* 获取默认样式
|
|
131
|
+
*/
|
|
132
|
+
function getDefaultStyle(): CSSProperties {
|
|
133
|
+
return {
|
|
134
|
+
transition: props.duration + 'ms all'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 计算高亮样式
|
|
140
|
+
* @param padding 内边距
|
|
141
|
+
*/
|
|
142
|
+
function calculateHighlightStyle(padding: number): CSSProperties {
|
|
143
|
+
return {
|
|
144
|
+
transition: props.duration + 'ms all,boxShadow 0s,height 0s,width 0s',
|
|
145
|
+
borderRadius: addUnit(props.borderRadius),
|
|
146
|
+
padding: addUnit(padding)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const highlightStyle = computed(() => {
|
|
150
|
+
// 如果元素信息尚未获取到,返回空样式避免闪烁
|
|
151
|
+
if (!elementInfo.value.width && !elementInfo.value.height) {
|
|
152
|
+
return getDefaultStyle()
|
|
153
|
+
}
|
|
154
|
+
const stepPadding = Number(isDef(currentStep.value.padding) ? currentStep.value.padding : props.padding)
|
|
155
|
+
const baseStyle = calculateHighlightStyle(stepPadding)
|
|
156
|
+
const style: CSSProperties = {
|
|
157
|
+
...baseStyle,
|
|
158
|
+
top: addUnit((elementInfo.value.top || 0) - stepPadding),
|
|
159
|
+
left: addUnit((elementInfo.value.left || 0) - stepPadding),
|
|
160
|
+
height: addUnit(elementInfo.value.height || 0),
|
|
161
|
+
width: addUnit(elementInfo.value.width || 0)
|
|
162
|
+
}
|
|
163
|
+
if (isDef(props.mask) && isDef(props.maskColor)) {
|
|
164
|
+
style.boxShadow = `0 0 0 100vh ${props.maskColor}`
|
|
165
|
+
}
|
|
166
|
+
return objToStyle([{ ...style }, props.highlightStyle])
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const popoverStyle = computed(() => {
|
|
170
|
+
const style: CSSProperties = {}
|
|
171
|
+
if (isDef(props.zIndex)) {
|
|
172
|
+
const zIndex = Number(props.zIndex)
|
|
173
|
+
style.zIndex = zIndex + 1
|
|
174
|
+
style.transitionDuration = `${props.duration}ms`
|
|
175
|
+
}
|
|
176
|
+
const stepPadding = Number(isDef(currentStep.value.offset) ? currentStep.value.offset : props.offset)
|
|
177
|
+
const placement = isDef(currentStep.value.placement) ? currentStep.value.placement : 'auto'
|
|
178
|
+
const down = placement === 'bottom' || (placement === 'auto' && isElementInTop.value)
|
|
179
|
+
if (down) {
|
|
180
|
+
// 提示在元素下方
|
|
181
|
+
style.top = addUnit((elementInfo.value.top || 0) + (elementInfo.value.height || 0) + Number(stepPadding))
|
|
182
|
+
} else {
|
|
183
|
+
// 提示在元素上方
|
|
184
|
+
style.bottom = addUnit(windowHeight.value + windowTop.value - (elementInfo.value.top || 0) + Number(stepPadding))
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return objToStyle(style)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const highlightElementInfo = computed(() => {
|
|
191
|
+
const stepPadding = Number(isDef(currentStep.value.padding) ? currentStep.value.padding : props.padding)
|
|
192
|
+
// 如果元素信息尚未获取到,返回空样式避免闪烁
|
|
193
|
+
if (!elementInfo.value.width && !elementInfo.value.height) {
|
|
194
|
+
return getDefaultStyle()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const baseStyle = calculateHighlightStyle(stepPadding)
|
|
198
|
+
const style: CSSProperties = {
|
|
199
|
+
...baseStyle,
|
|
200
|
+
top: addUnit((elementInfo.value.top || 0) - stepPadding),
|
|
201
|
+
left: addUnit((elementInfo.value.left || 0) - stepPadding),
|
|
202
|
+
width: addUnit((elementInfo.value.width || 0) + stepPadding * 2),
|
|
203
|
+
height: addUnit((elementInfo.value.height || 0) + stepPadding * 2)
|
|
204
|
+
}
|
|
205
|
+
if (isDef(props.mask) && isDef(props.maskColor)) {
|
|
206
|
+
style.boxShadow = `0 0 0 100vh ${props.maskColor}`
|
|
207
|
+
}
|
|
208
|
+
return style
|
|
209
|
+
})
|
|
210
|
+
function noop() {}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 更新元素信息
|
|
214
|
+
*/
|
|
215
|
+
async function updateElementInfo() {
|
|
216
|
+
updateSystemInfo()
|
|
217
|
+
const element = currentStep.value.element
|
|
218
|
+
if (!element) return
|
|
219
|
+
try {
|
|
220
|
+
const res = (await getRect(element, false, props.scope)) as UniApp.NodeInfo
|
|
221
|
+
initializeElementInfo(res)
|
|
222
|
+
const effectiveBoundaries = getEffectiveBoundaries()
|
|
223
|
+
const scrollNeeds = checkScrollNeeds(res, effectiveBoundaries)
|
|
224
|
+
handleScrolling(res, scrollNeeds, effectiveBoundaries)
|
|
225
|
+
calculateTipPosition(res)
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error('updateElementInfo error:', error)
|
|
228
|
+
emit('error', {
|
|
229
|
+
message: '无法找到指定的引导元素',
|
|
230
|
+
element: element
|
|
231
|
+
})
|
|
232
|
+
if (props.missingStrategy === 'skip') {
|
|
233
|
+
handleNext()
|
|
234
|
+
} else if (props.missingStrategy === 'hide') {
|
|
235
|
+
emit('update:modelValue', false)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 更新系统信息
|
|
242
|
+
*/
|
|
243
|
+
function updateSystemInfo() {
|
|
244
|
+
const sysInfo = getSystemInfo()
|
|
245
|
+
windowHeight.value = sysInfo.windowHeight
|
|
246
|
+
windowTop.value = sysInfo.windowTop || 0
|
|
247
|
+
statusBarHeight.value = sysInfo.statusBarHeight || 0
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 初始化元素信息
|
|
252
|
+
* @param res 元素节点信息
|
|
253
|
+
*/
|
|
254
|
+
function initializeElementInfo(res: UniApp.NodeInfo) {
|
|
255
|
+
elementInfo.value = res
|
|
256
|
+
// 调整元素位置信息,加上窗口顶部偏移量
|
|
257
|
+
elementInfo.value.top = (res.top || 0) + windowTop.value
|
|
258
|
+
elementInfo.value.bottom = ((res.bottom !== undefined ? res.bottom : (res.top || 0) + (res.height || 0)) as number) + windowTop.value
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 获取有效的页面边界(顶部和底部安全区域)
|
|
263
|
+
*/
|
|
264
|
+
function getEffectiveBoundaries() {
|
|
265
|
+
// 有效顶部边界初始化为窗口顶部 + 顶部偏移量
|
|
266
|
+
let effectiveWindowTop = windowTop.value + Number(topOffset.value)
|
|
267
|
+
// 有效底部边界为窗口高度
|
|
268
|
+
let effectiveWindowBottom = windowHeight.value
|
|
269
|
+
return {
|
|
270
|
+
top: effectiveWindowTop,
|
|
271
|
+
bottom: effectiveWindowBottom
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 检查是否需要滚动
|
|
277
|
+
* @param res 元素节点信息
|
|
278
|
+
* @param boundaries 边界信息
|
|
279
|
+
*/
|
|
280
|
+
function checkScrollNeeds(res: UniApp.NodeInfo, boundaries: { top: number; bottom: number }) {
|
|
281
|
+
// 判断元素是否被顶部遮挡(需要向上滚动)
|
|
282
|
+
const needScrollUp = Number(res.top) < boundaries.top
|
|
283
|
+
// 判断元素是否被底部遮挡(需要向下滚动)
|
|
284
|
+
const needScrollDown = (res.bottom !== undefined ? res.bottom : 0) + Number(props.bottomSafetyOffset) > boundaries.bottom
|
|
285
|
+
return {
|
|
286
|
+
up: needScrollUp, //提示框往上走
|
|
287
|
+
down: needScrollDown //提示框往下走
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* 处理滚动逻辑
|
|
293
|
+
* @param res 元素节点信息
|
|
294
|
+
* @param scrollNeeds 滚动需求
|
|
295
|
+
* @param boundaries 边界信息
|
|
296
|
+
*/
|
|
297
|
+
function handleScrolling(res: UniApp.NodeInfo, scrollNeeds: { up: boolean; down: boolean }, boundaries: { top: number; bottom: number }) {
|
|
298
|
+
if (scrollNeeds.up) {
|
|
299
|
+
// 元素被顶部遮挡,需要提示框往上走,页面往下走
|
|
300
|
+
scrollUp(res, boundaries)
|
|
301
|
+
} else if (scrollNeeds.down) {
|
|
302
|
+
// 元素被底部遮挡,需要提示框向下走,页面向上走
|
|
303
|
+
scrollDown(res)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* 向引导上滚动处理
|
|
309
|
+
* @param res 元素节点信息
|
|
310
|
+
* @param boundaries 边界信息
|
|
311
|
+
*/
|
|
312
|
+
function scrollUp(res: UniApp.NodeInfo, boundaries: { top: number; bottom: number }) {
|
|
313
|
+
// 计算需要滚动的距离
|
|
314
|
+
let scrollDistance = lastScrollTop.value + Number(res.top) - props.padding - boundaries.top
|
|
315
|
+
// 更新元素位置信息(滚动后)
|
|
316
|
+
elementInfo.value.top = boundaries.top + props.padding
|
|
317
|
+
elementInfo.value.bottom = windowHeight.value - (boundaries.top + props.padding)
|
|
318
|
+
uni.pageScrollTo({
|
|
319
|
+
scrollTop: scrollDistance,
|
|
320
|
+
duration: Number(props.duration),
|
|
321
|
+
success: () => {
|
|
322
|
+
// 更新已滚动距离
|
|
323
|
+
lastScrollTop.value = scrollDistance
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 引导向下滚动处理
|
|
330
|
+
* @param res 元素节点信息
|
|
331
|
+
*/
|
|
332
|
+
function scrollDown(res: UniApp.NodeInfo) {
|
|
333
|
+
// 计算需要滚动的距离
|
|
334
|
+
const bottom = res.bottom || 0
|
|
335
|
+
let scrollDistance = bottom - windowHeight.value + props.padding + Number(props.bottomSafetyOffset)
|
|
336
|
+
|
|
337
|
+
// 更新元素位置信息(滚动后)
|
|
338
|
+
elementInfo.value.top = windowHeight.value - bottom - props.padding - Number(props.bottomSafetyOffset) // 应该是减去安全偏移量
|
|
339
|
+
elementInfo.value.bottom = windowHeight.value - props.padding - Number(props.bottomSafetyOffset)
|
|
340
|
+
|
|
341
|
+
uni.pageScrollTo({
|
|
342
|
+
scrollTop: scrollDistance + lastScrollTop.value,
|
|
343
|
+
duration: Number(props.duration),
|
|
344
|
+
success: () => {
|
|
345
|
+
// 更新已滚动距离
|
|
346
|
+
lastScrollTop.value = scrollDistance + lastScrollTop.value
|
|
347
|
+
}
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* 计算提示框显示位置(上方或下方)
|
|
353
|
+
* @param res 元素节点信息
|
|
354
|
+
*/
|
|
355
|
+
function calculateTipPosition(res: UniApp.NodeInfo) {
|
|
356
|
+
// 计算导航区域总高度
|
|
357
|
+
let totalNavHeight = statusBarHeight.value
|
|
358
|
+
// 计算屏幕中心点位置
|
|
359
|
+
const screenCenter = (windowHeight.value + totalNavHeight) / 2 + windowTop.value
|
|
360
|
+
|
|
361
|
+
// 计算元素中心点位置
|
|
362
|
+
const elementCenter = (res.top || 0) + (res.height || 0) / 2 + windowTop.value
|
|
363
|
+
|
|
364
|
+
// 根据元素位置决定提示框显示在上方还是下方
|
|
365
|
+
if (elementCenter < screenCenter) {
|
|
366
|
+
isElementInTop.value = true
|
|
367
|
+
} else {
|
|
368
|
+
isElementInTop.value = false
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* 上一步
|
|
374
|
+
*/
|
|
375
|
+
function handlePrev() {
|
|
376
|
+
if (currentIndex.value > 0) {
|
|
377
|
+
const oldIndex = currentIndex.value
|
|
378
|
+
currentIndex.value--
|
|
379
|
+
emit('prev', {
|
|
380
|
+
prevCurrent: oldIndex,
|
|
381
|
+
current: currentIndex.value,
|
|
382
|
+
total: props.steps.length,
|
|
383
|
+
isElementInTop: isElementInTop.value
|
|
384
|
+
})
|
|
385
|
+
emit('change', { current: currentIndex.value })
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 下一步
|
|
391
|
+
*/
|
|
392
|
+
function handleNext() {
|
|
393
|
+
if (currentIndex.value < props.steps.length - 1) {
|
|
394
|
+
const oldIndex = currentIndex.value
|
|
395
|
+
currentIndex.value++
|
|
396
|
+
emit('next', {
|
|
397
|
+
prevCurrent: oldIndex,
|
|
398
|
+
current: currentIndex.value,
|
|
399
|
+
total: props.steps.length,
|
|
400
|
+
isElementInTop: isElementInTop.value
|
|
401
|
+
})
|
|
402
|
+
emit('change', { current: currentIndex.value })
|
|
403
|
+
} else {
|
|
404
|
+
handleFinish()
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* 完成
|
|
410
|
+
*/
|
|
411
|
+
function handleFinish() {
|
|
412
|
+
emit('finish', {
|
|
413
|
+
current: currentIndex.value,
|
|
414
|
+
total: props.steps.length
|
|
415
|
+
})
|
|
416
|
+
currentIndex.value = 0
|
|
417
|
+
lastScrollTop.value = 0 // 重置滚动位置
|
|
418
|
+
emit('update:modelValue', false)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* 跳过
|
|
423
|
+
*/
|
|
424
|
+
function handleSkip() {
|
|
425
|
+
emit('skip', {
|
|
426
|
+
current: currentIndex.value,
|
|
427
|
+
total: props.steps.length
|
|
428
|
+
})
|
|
429
|
+
currentIndex.value = 0
|
|
430
|
+
lastScrollTop.value = 0 // 重置滚动位置
|
|
431
|
+
emit('update:modelValue', false)
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* 点击遮罩层
|
|
435
|
+
*/
|
|
436
|
+
function handleMask() {
|
|
437
|
+
if (props.clickMaskNext) {
|
|
438
|
+
handleNext()
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
watch(
|
|
443
|
+
() => props.current,
|
|
444
|
+
(newVal) => {
|
|
445
|
+
currentIndex.value = newVal
|
|
446
|
+
}
|
|
447
|
+
)
|
|
448
|
+
// 在 setup 作用域中创建 raf 实例,避免在 watch 回调中调用 onUnmounted
|
|
449
|
+
const indexRaf = useRaf(updateElementInfo)
|
|
450
|
+
const modelRaf = useRaf(() => {
|
|
451
|
+
updateElementInfo()
|
|
452
|
+
emit('update:current', currentIndex.value)
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
// 监听 currentIndex 变化,同步到父组件
|
|
456
|
+
watch(
|
|
457
|
+
() => currentIndex.value,
|
|
458
|
+
(newVal) => {
|
|
459
|
+
indexRaf.cancel()
|
|
460
|
+
nextTick(() => {
|
|
461
|
+
indexRaf.start()
|
|
462
|
+
})
|
|
463
|
+
emit('update:current', newVal)
|
|
464
|
+
}
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
// 监听 modelValue 变化,当组件显示时更新系统信息
|
|
468
|
+
watch(
|
|
469
|
+
() => props.modelValue,
|
|
470
|
+
(newVal) => {
|
|
471
|
+
if (newVal) {
|
|
472
|
+
// 组件显示时重置滚动位置并更新系统信息
|
|
473
|
+
lastScrollTop.value = 0
|
|
474
|
+
updateSystemInfo()
|
|
475
|
+
modelRaf.cancel()
|
|
476
|
+
nextTick(() => {
|
|
477
|
+
modelRaf.start()
|
|
478
|
+
})
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
immediate: true
|
|
483
|
+
}
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
// 所有平台统一处理逻辑
|
|
487
|
+
if (props.customNav) {
|
|
488
|
+
// 开启了自定义导航栏
|
|
489
|
+
if (props.topSafetyOffset && Number(props.topSafetyOffset) > 0) {
|
|
490
|
+
// 用户传入了顶部安全偏移量,优先使用用户设置的值
|
|
491
|
+
topOffset.value = Number(props.topSafetyOffset)
|
|
492
|
+
} else {
|
|
493
|
+
// 未传入顶部偏移量
|
|
494
|
+
// #ifdef MP
|
|
495
|
+
// 微信小程序平台获取菜单按钮信息并使用其顶部位置
|
|
496
|
+
menuButtonInfo.value = uni.getMenuButtonBoundingClientRect() || null
|
|
497
|
+
topOffset.value = menuButtonInfo.value ? menuButtonInfo.value.top : 0
|
|
498
|
+
// #endif
|
|
499
|
+
// #ifndef MP
|
|
500
|
+
// 非微信小程序平台默认为0
|
|
501
|
+
topOffset.value = 0
|
|
502
|
+
// #endif
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
// 未开启自定义导航栏,直接使用用户传入的顶部安全偏移量
|
|
506
|
+
topOffset.value = Number(props.topSafetyOffset) || 0
|
|
507
|
+
}
|
|
508
|
+
defineExpose<TourExpose>({
|
|
509
|
+
handlePrev,
|
|
510
|
+
handleNext,
|
|
511
|
+
handleFinish,
|
|
512
|
+
handleSkip
|
|
513
|
+
})
|
|
514
|
+
</script>
|
|
515
|
+
|
|
516
|
+
<style lang="scss">
|
|
517
|
+
@use './index.scss';
|
|
518
|
+
</style>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss' as *;
|
|
2
|
+
|
|
3
|
+
@include b(transition) {
|
|
4
|
+
transition-timing-function: ease;
|
|
5
|
+
|
|
6
|
+
@include transitionFrame(fade) {
|
|
7
|
+
opacity: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@include transitionActive(fade) {
|
|
11
|
+
transition-property: opacity;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@include transitionFrame(fade-up) {
|
|
15
|
+
transform: translate3d(0, 100%, 0);
|
|
16
|
+
opacity: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@include transitionFrame(fade-down) {
|
|
20
|
+
transform: translate3d(0, -100%, 0);
|
|
21
|
+
opacity: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@include transitionFrame(fade-left) {
|
|
25
|
+
transform: translate3d(-100%, 0, 0);
|
|
26
|
+
opacity: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@include transitionFrame(fade-right) {
|
|
30
|
+
transform: translate3d(100%, 0, 0);
|
|
31
|
+
opacity: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@include transitionFrame(slide-up) {
|
|
35
|
+
transform: translate3d(0, 100%, 0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@include transitionFrame(slide-down) {
|
|
39
|
+
transform: translate3d(0, -100%, 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@include transitionFrame(slide-left) {
|
|
43
|
+
transform: translate3d(-100%, 0, 0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@include transitionFrame(slide-right) {
|
|
47
|
+
transform: translate3d(100%, 0, 0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@include transitionFrame(zoom-in) {
|
|
51
|
+
opacity: 0;
|
|
52
|
+
transform: scale(0.8);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@include transitionFrame(zoom-out) {
|
|
56
|
+
transform: scale(1.2);
|
|
57
|
+
opacity: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@include transitionActive(zoom-in, zoom-out, fade-up, fade-down, fade-left, fade-right) {
|
|
61
|
+
transition-property: opacity, transform;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@include transitionActive(slide-up, slide-down, slide-left, slide-right) {
|
|
65
|
+
transition-property: transform;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2026-03-13 17:20:03
|
|
4
|
+
* @LastEditTime: 2026-04-06 23:06:51
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-ui/src/uni_modules/wot-ui/components/wd-transition/types.ts
|
|
8
|
+
* 记得注释
|
|
9
|
+
*/
|
|
10
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
11
|
+
import { baseProps, makeBooleanProp, makeStringProp } from '../../common/props'
|
|
12
|
+
|
|
13
|
+
export type TransitionName =
|
|
14
|
+
| 'fade'
|
|
15
|
+
| 'fade-down'
|
|
16
|
+
| 'fade-left'
|
|
17
|
+
| 'fade-right'
|
|
18
|
+
| 'fade-up'
|
|
19
|
+
| 'slide-down'
|
|
20
|
+
| 'slide-left'
|
|
21
|
+
| 'slide-right'
|
|
22
|
+
| 'slide-up'
|
|
23
|
+
| 'zoom-in'
|
|
24
|
+
| 'zoom-out'
|
|
25
|
+
|
|
26
|
+
export const transitionProps = {
|
|
27
|
+
...baseProps,
|
|
28
|
+
/**
|
|
29
|
+
* 是否展示组件
|
|
30
|
+
* 类型: boolean
|
|
31
|
+
* 默认值: false
|
|
32
|
+
*/
|
|
33
|
+
show: makeBooleanProp(false),
|
|
34
|
+
/**
|
|
35
|
+
* 动画执行时间,单位毫秒
|
|
36
|
+
* 类型: Record<string, number> | number | boolean
|
|
37
|
+
* 默认值: 300
|
|
38
|
+
*/
|
|
39
|
+
duration: {
|
|
40
|
+
type: [Object, Number, Boolean] as PropType<Record<string, number> | number | boolean>,
|
|
41
|
+
default: 300
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* 弹层内容懒渲染,触发展示时才渲染内容
|
|
45
|
+
* 类型: boolean
|
|
46
|
+
* 默认值: false
|
|
47
|
+
*/
|
|
48
|
+
lazyRender: makeBooleanProp(false),
|
|
49
|
+
/**
|
|
50
|
+
* 动画类型
|
|
51
|
+
* 类型: TransitionName | TransitionName[]
|
|
52
|
+
* 可选值: 'fade' | 'fade-up' | 'fade-down' | 'fade-left' | 'fade-right' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'zoom-in' | 'zoom-out'
|
|
53
|
+
* 默认值: 'fade'
|
|
54
|
+
*/
|
|
55
|
+
name: [String, Array] as PropType<TransitionName | TransitionName[]>,
|
|
56
|
+
/**
|
|
57
|
+
* 是否在动画结束时销毁子节点(display: none)
|
|
58
|
+
* 类型: boolean
|
|
59
|
+
* 默认值: true
|
|
60
|
+
*/
|
|
61
|
+
destroy: makeBooleanProp(true),
|
|
62
|
+
/**
|
|
63
|
+
* 进入过渡的开始状态
|
|
64
|
+
* 类型: string
|
|
65
|
+
* 默认值: ''
|
|
66
|
+
*/
|
|
67
|
+
enterClass: makeStringProp(''),
|
|
68
|
+
/**
|
|
69
|
+
* 进入过渡的激活状态
|
|
70
|
+
* 类型: string
|
|
71
|
+
* 默认值: ''
|
|
72
|
+
*/
|
|
73
|
+
enterActiveClass: makeStringProp(''),
|
|
74
|
+
/**
|
|
75
|
+
* 进入过渡的结束状态
|
|
76
|
+
* 类型: string
|
|
77
|
+
* 默认值: ''
|
|
78
|
+
*/
|
|
79
|
+
enterToClass: makeStringProp(''),
|
|
80
|
+
/**
|
|
81
|
+
* 离开过渡的开始状态
|
|
82
|
+
* 类型: string
|
|
83
|
+
* 默认值: ''
|
|
84
|
+
*/
|
|
85
|
+
leaveClass: makeStringProp(''),
|
|
86
|
+
/**
|
|
87
|
+
* 离开过渡的激活状态
|
|
88
|
+
* 类型: string
|
|
89
|
+
* 默认值: ''
|
|
90
|
+
*/
|
|
91
|
+
leaveActiveClass: makeStringProp(''),
|
|
92
|
+
/**
|
|
93
|
+
* 离开过渡的结束状态
|
|
94
|
+
* 类型: string
|
|
95
|
+
* 默认值: ''
|
|
96
|
+
*/
|
|
97
|
+
leaveToClass: makeStringProp(''),
|
|
98
|
+
/**
|
|
99
|
+
* 是否阻止触摸滚动
|
|
100
|
+
* 类型: boolean
|
|
101
|
+
* 默认值: false
|
|
102
|
+
*/
|
|
103
|
+
disableTouchMove: makeBooleanProp(false)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type TransitionProps = ExtractPropTypes<typeof transitionProps>
|