uview-plus 3.4.71 → 3.4.73

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/changelog.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 3.4.73(2025-08-05)
2
+ improvment: 优化下拉刷新默认图标
3
+
4
+ ## 3.4.72(2025-08-05)
5
+ improvment: 优化virtual-list虚拟列表样式
6
+
7
+ feat: 新增virtual-list虚拟列表演示
8
+
1
9
  ## 3.4.71(2025-08-05)
2
10
  feat: 新增virtual-list虚拟列表组件
3
11
 
@@ -22,7 +22,7 @@
22
22
  <!-- 默认下拉状态 -->
23
23
  <view class="refresh-content">
24
24
  <view class="refresh-indicator">
25
- <view class="arrow"></view>
25
+ <up-icon name="arrow-downward" size="26px"></up-icon>
26
26
  </view>
27
27
  <text class="refresh-text">下拉刷新</text>
28
28
  </view>
@@ -37,7 +37,7 @@
37
37
  <!-- 默认释放状态 -->
38
38
  <view class="refresh-content">
39
39
  <view class="refresh-indicator">
40
- <view class="arrow rotate"></view>
40
+ <up-icon name="arrow-upward" size="26px"></up-icon>
41
41
  </view>
42
42
  <text class="refresh-text">释放刷新</text>
43
43
  </view>
