stellar-ui-plus 1.25.0 → 1.25.2
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/components/ste-animate/ATTRIBUTES.md +13 -5
- package/components/ste-animate/README.md +4 -28
- package/components/ste-animate/ste-animate.easycom.json +31 -9
- package/components/ste-app-update/ATTRIBUTES.md +11 -5
- package/components/ste-app-update/README.md +1 -3
- package/components/ste-app-update/method.ts +44 -1
- package/components/ste-app-update/props.ts +17 -2
- package/components/ste-app-update/ste-app-update.easycom.json +18 -8
- package/components/ste-app-update/ste-app-update.vue +93 -18
- package/components/ste-area-chart/ATTRIBUTES.md +3 -1
- package/components/ste-area-chart/README.md +4 -4
- package/components/ste-badge/ATTRIBUTES.md +10 -1
- package/components/ste-badge/README.md +9 -18
- package/components/ste-badge/ste-badge.easycom.json +8 -0
- package/components/ste-bar-chart/ATTRIBUTES.md +3 -1
- package/components/ste-bar-chart/README.md +3 -5
- package/components/ste-barcode/ATTRIBUTES.md +6 -2
- package/components/ste-barcode/README.md +3 -5
- package/components/ste-barcode/ste-barcode.easycom.json +1 -2
- package/components/ste-button/ATTRIBUTES.md +24 -14
- package/components/ste-button/README.md +11 -19
- package/components/ste-button/ste-button.easycom.json +76 -12
- package/components/ste-calendar/ATTRIBUTES.md +12 -2
- package/components/ste-calendar/README.md +16 -24
- package/components/ste-calendar/ste-calendar.easycom.json +4 -3
- package/components/ste-category/ATTRIBUTES.md +6 -2
- package/components/ste-category/README.md +2 -4
- package/components/ste-category/ste-category.easycom.json +1 -2
- package/components/ste-checkbox/ATTRIBUTES.md +6 -2
- package/components/ste-checkbox/README.md +18 -20
- package/components/ste-checkbox/ste-checkbox.easycom.json +1 -3
- package/components/ste-checkbox/ste-checkbox.vue +71 -80
- package/components/ste-code-input/ATTRIBUTES.md +8 -4
- package/components/ste-code-input/README.md +7 -9
- package/components/ste-code-input/ste-code-input.easycom.json +13 -4
- package/components/ste-column-chart/ATTRIBUTES.md +3 -1
- package/components/ste-column-chart/README.md +5 -7
- package/components/ste-comment/ATTRIBUTES.md +3 -1
- package/components/ste-comment/README.md +2 -4
- package/components/ste-coupon-list/ATTRIBUTES.md +15 -5
- package/components/ste-coupon-list/README.md +6 -14
- package/components/ste-coupon-list/ste-coupon-list.easycom.json +22 -3
- package/components/ste-custom-keyboard/ATTRIBUTES.md +16 -7
- package/components/ste-custom-keyboard/README.md +10 -18
- package/components/ste-custom-keyboard/ste-custom-keyboard.easycom.json +28 -10
- package/components/ste-date-picker/ATTRIBUTES.md +9 -5
- package/components/ste-date-picker/README.md +9 -11
- package/components/ste-date-picker/ste-date-picker.easycom.json +19 -4
- package/components/ste-date-user/ATTRIBUTES.md +9 -1
- package/components/ste-date-user/README.md +3 -11
- package/components/ste-date-user/ste-date-user.easycom.json +4 -0
- package/components/ste-drag/ATTRIBUTES.md +13 -3
- package/components/ste-drag/README.md +5 -13
- package/components/ste-drag/ste-drag.easycom.json +10 -2
- package/components/ste-drag-sort/ATTRIBUTES.md +25 -0
- package/components/ste-drag-sort/README.md +116 -0
- package/components/ste-drag-sort/config.json +5 -0
- package/components/ste-drag-sort/props.ts +16 -0
- package/components/ste-drag-sort/ste-drag-sort.easycom.json +88 -0
- package/components/ste-drag-sort/ste-drag-sort.vue +589 -0
- package/components/ste-dropdown-menu/ATTRIBUTES.md +8 -4
- package/components/ste-dropdown-menu/README.md +14 -16
- package/components/ste-dropdown-menu/ste-dropdown-menu.easycom.json +13 -4
- package/components/ste-filter-tool/ATTRIBUTES.md +6 -2
- package/components/ste-filter-tool/README.md +4 -6
- package/components/ste-filter-tool/ste-filter-tool.easycom.json +1 -5
- package/components/ste-function-list/ATTRIBUTES.md +13 -2
- package/components/ste-function-list/README.md +3 -12
- package/components/ste-function-list/ste-function-list.easycom.json +8 -3
- package/components/ste-funnel-chart/ATTRIBUTES.md +3 -1
- package/components/ste-funnel-chart/README.md +4 -6
- package/components/ste-goods-info/ATTRIBUTES.md +15 -4
- package/components/ste-goods-info/README.md +8 -17
- package/components/ste-goods-info/ste-goods-info.easycom.json +40 -13
- package/components/ste-goods-list/ATTRIBUTES.md +9 -1
- package/components/ste-goods-list/README.md +4 -12
- package/components/ste-goods-list/ste-goods-list.easycom.json +4 -0
- package/components/ste-guide-qa/ATTRIBUTES.md +15 -4
- package/components/ste-guide-qa/README.md +6 -15
- package/components/ste-guide-qa/ste-guide-qa.easycom.json +20 -2
- package/components/ste-icon/ATTRIBUTES.md +7 -3
- package/components/ste-icon/README.md +5 -7
- package/components/ste-icon/ste-icon.easycom.json +7 -2
- package/components/ste-image/ATTRIBUTES.md +13 -2
- package/components/ste-image/README.md +6 -15
- package/components/ste-image/ste-image.easycom.json +8 -3
- package/components/ste-index-list/ATTRIBUTES.md +8 -4
- package/components/ste-index-list/README.md +6 -8
- package/components/ste-index-list/ste-index-list.easycom.json +13 -3
- package/components/ste-input/ATTRIBUTES.md +14 -3
- package/components/ste-input/README.md +16 -25
- package/components/ste-input/ste-input.easycom.json +14 -5
- package/components/ste-line-chart/ATTRIBUTES.md +3 -1
- package/components/ste-line-chart/README.md +5 -7
- package/components/ste-loading/ATTRIBUTES.md +3 -1
- package/components/ste-loading/README.md +6 -8
- package/components/ste-login/ATTRIBUTES.md +12 -2
- package/components/ste-login/README.md +7 -15
- package/components/ste-login/ste-login.easycom.json +4 -7
- package/components/ste-login-info/ATTRIBUTES.md +6 -2
- package/components/ste-login-info/README.md +2 -4
- package/components/ste-login-info/ste-login-info.easycom.json +1 -4
- package/components/ste-marquee/ATTRIBUTES.md +44 -0
- package/components/ste-marquee/README.md +123 -0
- package/components/ste-marquee/config.json +5 -0
- package/components/ste-marquee/props.ts +106 -0
- package/components/ste-marquee/ste-marquee.easycom.json +132 -0
- package/components/ste-marquee/ste-marquee.vue +249 -0
- package/components/ste-media-preview/ATTRIBUTES.md +14 -4
- package/components/ste-media-preview/README.md +23 -32
- package/components/ste-media-preview/ste-media-preview.easycom.json +16 -4
- package/components/ste-message-box/ATTRIBUTES.md +3 -1
- package/components/ste-message-box/README.md +11 -13
- package/components/ste-navbar/ATTRIBUTES.md +13 -3
- package/components/ste-navbar/README.md +5 -13
- package/components/ste-navbar/ste-navbar.easycom.json +10 -1
- package/components/ste-notice-bar/ATTRIBUTES.md +16 -5
- package/components/ste-notice-bar/README.md +11 -20
- package/components/ste-notice-bar/ste-notice-bar.easycom.json +26 -3
- package/components/ste-number-keyboard/ATTRIBUTES.md +17 -7
- package/components/ste-number-keyboard/README.md +9 -18
- package/components/ste-number-keyboard/ste-number-keyboard.easycom.json +32 -9
- package/components/ste-order-card/ATTRIBUTES.md +6 -2
- package/components/ste-order-card/README.md +4 -6
- package/components/ste-order-card/ste-order-card.easycom.json +1 -4
- package/components/ste-pie-chart/ATTRIBUTES.md +3 -1
- package/components/ste-pie-chart/README.md +4 -6
- package/components/ste-popup/ATTRIBUTES.md +15 -5
- package/components/ste-popup/README.md +10 -18
- package/components/ste-popup/ste-popup.easycom.json +22 -4
- package/components/ste-price/ATTRIBUTES.md +7 -3
- package/components/ste-price/README.md +10 -12
- package/components/ste-price/ste-price.easycom.json +7 -2
- package/components/ste-progress/ATTRIBUTES.md +9 -1
- package/components/ste-progress/README.md +9 -17
- package/components/ste-progress/ste-progress.easycom.json +4 -0
- package/components/ste-qrcode/ATTRIBUTES.md +6 -2
- package/components/ste-qrcode/README.md +4 -6
- package/components/ste-qrcode/ste-qrcode.easycom.json +1 -2
- package/components/ste-radio/ATTRIBUTES.md +6 -2
- package/components/ste-radio/README.md +17 -19
- package/components/ste-radio/ste-radio.easycom.json +1 -3
- package/components/ste-radio/ste-radio.vue +109 -85
- package/components/ste-rate/ATTRIBUTES.md +7 -3
- package/components/ste-rate/README.md +8 -10
- package/components/ste-rate/ste-rate.easycom.json +7 -2
- package/components/ste-read-more/ATTRIBUTES.md +20 -4
- package/components/ste-read-more/README.md +5 -19
- package/components/ste-read-more/ste-read-more.easycom.json +20 -2
- package/components/ste-rich-text/ATTRIBUTES.md +3 -1
- package/components/ste-rich-text/README.md +2 -4
- package/components/ste-ring-chart/ATTRIBUTES.md +3 -1
- package/components/ste-ring-chart/README.md +22 -5
- package/components/ste-ring-chart/ste-ring-chart.vue +40 -1
- package/components/ste-scroll-to/ATTRIBUTES.md +7 -3
- package/components/ste-scroll-to/README.md +2 -4
- package/components/ste-scroll-to/ste-scroll-to.easycom.json +7 -2
- package/components/ste-search/ATTRIBUTES.md +14 -3
- package/components/ste-search/README.md +12 -21
- package/components/ste-search/ste-search.easycom.json +14 -7
- package/components/ste-search-box/ATTRIBUTES.md +6 -2
- package/components/ste-search-box/README.md +3 -5
- package/components/ste-search-box/ste-search-box.easycom.json +1 -3
- package/components/ste-select/ATTRIBUTES.md +9 -5
- package/components/ste-select/README.md +11 -11
- package/components/ste-select/ste-select.easycom.json +19 -6
- package/components/ste-select-seat/ATTRIBUTES.md +8 -4
- package/components/ste-select-seat/README.md +7 -21
- package/components/ste-select-seat/ste-select-seat.easycom.json +13 -3
- package/components/ste-signature/ATTRIBUTES.md +18 -5
- package/components/ste-signature/README.md +3 -14
- package/components/ste-signature/ste-signature.easycom.json +50 -3
- package/components/ste-simple-calendar/ATTRIBUTES.md +16 -4
- package/components/ste-simple-calendar/README.md +8 -18
- package/components/ste-simple-calendar/ste-simple-calendar.easycom.json +30 -2
- package/components/ste-skeleton/ATTRIBUTES.md +9 -1
- package/components/ste-skeleton/README.md +5 -13
- package/components/ste-skeleton/ste-skeleton.easycom.json +4 -0
- package/components/ste-slide-verify/ATTRIBUTES.md +16 -5
- package/components/ste-slide-verify/README.md +7 -16
- package/components/ste-slide-verify/ste-slide-verify.easycom.json +26 -3
- package/components/ste-slider/ATTRIBUTES.md +14 -2
- package/components/ste-slider/README.md +12 -21
- package/components/ste-slider/ste-slider.easycom.json +12 -4
- package/components/ste-slider/ste-slider.vue +5 -3
- package/components/ste-stepper/ATTRIBUTES.md +9 -5
- package/components/ste-stepper/README.md +9 -13
- package/components/ste-stepper/ste-stepper.easycom.json +19 -6
- package/components/ste-steps/ATTRIBUTES.md +6 -2
- package/components/ste-steps/README.md +9 -11
- package/components/ste-steps/ste-steps.easycom.json +1 -2
- package/components/ste-sticky/ATTRIBUTES.md +8 -4
- package/components/ste-sticky/README.md +2 -4
- package/components/ste-sticky/ste-sticky.easycom.json +13 -3
- package/components/ste-swipe-action/ATTRIBUTES.md +14 -3
- package/components/ste-swipe-action/README.md +9 -18
- package/components/ste-swipe-action/ste-swipe-action.easycom.json +20 -2
- package/components/ste-swipe-action/useData.ts +15 -8
- package/components/ste-swipe-action-group/ATTRIBUTES.md +6 -2
- package/components/ste-swipe-action-group/ste-swipe-action-group.easycom.json +1 -3
- package/components/ste-swiper/ATTRIBUTES.md +6 -2
- package/components/ste-swiper/README.md +12 -14
- package/components/ste-swiper/ste-swiper.easycom.json +1 -3
- package/components/ste-switch/ATTRIBUTES.md +8 -4
- package/components/ste-switch/README.md +7 -9
- package/components/ste-switch/ste-switch.easycom.json +13 -3
- package/components/ste-tab/ATTRIBUTES.md +3 -1
- package/components/ste-table/ATTRIBUTES.md +12 -8
- package/components/ste-table/README.md +23 -23
- package/components/ste-table/ste-table.easycom.json +38 -9
- package/components/ste-tabs/ATTRIBUTES.md +9 -4
- package/components/ste-tabs/README.md +4 -6
- package/components/ste-tabs/props.ts +3 -0
- package/components/ste-tabs/ste-tabs.easycom.json +18 -2
- package/components/ste-tabs/useData.ts +1 -1
- package/components/ste-text/ATTRIBUTES.md +9 -1
- package/components/ste-text/README.md +4 -12
- package/components/ste-text/ste-text.easycom.json +4 -0
- package/components/ste-toast/ATTRIBUTES.md +10 -1
- package/components/ste-toast/README.md +9 -18
- package/components/ste-toast/ste-toast.easycom.json +14 -0
- package/components/ste-touch-swipe/ATTRIBUTES.md +6 -2
- package/components/ste-touch-swipe/README.md +4 -6
- package/components/ste-touch-swipe/ste-touch-swipe.easycom.json +1 -2
- package/components/ste-tour/ATTRIBUTES.md +7 -3
- package/components/ste-tour/README.md +5 -7
- package/components/ste-tour/ste-tour.easycom.json +11 -4
- package/components/ste-tree/ATTRIBUTES.md +15 -2
- package/components/ste-tree/README.md +6 -17
- package/components/ste-tree/ste-tree.easycom.json +16 -4
- package/components/ste-upload/ATTRIBUTES.md +17 -5
- package/components/ste-upload/README.md +9 -20
- package/components/ste-upload/ste-upload.easycom.json +36 -9
- package/components/ste-user-info/ATTRIBUTES.md +15 -5
- package/components/ste-user-info/README.md +5 -13
- package/components/ste-user-info/ste-user-info.easycom.json +22 -4
- package/components/ste-video/ATTRIBUTES.md +3 -1
- package/components/ste-video/README.md +4 -8
- package/components/ste-watermark/ATTRIBUTES.md +3 -1
- package/components/ste-watermark/README.md +5 -7
- package/config/font-size.ts +3 -0
- package/config/index.ts +5 -0
- package/index.ts +4 -0
- package/package.json +1 -1
- package/types/components.d.ts +4 -0
- package/types/refComponents.d.ts +4 -0
- package/utils/System.ts +50 -15
- package/utils/mixin.ts +4 -3
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ste-marquee",
|
|
3
|
+
"description": "走马灯组件,用于水平滚动展示公告、中奖名单等信息",
|
|
4
|
+
"example": "<ste-marquee :list=\"list\"></ste-marquee>",
|
|
5
|
+
"tutorial": "https://stellar-ui.intecloud.com.cn/?projectName=stellar-ui-plus&menu=%E7%BB%84%E4%BB%B6&active=ste-marquee",
|
|
6
|
+
"attributes": [
|
|
7
|
+
{
|
|
8
|
+
"name": "list",
|
|
9
|
+
"description": "数据列表",
|
|
10
|
+
"type": "MarqueeItem[]",
|
|
11
|
+
"default": "[]"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "speed",
|
|
15
|
+
"description": "滚动速度(px/s)",
|
|
16
|
+
"type": "number",
|
|
17
|
+
"default": 50
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "pauseOnHover",
|
|
21
|
+
"description": "悬停时是否暂停",
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"default": true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "loop",
|
|
27
|
+
"description": "是否循环播放",
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"default": true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "gap",
|
|
33
|
+
"description": "消息之间的间距(rpx)",
|
|
34
|
+
"type": "number",
|
|
35
|
+
"default": 20
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "height",
|
|
39
|
+
"description": "容器高度",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"default": "auto"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "fillScreen",
|
|
45
|
+
"description": "是否填满屏幕宽度",
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"default": false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "clickable",
|
|
51
|
+
"description": "是否可点击",
|
|
52
|
+
"type": "boolean",
|
|
53
|
+
"default": true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "containerBg",
|
|
57
|
+
"description": "容器背景色",
|
|
58
|
+
"type": "string",
|
|
59
|
+
"default": "transparent"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "containerPadding",
|
|
63
|
+
"description": "容器内边距",
|
|
64
|
+
"type": "string",
|
|
65
|
+
"default": "0rpx"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "containerRadius",
|
|
69
|
+
"description": "容器圆角",
|
|
70
|
+
"type": "string",
|
|
71
|
+
"default": "0rpx"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "itemBg",
|
|
75
|
+
"description": "消息项背景色",
|
|
76
|
+
"type": "string",
|
|
77
|
+
"default": "transparent"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "itemPadding",
|
|
81
|
+
"description": "消息项内边距",
|
|
82
|
+
"type": "string",
|
|
83
|
+
"default": "0rpx 20rpx"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "itemRadius",
|
|
87
|
+
"description": "消息项圆角",
|
|
88
|
+
"type": "string",
|
|
89
|
+
"default": "0rpx"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "[event]click",
|
|
93
|
+
"description": "点击消息时触发",
|
|
94
|
+
"params": [
|
|
95
|
+
{ "name": "item", "description": "点击的数据项" },
|
|
96
|
+
{ "name": "index", "description": "数据项索引" }
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "[event]complete",
|
|
101
|
+
"description": "一轮播放完成时触发"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "[method]play",
|
|
105
|
+
"description": "开始播放"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "[method]pause",
|
|
109
|
+
"description": "暂停播放"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "[method]resume",
|
|
113
|
+
"description": "恢复播放"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"name": "[method]stop",
|
|
117
|
+
"description": "停止播放并回到初始位置"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "[slot]default",
|
|
121
|
+
"description": "默认插槽,自定义整个内容区域"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "[slot]item",
|
|
125
|
+
"description": "自定义单项内容",
|
|
126
|
+
"params": [
|
|
127
|
+
{ "name": "item", "description": "数据项对象" },
|
|
128
|
+
{ "name": "index", "description": "数据项索引" }
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed, onMounted, watch, nextTick, getCurrentInstance } from 'vue';
|
|
3
|
+
import propsData, { type MarqueeItem } from './props';
|
|
4
|
+
|
|
5
|
+
const props = defineProps(propsData);
|
|
6
|
+
const instance = getCurrentInstance();
|
|
7
|
+
const emits = defineEmits<{
|
|
8
|
+
(e: 'click', item: MarqueeItem, index: number): void;
|
|
9
|
+
}>();
|
|
10
|
+
|
|
11
|
+
// ─── 状态 ──────────────────────────────────────────────────────
|
|
12
|
+
const displayQueue = ref<(MarqueeItem & { _key: string })[]>([]);
|
|
13
|
+
const contentWidth = ref(0);
|
|
14
|
+
const isReady = ref(false);
|
|
15
|
+
let copyCount = 2;
|
|
16
|
+
let keySeed = 0;
|
|
17
|
+
|
|
18
|
+
// ─── 样式 ──────────────────────────────────────────────────────
|
|
19
|
+
const containerStyle = computed(() => ({
|
|
20
|
+
height: props.height === 'auto' ? undefined : props.height,
|
|
21
|
+
background: props.containerBg,
|
|
22
|
+
padding: props.containerPadding,
|
|
23
|
+
borderRadius: props.containerRadius,
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
// 使用 CSS 变量控制动画
|
|
27
|
+
const cssVariables = computed(() => {
|
|
28
|
+
if (!isReady.value || contentWidth.value <= 0) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
const duration = contentWidth.value / props.speed;
|
|
32
|
+
return {
|
|
33
|
+
'--marquee-duration': `${duration}s`,
|
|
34
|
+
'--marquee-width': `${contentWidth.value}px`,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const animationClass = computed(() => {
|
|
39
|
+
if (!isReady.value || contentWidth.value <= 0) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
return 'is-animating';
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const getItemStyle = (item: MarqueeItem) => ({
|
|
46
|
+
color: item.color || '',
|
|
47
|
+
background: item.background || props.itemBg,
|
|
48
|
+
padding: props.itemPadding,
|
|
49
|
+
borderRadius: props.itemRadius,
|
|
50
|
+
marginRight: `${props.gap}rpx`,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// ─── 测量 ──────────────────────────────────────────────────────
|
|
54
|
+
const queryWidth = (selector: string): Promise<number> =>
|
|
55
|
+
new Promise(resolve => {
|
|
56
|
+
uni.createSelectorQuery()
|
|
57
|
+
.in(instance)
|
|
58
|
+
.select(selector)
|
|
59
|
+
.boundingClientRect((rect: any) => resolve(rect ? rect.width : 0))
|
|
60
|
+
.exec();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ─── 构建队列 ──────────────────────────────────────────────────
|
|
64
|
+
const mkKey = (id: string | number, copy: number, seed: number) => `${id}_c${copy}_s${seed}`;
|
|
65
|
+
|
|
66
|
+
const buildQueue = async (sourceList: MarqueeItem[]) => {
|
|
67
|
+
if (!sourceList.length) {
|
|
68
|
+
displayQueue.value = [];
|
|
69
|
+
isReady.value = false;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
isReady.value = false;
|
|
74
|
+
const currentSeed = keySeed++;
|
|
75
|
+
|
|
76
|
+
// 先渲染单份测量
|
|
77
|
+
displayQueue.value = sourceList.map(it => ({ ...it, _key: mkKey(it.id, 0, currentSeed) }));
|
|
78
|
+
|
|
79
|
+
await nextTick();
|
|
80
|
+
await new Promise(r => setTimeout(r, 50));
|
|
81
|
+
|
|
82
|
+
const containerWidth = await queryWidth('.ste-marquee');
|
|
83
|
+
const singleWidth = await queryWidth('.ste-mq-content');
|
|
84
|
+
|
|
85
|
+
if (singleWidth <= 0) {
|
|
86
|
+
await new Promise(r => setTimeout(r, 100));
|
|
87
|
+
const retryWidth = await queryWidth('.ste-mq-content');
|
|
88
|
+
if (retryWidth <= 0) {
|
|
89
|
+
contentWidth.value = 0;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
contentWidth.value = retryWidth;
|
|
93
|
+
} else {
|
|
94
|
+
contentWidth.value = singleWidth;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 计算份数(防止除零)
|
|
98
|
+
if (contentWidth.value <= 0) {
|
|
99
|
+
copyCount = 2;
|
|
100
|
+
} else if (contentWidth.value >= containerWidth) {
|
|
101
|
+
copyCount = 2;
|
|
102
|
+
} else {
|
|
103
|
+
copyCount = Math.max(3, Math.ceil((containerWidth * 3) / contentWidth.value) + 1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 构建多份
|
|
107
|
+
const filled: (MarqueeItem & { _key: string })[] = [];
|
|
108
|
+
for (let c = 0; c < copyCount; c++) {
|
|
109
|
+
sourceList.forEach(it => filled.push({ ...it, _key: mkKey(it.id, c, currentSeed) }));
|
|
110
|
+
}
|
|
111
|
+
displayQueue.value = filled;
|
|
112
|
+
|
|
113
|
+
await nextTick();
|
|
114
|
+
isReady.value = true;
|
|
115
|
+
|
|
116
|
+
console.log('[ste-marquee] built queue, contentWidth:', contentWidth.value, 'copies:', copyCount);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// ─── 初始化 ────────────────────────────────────────────────────
|
|
120
|
+
const init = async (list: MarqueeItem[], { keepPaused = false } = {}) => {
|
|
121
|
+
if (!keepPaused) {
|
|
122
|
+
isPaused.value = false;
|
|
123
|
+
}
|
|
124
|
+
await buildQueue(list);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// ─── 控制 ──────────────────────────────────────────────────────
|
|
128
|
+
const isPaused = ref(false);
|
|
129
|
+
|
|
130
|
+
const play = () => {
|
|
131
|
+
isPaused.value = false;
|
|
132
|
+
};
|
|
133
|
+
const pause = () => {
|
|
134
|
+
isPaused.value = true;
|
|
135
|
+
};
|
|
136
|
+
const resume = () => {
|
|
137
|
+
isPaused.value = false;
|
|
138
|
+
};
|
|
139
|
+
const stop = async () => {
|
|
140
|
+
isPaused.value = true;
|
|
141
|
+
// 重新初始化回到起始位置,保持暂停状态
|
|
142
|
+
await init(props.list, { keepPaused: true });
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// ─── 监听 ──────────────────────────────────────────────────────
|
|
146
|
+
let isInitialized = false;
|
|
147
|
+
watch(
|
|
148
|
+
() => props.list,
|
|
149
|
+
newList => {
|
|
150
|
+
if (!isInitialized) return;
|
|
151
|
+
init(newList);
|
|
152
|
+
},
|
|
153
|
+
{ deep: true }
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// ─── 生命周期 ──────────────────────────────────────────────────
|
|
157
|
+
onMounted(() => {
|
|
158
|
+
setTimeout(async () => {
|
|
159
|
+
await init(props.list);
|
|
160
|
+
isInitialized = true;
|
|
161
|
+
}, 100);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// ─── 交互 ──────────────────────────────────────────────────────
|
|
165
|
+
const handleClick = (item: MarqueeItem, index: number) => {
|
|
166
|
+
if (!props.clickable) return;
|
|
167
|
+
emits('click', item, index);
|
|
168
|
+
};
|
|
169
|
+
const handleMouseEnter = () => {
|
|
170
|
+
if (props.pauseOnHover) pause();
|
|
171
|
+
};
|
|
172
|
+
const handleMouseLeave = () => {
|
|
173
|
+
if (props.pauseOnHover) resume();
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
defineExpose({ play, pause, resume, stop });
|
|
177
|
+
</script>
|
|
178
|
+
|
|
179
|
+
<template>
|
|
180
|
+
<view class="ste-marquee" :style="[containerStyle, cssVariables]" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave" @touchstart="handleMouseEnter" @touchend="handleMouseLeave">
|
|
181
|
+
<view class="ste-mq-wrapper" :class="{ 'is-paused': isPaused }">
|
|
182
|
+
<view class="ste-mq-content" :class="animationClass">
|
|
183
|
+
<view v-for="(item, index) in displayQueue" :key="item._key" class="ste-mq-item" :style="getItemStyle(item)" @click="handleClick(item, index)">
|
|
184
|
+
<slot name="item" :item="item" :index="index">
|
|
185
|
+
<image v-if="item.icon" class="ste-mq-icon" :src="item.icon" mode="aspectFit" />
|
|
186
|
+
<text class="ste-mq-text">{{ item.text }}</text>
|
|
187
|
+
</slot>
|
|
188
|
+
</view>
|
|
189
|
+
</view>
|
|
190
|
+
</view>
|
|
191
|
+
</view>
|
|
192
|
+
</template>
|
|
193
|
+
|
|
194
|
+
<style lang="scss" scoped>
|
|
195
|
+
.ste-marquee {
|
|
196
|
+
width: 100%;
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
position: relative;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.ste-mq-wrapper {
|
|
202
|
+
display: flex;
|
|
203
|
+
flex-direction: row;
|
|
204
|
+
align-items: center;
|
|
205
|
+
white-space: nowrap;
|
|
206
|
+
|
|
207
|
+
&.is-paused .ste-mq-content {
|
|
208
|
+
animation-play-state: paused !important;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.ste-mq-content {
|
|
213
|
+
display: flex;
|
|
214
|
+
flex-shrink: 0;
|
|
215
|
+
will-change: transform;
|
|
216
|
+
|
|
217
|
+
&.is-animating {
|
|
218
|
+
animation: marquee-scroll var(--marquee-duration, 10s) linear infinite;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@keyframes marquee-scroll {
|
|
223
|
+
0% {
|
|
224
|
+
transform: translateX(0);
|
|
225
|
+
}
|
|
226
|
+
100% {
|
|
227
|
+
transform: translateX(calc(var(--marquee-width, 0px) * -1));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.ste-mq-item {
|
|
232
|
+
display: inline-flex;
|
|
233
|
+
align-items: center;
|
|
234
|
+
flex-shrink: 0;
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.ste-mq-icon {
|
|
239
|
+
width: 40rpx;
|
|
240
|
+
height: 40rpx;
|
|
241
|
+
margin-right: 10rpx;
|
|
242
|
+
border-radius: 50%;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.ste-mq-text {
|
|
246
|
+
font-size: 28rpx;
|
|
247
|
+
line-height: 1.5;
|
|
248
|
+
}
|
|
249
|
+
</style>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
## API
|
|
2
|
+
|
|
3
|
+
### Props
|
|
2
4
|
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
3
5
|
| ----- | ----- | --- | ------- | ------ | -------- |
|
|
4
6
|
| `show` | 是否显示 | `boolean` | `false` | - | - |
|
|
@@ -12,10 +14,18 @@
|
|
|
12
14
|
| `zIndex` | 弹出层级 | `number` | `997` | - | - |
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
### Events
|
|
16
18
|
| 事件名 | 说明 | 事件参数 | 支持版本 |
|
|
17
19
|
| ----- | ----- | ------- | -------- |
|
|
18
|
-
| `beforeClose` | 关闭前触发 |
|
|
19
|
-
| `close` | 关闭后触发 |
|
|
20
|
+
| `beforeClose` | 关闭前触发 | `data`:() => void | - |
|
|
21
|
+
| `close` | 关闭后触发 | `data`:() => void | - |
|
|
20
22
|
| `change` | 切换时触发 | `index`:切换后的下标 | - |
|
|
21
23
|
| `longpress` | 长按时触发 | `index`:当前下标 | - |
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Slots
|
|
27
|
+
| 插槽名 | 说明 | 参数 | 支持版本 |
|
|
28
|
+
| ----- | ----- | --- | -------- |
|
|
29
|
+
| `default` | 默认插槽:图片底部居中展示 | - | - |
|
|
30
|
+
|
|
31
|
+
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
---$
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- APP兼容性问题
|
|
8
|
+
- APP对于视频预览只支持单个视频预览
|
|
9
|
+
- 不支持视频图片混合预览
|
|
10
|
+
- APP预览多个媒体时,统一当作图片处理
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
## 代码演示
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## 基础用法
|
|
15
15
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
16
|
+
- `show`属性控制是否展示预览弹窗,支持`sync`双向绑定
|
|
17
|
+
- `urls`属性为要预览的媒体URL数组
|
|
18
18
|
|
|
19
19
|
```html
|
|
20
20
|
<template>
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
</script>
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
## 自动轮播
|
|
39
39
|
|
|
40
|
-
-
|
|
40
|
+
- `autoplay`属性控制自动轮播间隔时间,单位为毫秒,为`0`时不轮播
|
|
41
41
|
|
|
42
42
|
```html
|
|
43
43
|
<template>
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
</script>
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
## 前后衔接循环播放
|
|
63
63
|
|
|
64
|
-
-
|
|
64
|
+
- `loop`属性可开启前后衔接循环播放
|
|
65
65
|
|
|
66
66
|
```html
|
|
67
67
|
<template>
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
</script>
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
## 默认展示下标为2的媒体资源
|
|
88
88
|
|
|
89
|
-
-
|
|
89
|
+
- `index`属性可控制从第几页开始展示
|
|
90
90
|
|
|
91
91
|
```html
|
|
92
92
|
<template>
|
|
@@ -109,9 +109,9 @@
|
|
|
109
109
|
</script>
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
## 隐藏左下角索引标签
|
|
113
113
|
|
|
114
|
-
-
|
|
114
|
+
- `showIndex`属性可控制左下角页签显示
|
|
115
115
|
|
|
116
116
|
```html
|
|
117
117
|
<template>
|
|
@@ -134,9 +134,9 @@
|
|
|
134
134
|
</script>
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
## 双指缩放
|
|
138
138
|
|
|
139
|
-
-
|
|
139
|
+
- `scale`属性可开启双指缩放功能
|
|
140
140
|
|
|
141
141
|
```html
|
|
142
142
|
<template>
|
|
@@ -159,9 +159,9 @@
|
|
|
159
159
|
</script>
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
## 长按触发事件
|
|
163
163
|
|
|
164
|
-
-
|
|
164
|
+
- 事件`longpress`在用户长按时触发
|
|
165
165
|
|
|
166
166
|
```html
|
|
167
167
|
<template>
|
|
@@ -190,10 +190,10 @@
|
|
|
190
190
|
</script>
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
## 关闭前/后事件
|
|
194
194
|
|
|
195
|
-
-
|
|
196
|
-
-
|
|
195
|
+
- 事件`beforeClose`在关闭前被触发
|
|
196
|
+
- 事件`close`在关闭后被触发
|
|
197
197
|
|
|
198
198
|
```html
|
|
199
199
|
<template>
|
|
@@ -244,16 +244,7 @@
|
|
|
244
244
|
|
|
245
245
|
---$
|
|
246
246
|
|
|
247
|
-
### API
|
|
248
|
-
|
|
249
247
|
<!-- props -->
|
|
250
248
|
|
|
251
|
-
#### 组件插槽(Slots)
|
|
252
|
-
|
|
253
|
-
| 插槽名 | 说明 | 插槽参数 | 支持版本 |
|
|
254
|
-
| ------- | ------------ | -------- | -------- |
|
|
255
|
-
| default | 默认插槽:图片底部居中展示 | - | - |
|
|
256
|
-
|
|
257
|
-
|
|
258
249
|
---$
|
|
259
250
|
{{xuyajun}}
|
|
@@ -61,17 +61,26 @@
|
|
|
61
61
|
{
|
|
62
62
|
"name": "[event]beforeClose",
|
|
63
63
|
"description": "关闭前触发",
|
|
64
|
-
"
|
|
64
|
+
"params": [
|
|
65
|
+
{
|
|
66
|
+
"name": "data",
|
|
67
|
+
"description": "() => void"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
65
70
|
},
|
|
66
71
|
{
|
|
67
72
|
"name": "[event]close",
|
|
68
73
|
"description": "关闭后触发",
|
|
69
|
-
"
|
|
74
|
+
"params": [
|
|
75
|
+
{
|
|
76
|
+
"name": "data",
|
|
77
|
+
"description": "() => void"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
70
80
|
},
|
|
71
81
|
{
|
|
72
82
|
"name": "[event]change",
|
|
73
83
|
"description": "切换时触发",
|
|
74
|
-
"type": "(index: number) => void",
|
|
75
84
|
"params": [
|
|
76
85
|
{
|
|
77
86
|
"name": "index",
|
|
@@ -82,13 +91,16 @@
|
|
|
82
91
|
{
|
|
83
92
|
"name": "[event]longpress",
|
|
84
93
|
"description": "长按时触发",
|
|
85
|
-
"type": "(index: number) => void",
|
|
86
94
|
"params": [
|
|
87
95
|
{
|
|
88
96
|
"name": "index",
|
|
89
97
|
"description": "当前下标"
|
|
90
98
|
}
|
|
91
99
|
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "[slot]default",
|
|
103
|
+
"description": "默认插槽:图片底部居中展示"
|
|
92
104
|
}
|
|
93
105
|
]
|
|
94
106
|
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
---$
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 使用方法
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## 组合函数使用方法
|
|
10
10
|
|
|
11
11
|
ps:注意 目前 useMessageBox 只能在 setup 作用域下使用
|
|
12
12
|
父组件引入组件 组合函数调用showMsgBox方法,打开轻提示
|
|
@@ -25,7 +25,7 @@ ps:注意 目前 useMessageBox 只能在 setup 作用域下使用
|
|
|
25
25
|
</template>
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## Ref用法
|
|
29
29
|
|
|
30
30
|
父组件引入组件 绑定ref 通过ref调用showMsgBox方法,打开轻提示
|
|
31
31
|
|
|
@@ -46,7 +46,7 @@ ps:注意 目前 useMessageBox 只能在 setup 作用域下使用
|
|
|
46
46
|
</template>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
## 全局引入
|
|
50
50
|
|
|
51
51
|
配合 [https://github.com/smartXJ/vue3-inset-loader](https://github.com/smartXJ/vue3-inset-loader) 插件, 将 ste-message-box 节点置于每个页面中,可以更进一步简化使用
|
|
52
52
|
|
|
@@ -61,9 +61,9 @@ insetLoader: {
|
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
## 代码演示
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
## 基础使用
|
|
67
67
|
|
|
68
68
|
可在标题(`title`)和内容(`content`)中使用`\n`来实现换行
|
|
69
69
|
|
|
@@ -83,7 +83,7 @@ insetLoader: {
|
|
|
83
83
|
</script>
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
## 带图标
|
|
87
87
|
|
|
88
88
|
- 内置三种图标类型:`info`、`success`、`error`
|
|
89
89
|
- 当显示图标时,内容(`content`)会失效,只显示标题(`title`)
|
|
@@ -119,7 +119,7 @@ insetLoader: {
|
|
|
119
119
|
</script>
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
## 自定义按钮
|
|
123
123
|
|
|
124
124
|
```html
|
|
125
125
|
<template>
|
|
@@ -163,7 +163,7 @@ insetLoader: {
|
|
|
163
163
|
</script>
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
## 显示输入框
|
|
167
167
|
|
|
168
168
|
当显示输入框时,内容(`content`)将不显示
|
|
169
169
|
|
|
@@ -188,7 +188,7 @@ insetLoader: {
|
|
|
188
188
|
</script>
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
## 插槽
|
|
192
192
|
|
|
193
193
|
如果提供的弹框内容不满足需求,可以使用插槽自定义弹框内容。
|
|
194
194
|
可以通过指定唯一标识`selector`的方式,在一个页面中使用多个`ste-message-box`,`useSteMsgBox(selector)`会返回一个指定了selector的组件实例。
|
|
@@ -216,7 +216,7 @@ insetLoader: {
|
|
|
216
216
|
</script>
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
## 回调事件
|
|
220
220
|
|
|
221
221
|
```html
|
|
222
222
|
<template>
|
|
@@ -263,8 +263,6 @@ insetLoader: {
|
|
|
263
263
|
|
|
264
264
|
---$
|
|
265
265
|
|
|
266
|
-
### API
|
|
267
|
-
|
|
268
266
|
<!-- props -->
|
|
269
267
|
|
|
270
268
|
---$
|