hy-app 0.2.13 → 0.2.15
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/hy-action-sheet/hy-action-sheet.vue +81 -13
- package/components/hy-action-sheet/typing.d.ts +1 -3
- package/components/hy-address-picker/hy-address-picker.vue +109 -8
- package/components/hy-address-picker/index.scss +2 -2
- package/components/hy-address-picker/typing.d.ts +39 -30
- package/components/hy-avatar/hy-avatar.vue +78 -4
- package/components/hy-avatar/typing.d.ts +21 -16
- package/components/hy-back-top/hy-back-top.vue +86 -28
- package/components/hy-back-top/typing.d.ts +17 -12
- package/components/hy-badge/hy-badge.vue +114 -43
- package/components/hy-badge/typing.d.ts +20 -15
- package/components/hy-button/HyButton.docgen.js +6 -0
- package/components/hy-button/hy-button.vue +70 -77
- package/components/hy-button/props.ts +40 -41
- package/components/hy-calendar/hy-calendar.vue +290 -143
- package/components/hy-calendar/typing.d.ts +38 -31
- package/components/hy-card/hy-card.vue +139 -36
- package/components/hy-card/typing.d.ts +39 -28
- package/components/hy-cell/hy-cell.vue +131 -67
- package/components/hy-cell/typing.d.ts +6 -1
- package/components/hy-check-button/hy-check-button.vue +101 -32
- package/components/hy-check-button/typing.d.ts +26 -19
- package/components/hy-checkbox/hy-checkbox.vue +167 -78
- package/components/hy-checkbox/typing.d.ts +26 -19
- package/components/hy-code-input/hy-code-input.vue +101 -5
- package/components/hy-code-input/typing.d.ts +9 -0
- package/components/hy-config-provider/hy-config-provider.vue +44 -24
- package/components/hy-config-provider/typing.d.ts +0 -4
- package/components/hy-count-down/hy-count-down.vue +99 -62
- package/components/hy-count-down/typing.d.ts +18 -5
- package/components/hy-count-to/hy-count-to.vue +165 -113
- package/components/hy-count-to/typing.d.ts +15 -11
- package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
- package/components/hy-datetime-picker/typing.d.ts +49 -39
- package/components/hy-divider/hy-divider.vue +128 -64
- package/components/hy-divider/typing.d.ts +16 -16
- package/components/hy-dropdown/hy-dropdown.vue +57 -19
- package/components/hy-dropdown/typing.d.ts +14 -14
- package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
- package/components/hy-dropdown-item/typing.d.ts +13 -6
- package/components/hy-empty/hy-empty.vue +64 -6
- package/components/hy-empty/typing.d.ts +5 -0
- package/components/hy-float-button/hy-float-button.vue +117 -5
- package/components/hy-float-button/typing.d.ts +7 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
- package/components/hy-folding-panel/typing.d.ts +24 -15
- package/components/hy-grid/hy-grid.vue +95 -35
- package/components/hy-grid/typing.d.ts +24 -19
- package/components/hy-icon/hy-icon.vue +84 -6
- package/components/hy-icon/typing.d.ts +5 -0
- package/components/hy-image/hy-image.vue +105 -6
- package/components/hy-image/typing.d.ts +9 -0
- package/components/hy-input/hy-input.vue +277 -130
- package/components/hy-input/props.ts +13 -14
- package/components/hy-input/typing.d.ts +59 -38
- package/components/hy-line/hy-line.vue +65 -25
- package/components/hy-line-progress/hy-line-progress.vue +68 -35
- package/components/hy-list/hy-list.vue +127 -61
- package/components/hy-list/typing.d.ts +19 -12
- package/components/hy-loading/hy-loading.vue +79 -25
- package/components/hy-menu/hy-menu.vue +69 -45
- package/components/hy-menu/typing.d.ts +22 -15
- package/components/hy-modal/hy-modal.vue +91 -4
- package/components/hy-modal/typing.d.ts +11 -0
- package/components/hy-navbar/hy-navbar.vue +105 -25
- package/components/hy-navbar/typing.d.ts +25 -20
- package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
- package/components/hy-notice-bar/typing.d.ts +22 -17
- package/components/hy-notify/hy-notify.vue +106 -54
- package/components/hy-number-step/hy-number-step.vue +211 -120
- package/components/hy-number-step/typing.d.ts +45 -28
- package/components/hy-overlay/hy-overlay.vue +60 -16
- package/components/hy-overlay/typing.d.ts +11 -6
- package/components/hy-pagination/hy-pagination.vue +94 -37
- package/components/hy-pagination/typing.d.ts +20 -11
- package/components/hy-picker/hy-picker.vue +225 -160
- package/components/hy-picker/typing.d.ts +51 -28
- package/components/hy-popover/hy-popover.vue +55 -7
- package/components/hy-popover/typing.d.ts +21 -1
- package/components/hy-popup/hy-popup.vue +164 -99
- package/components/hy-popup/typing.d.ts +11 -0
- package/components/hy-price/hy-price.vue +77 -30
- package/components/hy-price/typing.d.ts +10 -10
- package/components/hy-qrcode/hy-qrcode.vue +75 -5
- package/components/hy-qrcode/typing.d.ts +25 -16
- package/components/hy-radio/hy-radio.vue +169 -88
- package/components/hy-radio/typing.d.ts +29 -22
- package/components/hy-rate/hy-rate.vue +155 -104
- package/components/hy-rate/typing.d.ts +23 -16
- package/components/hy-read-more/hy-read-more.vue +83 -56
- package/components/hy-read-more/typing.d.ts +18 -11
- package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
- package/components/hy-scroll-list/typing.d.ts +14 -7
- package/components/hy-search/hy-search.vue +168 -62
- package/components/hy-search/typing.d.ts +47 -26
- package/components/hy-signature/hy-signature.vue +354 -272
- package/components/hy-signature/typing.d.ts +65 -52
- package/components/hy-slider/hy-slider.vue +208 -160
- package/components/hy-slider/typing.d.ts +28 -17
- package/components/hy-steps/hy-steps.vue +125 -99
- package/components/hy-steps/typing.d.ts +21 -14
- package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
- package/components/hy-submit-bar/typing.d.ts +30 -23
- package/components/hy-subsection/hy-subsection.vue +139 -96
- package/components/hy-subsection/typing.d.ts +23 -16
- package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
- package/components/hy-swipe-action/typing.d.ts +26 -17
- package/components/hy-swiper/hy-swiper.vue +178 -73
- package/components/hy-swiper/typing.d.ts +37 -28
- package/components/hy-switch/hy-switch.vue +107 -60
- package/components/hy-switch/typing.d.ts +25 -18
- package/components/hy-tabs/hy-tabs.vue +170 -160
- package/components/hy-tabs/typing.d.ts +36 -22
- package/components/hy-tag/hy-tag.vue +133 -58
- package/components/hy-tag/typing.d.ts +26 -18
- package/components/hy-text/hy-text.vue +106 -6
- package/components/hy-text/typing.d.ts +31 -26
- package/components/hy-textarea/hy-textarea.vue +183 -89
- package/components/hy-textarea/typing.d.ts +41 -24
- package/components/hy-tooltip/hy-tooltip.vue +145 -101
- package/components/hy-tooltip/typing.d.ts +18 -13
- package/components/hy-transition/hy-transition.vue +48 -13
- package/components/hy-transition/typing.d.ts +17 -0
- package/components/hy-upload/hy-upload.vue +113 -148
- package/components/hy-upload/typing.d.ts +71 -71
- package/components/hy-warn/hy-warn.vue +79 -36
- package/components/hy-warn/typing.d.ts +18 -11
- package/components/hy-waterfall/hy-waterfall.vue +90 -77
- package/components/hy-watermark/hy-watermark.vue +82 -5
- package/components/hy-watermark/typing.d.ts +20 -20
- package/global.d.ts +39 -59
- package/package.json +5 -13
- package/utils/inspect.ts +3 -1
- package/web-types.json +1 -1
- package/component-helper.ts +0 -177
- package/components.json +0 -3287
- package/dist/attributes.json +0 -1
- package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
- package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
- package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
- package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
- package/dist/docs/components/hy-badge/hy-badge.md +0 -13
- package/dist/docs/components/hy-button/hy-button.md +0 -61
- package/dist/docs/components/hy-calendar/header.md +0 -17
- package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
- package/dist/docs/components/hy-calendar/month.md +0 -38
- package/dist/docs/components/hy-card/hy-card.md +0 -24
- package/dist/docs/components/hy-cell/hy-cell.md +0 -26
- package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
- package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
- package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
- package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
- package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
- package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
- package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
- package/dist/docs/components/hy-divider/hy-divider.md +0 -13
- package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
- package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
- package/dist/docs/components/hy-empty/hy-empty.md +0 -20
- package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
- package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
- package/dist/docs/components/hy-form/hy-form.md +0 -29
- package/dist/docs/components/hy-grid/hy-grid.md +0 -19
- package/dist/docs/components/hy-icon/hy-icon.md +0 -13
- package/dist/docs/components/hy-image/hy-image.md +0 -22
- package/dist/docs/components/hy-input/hy-input.md +0 -29
- package/dist/docs/components/hy-line/hy-line.md +0 -7
- package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
- package/dist/docs/components/hy-list/hy-list.md +0 -25
- package/dist/docs/components/hy-loading/hy-loading.md +0 -14
- package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
- package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
- package/dist/docs/components/hy-login/hy-login.md +0 -14
- package/dist/docs/components/hy-menu/hy-menu.md +0 -21
- package/dist/docs/components/hy-modal/hy-modal.md +0 -23
- package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
- package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
- package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
- package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
- package/dist/docs/components/hy-notify/hy-notify.md +0 -23
- package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
- package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
- package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
- package/dist/docs/components/hy-parse/hy-parse.md +0 -46
- package/dist/docs/components/hy-parse/node/node.md +0 -7
- package/dist/docs/components/hy-picker/hy-picker.md +0 -32
- package/dist/docs/components/hy-popover/hy-popover.md +0 -34
- package/dist/docs/components/hy-popup/hy-popup.md +0 -22
- package/dist/docs/components/hy-price/hy-price.md +0 -13
- package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
- package/dist/docs/components/hy-radio/hy-radio.md +0 -21
- package/dist/docs/components/hy-rate/hy-rate.md +0 -14
- package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
- package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
- package/dist/docs/components/hy-search/hy-search.md +0 -27
- package/dist/docs/components/hy-signature/hy-signature.md +0 -45
- package/dist/docs/components/hy-slider/hy-slider.md +0 -24
- package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
- package/dist/docs/components/hy-steps/hy-steps.md +0 -23
- package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
- package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
- package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
- package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
- package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
- package/dist/docs/components/hy-switch/hy-switch.md +0 -20
- package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
- package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
- package/dist/docs/components/hy-tag/hy-tag.md +0 -21
- package/dist/docs/components/hy-text/hy-text.md +0 -13
- package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
- package/dist/docs/components/hy-toast/hy-toast.md +0 -17
- package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
- package/dist/docs/components/hy-transition/hy-transition.md +0 -25
- package/dist/docs/components/hy-upload/hy-upload.md +0 -25
- package/dist/docs/components/hy-warn/hy-warn.md +0 -14
- package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
- package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
- package/dist/docs/components/message/TheMessage.md +0 -17
- package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
- package/dist/tags.json +0 -1
- package/dist/web-types.json +0 -1
- package/docgen.config.js +0 -14
- package/web-types.config.js +0 -7
|
@@ -9,10 +9,7 @@
|
|
|
9
9
|
class="hy-virtual-container"
|
|
10
10
|
>
|
|
11
11
|
<view class="hy-virtual-container__list">
|
|
12
|
-
<slot
|
|
13
|
-
v-if="slotDefault"
|
|
14
|
-
:record="line === 1 ? virtualData : waterfall"
|
|
15
|
-
></slot>
|
|
12
|
+
<slot v-if="slotDefault" :record="line === 1 ? virtualData : waterfall"></slot>
|
|
16
13
|
<template v-else>
|
|
17
14
|
<view
|
|
18
15
|
v-if="line === 1"
|
|
@@ -39,7 +36,7 @@
|
|
|
39
36
|
>
|
|
40
37
|
<slot name="left" :record="item"></slot>
|
|
41
38
|
</view>
|
|
42
|
-
<slot v-else name="left-list" :record="waterfall.left"
|
|
39
|
+
<slot v-else name="left-list" :record="waterfall.left"></slot>
|
|
43
40
|
</view>
|
|
44
41
|
<view
|
|
45
42
|
v-if="line === 2"
|
|
@@ -55,7 +52,7 @@
|
|
|
55
52
|
>
|
|
56
53
|
<slot name="right" :record="item"></slot>
|
|
57
54
|
</view>
|
|
58
|
-
<slot v-else name="right-list" :record="waterfall.right"
|
|
55
|
+
<slot v-else name="right-list" :record="waterfall.right"></slot>
|
|
59
56
|
</view>
|
|
60
57
|
</template>
|
|
61
58
|
<!--加载更多样式-->
|
|
@@ -65,13 +62,18 @@
|
|
|
65
62
|
</template>
|
|
66
63
|
|
|
67
64
|
<script lang="ts">
|
|
65
|
+
/**
|
|
66
|
+
* 实现只展示可视内容的dom,减少dom创建,优化滚动性能
|
|
67
|
+
* @displayName hy-list
|
|
68
|
+
*/
|
|
69
|
+
defineOptions({})
|
|
68
70
|
export default {
|
|
69
71
|
name: 'hy-list',
|
|
70
72
|
options: {
|
|
71
73
|
addGlobalClass: true,
|
|
72
74
|
virtualHost: true,
|
|
73
|
-
styleIsolation: 'shared'
|
|
74
|
-
}
|
|
75
|
+
styleIsolation: 'shared',
|
|
76
|
+
},
|
|
75
77
|
}
|
|
76
78
|
</script>
|
|
77
79
|
|
|
@@ -87,12 +89,78 @@ import {
|
|
|
87
89
|
toRefs,
|
|
88
90
|
useSlots,
|
|
89
91
|
watch,
|
|
90
|
-
} from
|
|
91
|
-
import { addUnit, getPx, getRect } from
|
|
92
|
-
import type
|
|
93
|
-
import defaultProps from "./props";
|
|
92
|
+
} from 'vue'
|
|
93
|
+
import { addUnit, getPx, getRect } from '../../utils'
|
|
94
|
+
import type { IListEmits } from './typing'
|
|
94
95
|
|
|
95
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
96
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
97
|
+
const props = defineProps({
|
|
98
|
+
/** 数据列表 */
|
|
99
|
+
list: {
|
|
100
|
+
type: Array,
|
|
101
|
+
default() {
|
|
102
|
+
return []
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
/** 容器高度,必须给个高度,否则加载全部数据 */
|
|
106
|
+
containerHeight: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: '100%',
|
|
109
|
+
},
|
|
110
|
+
/** 子容器的高度,必须和内容一致,否则计算有问题 */
|
|
111
|
+
itemHeight: {
|
|
112
|
+
type: [String, Number],
|
|
113
|
+
default: '40px',
|
|
114
|
+
},
|
|
115
|
+
/** 子容器的底部,会计算到容器内 */
|
|
116
|
+
marginBottom: {
|
|
117
|
+
type: [String, Number],
|
|
118
|
+
default: 10,
|
|
119
|
+
},
|
|
120
|
+
/** 子容器的内边距 */
|
|
121
|
+
padding: {
|
|
122
|
+
type: [String, Number],
|
|
123
|
+
default: 10,
|
|
124
|
+
},
|
|
125
|
+
/** 子容器的圆角,单位px */
|
|
126
|
+
borderRadius: {
|
|
127
|
+
type: [String, Number],
|
|
128
|
+
default: '3px',
|
|
129
|
+
},
|
|
130
|
+
/** 容器背景色 */
|
|
131
|
+
background: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: 'transparent',
|
|
134
|
+
},
|
|
135
|
+
/** 是否显示边框 */
|
|
136
|
+
border: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: false,
|
|
139
|
+
},
|
|
140
|
+
/** 展示几列 */
|
|
141
|
+
line: {
|
|
142
|
+
type: Number,
|
|
143
|
+
default: 1,
|
|
144
|
+
},
|
|
145
|
+
/** 每一项的唯一标识key */
|
|
146
|
+
keyField: {
|
|
147
|
+
type: String,
|
|
148
|
+
default: 'id',
|
|
149
|
+
},
|
|
150
|
+
/**
|
|
151
|
+
* 加载状态
|
|
152
|
+
* @values loadMore,loading,noMore
|
|
153
|
+
* */
|
|
154
|
+
load: {
|
|
155
|
+
type: String,
|
|
156
|
+
default: 'loadMore',
|
|
157
|
+
},
|
|
158
|
+
/** 显示底部加载状态 */
|
|
159
|
+
showDivider: {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
default: true,
|
|
162
|
+
},
|
|
163
|
+
})
|
|
96
164
|
const {
|
|
97
165
|
list,
|
|
98
166
|
line,
|
|
@@ -104,33 +172,33 @@ const {
|
|
|
104
172
|
borderRadius,
|
|
105
173
|
background,
|
|
106
174
|
border,
|
|
107
|
-
} = toRefs(props)
|
|
108
|
-
const emit = defineEmits(
|
|
175
|
+
} = toRefs(props)
|
|
176
|
+
const emit = defineEmits<IListEmits>()
|
|
109
177
|
|
|
110
|
-
const slots = useSlots()
|
|
178
|
+
const slots = useSlots()
|
|
111
179
|
// 滚动条距离顶部距离
|
|
112
|
-
const scrollTop = ref(0)
|
|
180
|
+
const scrollTop = ref(0)
|
|
113
181
|
// 可视区域的高度
|
|
114
|
-
const viewHeight = ref(0)
|
|
182
|
+
const viewHeight = ref(0)
|
|
115
183
|
const waterfall: {
|
|
116
|
-
left: AnyObject[]
|
|
117
|
-
right: AnyObject[]
|
|
184
|
+
left: AnyObject[]
|
|
185
|
+
right: AnyObject[]
|
|
118
186
|
} = reactive({
|
|
119
187
|
left: [],
|
|
120
188
|
right: [],
|
|
121
|
-
})
|
|
189
|
+
})
|
|
122
190
|
// 排列方式
|
|
123
|
-
const arrange = computed(() => (line.value === 1 ?
|
|
124
|
-
const boxHeight = getPx(itemHeight.value) + getPx(marginBottom.value)
|
|
125
|
-
const listHeight = addUnit(containerHeight.value)
|
|
126
|
-
const instance = getCurrentInstance()
|
|
191
|
+
const arrange = computed(() => (line.value === 1 ? 'column' : 'row'))
|
|
192
|
+
const boxHeight = getPx(itemHeight.value) + getPx(marginBottom.value)
|
|
193
|
+
const listHeight = addUnit(containerHeight.value)
|
|
194
|
+
const instance = getCurrentInstance()
|
|
127
195
|
|
|
128
196
|
onMounted(() => {
|
|
129
197
|
nextTick(async () => {
|
|
130
|
-
const res = await getRect(
|
|
131
|
-
viewHeight.value = (res as UniApp.NodeInfo).height ?? 0
|
|
132
|
-
})
|
|
133
|
-
})
|
|
198
|
+
const res = await getRect('.hy-virtual-container', false, instance)
|
|
199
|
+
viewHeight.value = (res as UniApp.NodeInfo).height ?? 0
|
|
200
|
+
})
|
|
201
|
+
})
|
|
134
202
|
|
|
135
203
|
const itemStyle = computed((): CSSProperties => {
|
|
136
204
|
return {
|
|
@@ -139,91 +207,89 @@ const itemStyle = computed((): CSSProperties => {
|
|
|
139
207
|
marginBottom: addUnit(marginBottom.value),
|
|
140
208
|
borderRadius: addUnit(borderRadius.value),
|
|
141
209
|
background: background.value,
|
|
142
|
-
border: border.value ?
|
|
143
|
-
}
|
|
144
|
-
})
|
|
210
|
+
border: border.value ? '1px solid #dadbde' : '',
|
|
211
|
+
}
|
|
212
|
+
})
|
|
145
213
|
|
|
146
214
|
/**
|
|
147
215
|
* @description 虚拟列表真实展示数据:起始下标
|
|
148
216
|
*/
|
|
149
217
|
const start = computed(() => {
|
|
150
|
-
const s = Math.floor(scrollTop.value / boxHeight)
|
|
151
|
-
return Math.max(0, s * line.value)
|
|
152
|
-
})
|
|
218
|
+
const s = Math.floor(scrollTop.value / boxHeight)
|
|
219
|
+
return Math.max(0, s * line.value)
|
|
220
|
+
})
|
|
153
221
|
|
|
154
222
|
/**
|
|
155
223
|
* @description 虚拟列表真实展示数据:结束下标
|
|
156
224
|
*/
|
|
157
225
|
const over = computed(() => {
|
|
158
|
-
const o = Math.floor(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return Math.min(list.value.length, o * line.value);
|
|
162
|
-
});
|
|
226
|
+
const o = Math.floor((scrollTop.value + viewHeight.value + 1) / boxHeight + 5)
|
|
227
|
+
return Math.min(list.value.length, o * line.value)
|
|
228
|
+
})
|
|
163
229
|
|
|
164
230
|
/**
|
|
165
231
|
* @description 计算虚拟列表的padding(保持列表高度完整且滚动条能正常滚动)
|
|
166
232
|
*/
|
|
167
233
|
const paddingAttr = computed(() => {
|
|
168
|
-
const paddingTop = start.value * boxHeight
|
|
169
|
-
const paddingBottom = (list.value.length - over.value) * boxHeight
|
|
170
|
-
return `${paddingTop / line.value}px 0 ${paddingBottom / line.value}px
|
|
171
|
-
})
|
|
234
|
+
const paddingTop = start.value * boxHeight
|
|
235
|
+
const paddingBottom = (list.value.length - over.value) * boxHeight
|
|
236
|
+
return `${paddingTop / line.value}px 0 ${paddingBottom / line.value}px`
|
|
237
|
+
})
|
|
172
238
|
|
|
173
239
|
/**
|
|
174
240
|
* @description 虚拟列表真实展示数据
|
|
175
241
|
*/
|
|
176
242
|
const virtualData = computed(() => {
|
|
177
|
-
return list.value.slice(start.value, over.value)
|
|
178
|
-
})
|
|
243
|
+
return list.value.slice(start.value, over.value)
|
|
244
|
+
})
|
|
179
245
|
|
|
180
246
|
watch(
|
|
181
247
|
() => virtualData.value,
|
|
182
248
|
(newVal, oldValue) => {
|
|
183
|
-
waterfall.left.length = 0
|
|
184
|
-
waterfall.right.length = 0
|
|
185
|
-
if (line.value === 2 && newVal.every((item) => typeof item !==
|
|
249
|
+
waterfall.left.length = 0
|
|
250
|
+
waterfall.right.length = 0
|
|
251
|
+
if (line.value === 2 && newVal.every((item) => typeof item !== 'string')) {
|
|
186
252
|
newVal.forEach((item, i) => {
|
|
187
253
|
if (i % 2 === 0) {
|
|
188
|
-
waterfall.left.push(item as AnyObject)
|
|
254
|
+
waterfall.left.push(item as AnyObject)
|
|
189
255
|
} else {
|
|
190
|
-
waterfall.right.push(item as AnyObject)
|
|
256
|
+
waterfall.right.push(item as AnyObject)
|
|
191
257
|
}
|
|
192
|
-
})
|
|
258
|
+
})
|
|
193
259
|
}
|
|
194
260
|
},
|
|
195
261
|
{ immediate: true, deep: true },
|
|
196
|
-
)
|
|
262
|
+
)
|
|
197
263
|
|
|
198
264
|
/**
|
|
199
265
|
* @description 监听滚动条距离顶部距离,实时更新
|
|
200
266
|
*/
|
|
201
267
|
const onScroll = async (e: any) => {
|
|
202
|
-
scrollTop.value = e.detail.scrollTop ?? 0
|
|
203
|
-
}
|
|
268
|
+
scrollTop.value = e.detail.scrollTop ?? 0
|
|
269
|
+
}
|
|
204
270
|
|
|
205
271
|
/**
|
|
206
272
|
* @description 滚动底部函数
|
|
207
273
|
* */
|
|
208
274
|
const scrollToLower = () => {
|
|
209
|
-
emit(
|
|
210
|
-
}
|
|
275
|
+
emit('scrollToLower')
|
|
276
|
+
}
|
|
211
277
|
|
|
212
278
|
/**
|
|
213
279
|
* @description 点击行触发函数
|
|
214
280
|
* */
|
|
215
281
|
const handleClick = (temp: string | AnyObject) => {
|
|
216
|
-
emit(
|
|
217
|
-
}
|
|
282
|
+
emit('click', temp)
|
|
283
|
+
}
|
|
218
284
|
|
|
219
285
|
/**
|
|
220
286
|
* @description 获取默认插槽
|
|
221
287
|
*/
|
|
222
|
-
const slotDefault = useSlots().default
|
|
288
|
+
const slotDefault = useSlots().default
|
|
223
289
|
</script>
|
|
224
290
|
|
|
225
291
|
<style lang="scss" scoped>
|
|
226
|
-
@import
|
|
292
|
+
@import './index.scss';
|
|
227
293
|
.hy-virtual-container {
|
|
228
294
|
height: v-bind(listHeight);
|
|
229
295
|
&__list {
|
|
@@ -2,49 +2,56 @@ export default interface HyListProps {
|
|
|
2
2
|
/**
|
|
3
3
|
* @description 数据列表
|
|
4
4
|
* */
|
|
5
|
-
list: (AnyObject | string)[]
|
|
5
|
+
list: (AnyObject | string)[]
|
|
6
6
|
/**
|
|
7
7
|
* @description 容器高度,必须给个高度,否则加载全部数据
|
|
8
8
|
* */
|
|
9
|
-
containerHeight: string
|
|
9
|
+
containerHeight: string
|
|
10
10
|
/**
|
|
11
11
|
* @description 子容器的高度,必须和内容一致,否则计算有问题
|
|
12
12
|
* */
|
|
13
|
-
itemHeight?: number | string
|
|
13
|
+
itemHeight?: number | string
|
|
14
14
|
/**
|
|
15
15
|
* @description 子容器的内边距
|
|
16
16
|
* */
|
|
17
|
-
padding?: number | string
|
|
17
|
+
padding?: number | string
|
|
18
18
|
/**
|
|
19
19
|
* @description 子容器的底部,会计算到容器内
|
|
20
20
|
* */
|
|
21
|
-
marginBottom?: number | string
|
|
21
|
+
marginBottom?: number | string
|
|
22
22
|
/**
|
|
23
23
|
* @description 子容器的圆角,单位px
|
|
24
24
|
* */
|
|
25
|
-
borderRadius?: number | string
|
|
25
|
+
borderRadius?: number | string
|
|
26
26
|
/**
|
|
27
27
|
* @description 容器背景色
|
|
28
28
|
* */
|
|
29
|
-
background?: string
|
|
29
|
+
background?: string
|
|
30
30
|
/**
|
|
31
31
|
* @description 是否显示边框(默认false)
|
|
32
32
|
* */
|
|
33
|
-
border?: boolean
|
|
33
|
+
border?: boolean
|
|
34
34
|
/**
|
|
35
35
|
* @description 展示几列
|
|
36
36
|
* */
|
|
37
|
-
line?: number
|
|
37
|
+
line?: number
|
|
38
38
|
/**
|
|
39
39
|
* @description 加载状态
|
|
40
40
|
* */
|
|
41
|
-
load?:
|
|
41
|
+
load?: 'loadMore' | 'loading' | 'noMore'
|
|
42
42
|
/**
|
|
43
43
|
* @description 每一项的唯一标识key
|
|
44
44
|
* */
|
|
45
|
-
keyField?: string
|
|
45
|
+
keyField?: string
|
|
46
46
|
/**
|
|
47
47
|
* @description 显示底部加载状态
|
|
48
48
|
* */
|
|
49
|
-
showDivider?: boolean
|
|
49
|
+
showDivider?: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IListEmits {
|
|
53
|
+
/** 点击行触发 */
|
|
54
|
+
(e: 'click', temp: string | AnyObject): void
|
|
55
|
+
/** 滚动底部触发 */
|
|
56
|
+
(e: 'scrollToLower'): void
|
|
50
57
|
}
|
|
@@ -25,12 +25,7 @@
|
|
|
25
25
|
>
|
|
26
26
|
<block v-if="mode === 'spinner'">
|
|
27
27
|
<!-- #ifndef APP-NVUE -->
|
|
28
|
-
<view
|
|
29
|
-
v-for="(item, index) in array12"
|
|
30
|
-
:key="index"
|
|
31
|
-
class="hy-loading-icon__dot"
|
|
32
|
-
>
|
|
33
|
-
</view>
|
|
28
|
+
<view v-for="(item, index) in array12" :key="index" class="hy-loading-icon__dot"></view>
|
|
34
29
|
<!-- #endif -->
|
|
35
30
|
</block>
|
|
36
31
|
</view>
|
|
@@ -41,47 +36,106 @@
|
|
|
41
36
|
fontSize: addUnit(textSize),
|
|
42
37
|
color: textColor,
|
|
43
38
|
}"
|
|
44
|
-
>{{ text }}</text
|
|
45
39
|
>
|
|
40
|
+
{{ text }}
|
|
41
|
+
</text>
|
|
46
42
|
</view>
|
|
47
43
|
</template>
|
|
48
44
|
|
|
49
45
|
<script lang="ts">
|
|
46
|
+
/**
|
|
47
|
+
* 目前用在华玥的loadMore加载更多等组件的正在加载状态场景。
|
|
48
|
+
* @displayName hy-loading
|
|
49
|
+
*/
|
|
50
|
+
defineOptions({})
|
|
50
51
|
export default {
|
|
51
52
|
name: 'hy-loading',
|
|
52
53
|
options: {
|
|
53
54
|
addGlobalClass: true,
|
|
54
55
|
virtualHost: true,
|
|
55
|
-
styleIsolation: 'shared'
|
|
56
|
-
}
|
|
56
|
+
styleIsolation: 'shared',
|
|
57
|
+
},
|
|
57
58
|
}
|
|
58
59
|
</script>
|
|
59
60
|
|
|
60
61
|
<script setup lang="ts">
|
|
61
|
-
import
|
|
62
|
-
import type
|
|
63
|
-
import {
|
|
64
|
-
import { addUnit, colorGradient } from "../../utils";
|
|
62
|
+
import { toRefs, ref, computed } from 'vue'
|
|
63
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
64
|
+
import { addUnit, colorGradient } from '../../utils'
|
|
65
65
|
|
|
66
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
67
|
-
const
|
|
68
|
-
|
|
66
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
67
|
+
const props = defineProps({
|
|
68
|
+
/** 是否显示组件 */
|
|
69
|
+
show: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: true,
|
|
72
|
+
},
|
|
73
|
+
/** 动画活动区域的颜色,只对 mode = flower 模式有效 */
|
|
74
|
+
color: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: '#909399',
|
|
77
|
+
},
|
|
78
|
+
/** 提示文本的颜色 */
|
|
79
|
+
textColor: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: '#909399',
|
|
82
|
+
},
|
|
83
|
+
/** 文字和图标是否垂直排列 */
|
|
84
|
+
vertical: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: false,
|
|
87
|
+
},
|
|
88
|
+
/** 模式选择,见官网说明 */
|
|
89
|
+
mode: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: 'spinner',
|
|
92
|
+
},
|
|
93
|
+
/** 加载图标的大小,单位px */
|
|
94
|
+
size: {
|
|
95
|
+
type: Number,
|
|
96
|
+
default: 24,
|
|
97
|
+
},
|
|
98
|
+
/** 文字大小 */
|
|
99
|
+
textSize: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: 15,
|
|
102
|
+
},
|
|
103
|
+
/** 文字内容 */
|
|
104
|
+
text: String,
|
|
105
|
+
/** 动画模式 */
|
|
106
|
+
timingFunction: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: 'ease-in-out',
|
|
109
|
+
},
|
|
110
|
+
/** 动画执行周期时间 */
|
|
111
|
+
duration: {
|
|
112
|
+
type: Number,
|
|
113
|
+
default: 1200,
|
|
114
|
+
},
|
|
115
|
+
/** mode=circle时的暗边颜色 */
|
|
116
|
+
inactiveColor: String,
|
|
117
|
+
/** 定义需要用到的外部样式 */
|
|
118
|
+
customStyle: {
|
|
119
|
+
type: Object as PropType<CSSProperties>,
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
const { show, size, color, mode, inactiveColor } = toRefs(props)
|
|
69
123
|
|
|
70
124
|
//动画旋转角度
|
|
71
|
-
const aniAngel = ref(360)
|
|
125
|
+
const aniAngel = ref(360)
|
|
72
126
|
const array12 = Array.from({
|
|
73
127
|
length: 12,
|
|
74
|
-
})
|
|
75
|
-
const webviewHide = ref(false)
|
|
128
|
+
})
|
|
129
|
+
const webviewHide = ref(false)
|
|
76
130
|
|
|
77
131
|
const otherBorderColor = computed(() => {
|
|
78
|
-
const lightColor = colorGradient(color.value,
|
|
79
|
-
if (mode.value ===
|
|
80
|
-
return inactiveColor.value ? inactiveColor.value : lightColor
|
|
132
|
+
const lightColor = colorGradient(color.value, '#ffffff', 100)[80]
|
|
133
|
+
if (mode.value === 'circle') {
|
|
134
|
+
return inactiveColor.value ? inactiveColor.value : lightColor
|
|
81
135
|
} else {
|
|
82
|
-
return
|
|
136
|
+
return 'transparent'
|
|
83
137
|
}
|
|
84
|
-
})
|
|
138
|
+
})
|
|
85
139
|
|
|
86
140
|
// 监听webview的显示与隐藏
|
|
87
141
|
// const addEventListenerToWebview = () => {
|
|
@@ -102,5 +156,5 @@ const otherBorderColor = computed(() => {
|
|
|
102
156
|
</script>
|
|
103
157
|
|
|
104
158
|
<style lang="scss" scoped>
|
|
105
|
-
@import
|
|
159
|
+
@import './index.scss';
|
|
106
160
|
</style>
|