@@ -106,7 +106,7 @@ export default {
106
106
  // 下拉刷新阈值
107
107
  threshold: {
108
108
  type: Number,
109
- default: 50
109
+ default: 80
110
110
  },
111
111
  // 阻尼系数
112
112
  damping: {
@@ -116,7 +116,7 @@ export default {
116
116
  // 最大下拉距离
117
117
  maxDistance: {
118
118
  type: Number,
119
- default: 100
119
+ default: 120
120
120
  },
121
121
  // 是否显示加载更多
122
122
  showLoadmore: {
@@ -311,28 +311,6 @@ export default {
311
311
  padding-bottom: 10px;
312
312
  }
313
313
 
314
- .refresh-indicator {
315
- width: 24px;
316
- height: 24px;
317
- display: flex;
318
- align-items: center;
319
- justify-content: center;
320
- margin-bottom: 8px;
321
- }
322
-
323
- .arrow {
324
- width: 12px;
325
- height: 12px;
326
- border-left: 2px solid #666;
327
- border-bottom: 2px solid #666;
328
- transform: rotate(-45deg);
329
- transition: transform 0.2s;
330
- }
331
-
332
- .arrow.rotate {
333
- transform: rotate(135deg);
334
- }
335
-
336
314
  .spinner {
337
315
  width: 16px;
338
316
  height: 16px;
@@ -1,13 +1,13 @@
1
1
  <template>
2
- <view class="u-virtual-list" :style="{ height: addUnit(height) }">
2
+ <view class="u-virtual-list" :style="{ height: addUnit(height) }" ref="container">
3
3
  <scroll-view
4
4
  class="virtual-scroll-container"
5
5
  :scroll-y="true"
6
6
  :scroll-top="scrollTop"
7
7
  :style="{ height: '100%' }"
8
8
  @scroll="handleScroll"
9
- touchmove.stop.prevent="handleTouchMove"
10
9
  >
10
+ <!-- @touchmove.stop.prevent="handleTouchMove" -->
11
11
  <view class="scroll-content">
12
12
  <!-- 顶部占位 -->
13
13
  <view :style="{ height: topPlaceholderHeight + 'px' }"></view>
@@ -81,7 +81,9 @@ export default {
81
81
  // 默认值,防止除以0
82
82
  return Math.ceil(500 / this.itemHeight) || 10
83
83
  }
84
- return Math.ceil(this.containerHeight / this.itemHeight)
84
+ const calculated = Math.ceil(this.containerHeight / this.itemHeight)
85
+ // 确保至少显示一些项
86
+ return Math.max(1, calculated)
85
87
  },
86
88
  // 可视项数量
87
89
  visibleCount() {
@@ -111,6 +113,7 @@ export default {
111
113
  return (this.listData.length - end) * this.itemHeight
112
114
  }
113
115
  },
116
+ emits: ['update:scrollTop', 'scroll'],
114
117
  watch: {
115
118
  listData: {
116
119
  handler() {
@@ -132,25 +135,69 @@ export default {
132
135
 
133
136
  // 测量容器高度
134
137
  measureContainerHeight() {
138
+ // 使用 uni.createSelectorQuery 获取实际高度
139
+ this.$nextTick(() => {
140
+ // #ifdef H5
141
+ if (this.$refs.container) {
142
+ const element = this.$refs.container.$el || this.$refs.container
143
+ this.containerHeight = element.offsetHeight || 500
144
+ }
145
+ // #endif
146
+
147
+ // #ifndef H5
148
+ const query = uni.createSelectorQuery().in(this)
149
+ query.select('.u-virtual-list').boundingClientRect(rect => {
150
+ if (rect) {
151
+ this.containerHeight = rect.height || 500
152
+ } else {
153
+ // 如果无法获取实际高度,使用默认计算
154
+ this.containerHeight = this.calculateDefaultHeight()
155
+ }
156
+ }).exec()
157
+ // #endif
158
+ })
159
+ },
160
+
161
+ // 计算默认高度
162
+ calculateDefaultHeight() {
135
163
  const height = this.height
136
164
  if (typeof height === 'number') {
137
- this.containerHeight = height
138
- return
165
+ return height
139
166
  }
140
167
 
141
168
  if (typeof height === 'string') {
142
169
  if (height.includes('px')) {
143
- this.containerHeight = parseInt(height)
170
+ return parseInt(height) || 500
171
+ } else if (height.includes('vh')) {
172
+ // 处理视口高度单位
173
+ const vh = parseInt(height)
174
+ return isNaN(vh) ? 500 : (vh / 100) * this.getViewportHeight()
144
175
  } else if (height.includes('%')) {
145
- // 对于百分比高度,使用默认值或根据父容器计算
146
- this.containerHeight = 500
176
+ // 百分比高度,使用默认值
177
+ return 500
147
178
  } else {
148
179
  const num = parseInt(height)
149
- this.containerHeight = isNaN(num) ? 500 : num
180
+ return isNaN(num) ? 500 : num
150
181
  }
151
- } else {
152
- this.containerHeight = 500
153
182
  }
183
+
184
+ return 500
185
+ },
186
+
187
+ // 获取视口高度
188
+ getViewportHeight() {
189
+ // #ifdef H5
190
+ return window.innerHeight
191
+ // #endif
192
+
193
+ // #ifndef H5
194
+ try {
195
+ const res = uni.getSystemInfoSync()
196
+ return res.windowHeight
197
+ } catch (e) {
198
+ return 600 // 默认值
199
+ }
200
+ // #endif
154
201
  },
155
202
 
156
203
  getItemKey(item) {
@@ -166,6 +213,7 @@ export default {
166
213
  // 处理滚动
167
214
  handleScroll(e) {
168
215
  const scrollTop = e.detail.scrollTop
216
+ this.$emit('update:scrollTop', scrollTop)
169
217
  this.$emit('scroll', scrollTop)
170
218
  },
171
219
 
@@ -183,4 +231,23 @@ export default {
183
231
  }
184
232
  }
185
233
  }
186
- </script>
234
+ </script>
235
+
236
+ <style scoped lang="scss">
237
+ .u-virtual-list {
238
+ position: relative;
239
+ overflow: hidden;
240
+ }
241
+
242
+ .virtual-scroll-container {
243
+ height: 100%;
244
+ }
245
+
246
+ .scroll-content {
247
+ position: relative;
248
+ }
249
+
250
+ .list-item {
251
+ will-change: transform;
252
+ }
253
+ </style>
package/package.json CHANGED
@@ -2,15 +2,13 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.4.71",
6
- "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
5
+ "version": "3.4.73",
6
+ "description": "零云®uview-plus已兼容vue3,100+全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
7
7
  "keywords": [
8
8
  "uview",
9
9
  "uview-plus",
10
10
  "ui",
11
- "ui",
12
- "uni-app",
13
- "uni-app",
11
+ "echarts",
14
12
  "ui",
15
13
  "可视化设计"
16
14
  ],