uview-pro 0.6.0-beta.0 → 0.6.0-beta.1

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,28 +1,39 @@
1
- ## 0.6.0-beta.0(2026-04-30
1
+ ## 0.6.0-beta.1(2026-05-08
2
2
 
3
3
  ### ✨ Features | 新功能
4
4
 
5
- - **u-upload:** 新增多种上传模式和文件类型支持,支持图片、视频、文档等多种类型,支持网格(grid)和列表(list)两种展示模式 ([f75d34c](https://github.com/anyup/uView-Pro/commit/f75d34c22d551c41e8e873bc5779089ff2b2c0c7))
6
- - **u-upload:** 新增 v-model 支持并优化文件列表同步逻辑 ([5548d84](https://github.com/anyup/uView-Pro/commit/5548d847b5c442da40775ec06ecfab7f0fddf448))
7
- - **upload:** 完善上传组件示例页面功能,添加多种上传模式示例:图片上传(网格模式)、文件上传(列表模式)、视频上传 ([d43b3d2](https://github.com/anyup/uView-Pro/commit/d43b3d2c7f0ff7a7fe45467d49d451ca878b7eb1))
8
-
9
- ### ♻️ Code Refactoring | 代码重构
10
-
11
- - **u-divider:** 规范化 slot 标签 ([fccac33](https://github.com/anyup/uView-Pro/commit/fccac33b6adce3395179d5c55b7b8a0a4d25a800))
12
-
13
- ### 🐛 Bug Fixes | Bug 修复
14
-
15
- - **u-upload:** 优化微信小程序平台监听文件列表变化不触发on-list-change事件的场景 ([47fa5c1](https://github.com/anyup/uView-Pro/commit/47fa5c1dfa30214dfc40f7ee01b09f6f95d09b9a))
16
- - **changelog:** 修复版本标题格式和Unreleased区块处理 ([3a87f47](https://github.com/anyup/uView-Pro/commit/3a87f4739cdebc1aafcb33e3f9b31dd79f9bc3d2))
17
-
18
- ### 👷 Continuous Integration | CI 配置
19
-
20
- - 增强预发布版本支持和发布管理功能 ([86abdaa](https://github.com/anyup/uView-Pro/commit/86abdaad6a618dfa42416138f05baf910f52fba5))
5
+ - **u-upload:** 新增image-shape属性支持圆形和方形展示 ([fac9414](https://github.com/anyup/uView-Pro/commit/fac941413ba4d944116513934306376a0188fcda))
6
+ - **u-upload:** 新增customChoose属性支持自定义文件选择功能 ([97e17ee](https://github.com/anyup/uView-Pro/commit/97e17eeae15c03a7791bb5eec4159782f3d70d84))
21
7
 
22
8
  ### 👥 Contributors
23
9
 
24
10
  <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
25
11
 
12
+ ## 0.6.0-beta.0(2026-04-30)
13
+
14
+ ### ✨ Features | 新功能
15
+
16
+ - **u-upload:** 新增多种上传模式和文件类型支持,支持图片、视频、文档等多种类型,支持网格(grid)和列表(list)两种展示模式 ([f75d34c](https://github.com/anyup/uView-Pro/commit/f75d34c22d551c41e8e873bc5779089ff2b2c0c7))
17
+ - **u-upload:** 新增 v-model 支持并优化文件列表同步逻辑 ([5548d84](https://github.com/anyup/uView-Pro/commit/5548d847b5c442da40775ec06ecfab7f0fddf448))
18
+ - **upload:** 完善上传组件示例页面功能,添加多种上传模式示例:图片上传(网格模式)、文件上传(列表模式)、视频上传 ([d43b3d2](https://github.com/anyup/uView-Pro/commit/d43b3d2c7f0ff7a7fe45467d49d451ca878b7eb1))
19
+
20
+ ### ♻️ Code Refactoring | 代码重构
21
+
22
+ - **u-divider:** 规范化 slot 标签 ([fccac33](https://github.com/anyup/uView-Pro/commit/fccac33b6adce3395179d5c55b7b8a0a4d25a800))
23
+
24
+ ### 🐛 Bug Fixes | Bug 修复
25
+
26
+ - **u-upload:** 优化微信小程序平台监听文件列表变化不触发on-list-change事件的场景 ([47fa5c1](https://github.com/anyup/uView-Pro/commit/47fa5c1dfa30214dfc40f7ee01b09f6f95d09b9a))
27
+ - **changelog:** 修复版本标题格式和Unreleased区块处理 ([3a87f47](https://github.com/anyup/uView-Pro/commit/3a87f4739cdebc1aafcb33e3f9b31dd79f9bc3d2))
28
+
29
+ ### 👷 Continuous Integration | CI 配置
30
+
31
+ - 增强预发布版本支持和发布管理功能 ([86abdaa](https://github.com/anyup/uView-Pro/commit/86abdaad6a618dfa42416138f05baf910f52fba5))
32
+
33
+ ### 👥 Contributors
34
+
35
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
36
+
26
37
  ## 0.5.18(2026-04-22)
27
38
 
28
39
  ### 🐛 Bug Fixes | Bug 修复
@@ -153,7 +153,19 @@ export const UploadProps = {
153
153
  * 选择文件时的扩展名过滤
154
154
  * @description 仅在 accept='file' 或 accept='all' 时有效
155
155
  */
156
- extension: { type: Array as PropType<string[]>, default: () => [] }
156
+ extension: { type: Array as PropType<string[]>, default: () => [] },
157
+ /**
158
+ * 图片/图标展示形状
159
+ * @description 可选值:square-方形(默认), circle-圆形。在 grid 模式下作用于图片和添加按钮,在 list 模式下作用于图标
160
+ * @default 'square'
161
+ */
162
+ imageShape: { type: String as PropType<'square' | 'circle'>, default: 'square' },
163
+ /**
164
+ * 是否使用自定义选择文件
165
+ * @description 设置为 true 时,点击选择文件会触发 on-choose 事件,不会调用默认的文件选择 API,用户可自行处理文件选择逻辑,然后通过 addFiles 方法将文件添加到列表
166
+ * @default false
167
+ */
168
+ customChoose: { type: Boolean, default: false }
157
169
  };
158
170
 
159
171
  export type UploadProps = ExtractPropTypes<typeof UploadProps>;
@@ -18,11 +18,20 @@
18
18
  <view class="u-upload-list__left" @tap.stop="handlePreview(item, index)">
19
19
  <!-- 图片类型:显示缩略图 -->
20
20
  <template v-if="isImageFile(item)">
21
- <image class="u-upload-list__thumb" :src="item.url || item.path" mode="aspectFill" />
21
+ <image
22
+ class="u-upload-list__thumb"
23
+ :class="{ 'u-upload-list__thumb--circle': props.imageShape === 'circle' }"
24
+ :src="item.url || item.path"
25
+ :mode="imageMode"
26
+ />
22
27
  </template>
23
28
  <!-- 非图片类型:显示文件图标 -->
24
29
  <template v-else>
25
- <view class="u-upload-list__icon" :style="{ background: getFileIcon(item).bgColor }">
30
+ <view
31
+ class="u-upload-list__icon"
32
+ :class="{ 'u-upload-list__icon--circle': props.imageShape === 'circle' }"
33
+ :style="{ background: getFileIcon(item).bgColor }"
34
+ >
26
35
  <u-icon :name="getFileIcon(item).name" size="32" color="var(--u-white-color)"></u-icon>
27
36
  </view>
28
37
  </template>
@@ -99,8 +108,9 @@
99
108
  <template v-else>
100
109
  <template v-if="showUploadList">
101
110
  <view
102
- class="u-upload-grid__item u-upload-grid__preview"
103
111
  v-for="(item, index) in lists"
112
+ class="u-upload-grid__item u-upload-grid__preview"
113
+ :class="{ 'u-upload-grid__item--circle': props.imageShape === 'circle' }"
104
114
  :key="index"
105
115
  :style="{
106
116
  width: $u.addUnit(width),
@@ -132,10 +142,11 @@
132
142
  <!-- 图片类型预览 -->
133
143
  <template v-if="isImageFile(item)">
134
144
  <image
135
- @tap.stop="handlePreview(item, index)"
136
145
  class="u-upload-grid__image"
146
+ :class="{ 'u-upload-grid__image--circle': props.imageShape === 'circle' }"
137
147
  :src="item.url || item.path"
138
148
  :mode="imageMode"
149
+ @tap.stop="handlePreview(item, index)"
139
150
  ></image>
140
151
  </template>
141
152
 
@@ -190,6 +201,7 @@
190
201
  class="u-upload-grid__item u-upload-grid__add"
191
202
  hover-class="u-upload-grid__add--hover"
192
203
  hover-stay-time="150"
204
+ :class="{ 'u-upload-grid__item--circle': props.imageShape === 'circle' }"
193
205
  :style="{
194
206
  width: $u.addUnit(width),
195
207
  height: $u.addUnit(height)
@@ -262,10 +274,12 @@ import type { UploadFileItem } from '../../types/global';
262
274
  * @property {Boolean} compressed 选择视频时是否压缩(默认true)
263
275
  * @property {Number} max-duration 选择视频时拍摄最长时长,单位秒(默认60)
264
276
  * @property {String} camera 选择视频时摄像头方向,可选值:front|back(默认'back')
277
+ * @property {String} image-shape 图片/图标展示形状,可选值:square|circle(默认'square'),在grid模式下作用于图片和添加按钮,在list模式下作用于图标
265
278
  * @property {Array<Object>} file-list 默认显示的文件列表,数组元素为对象,必须提供url属性
266
279
  * @property {Function} before-upload 上传前钩子,返回false或Promise.reject则跳过当前文件上传
267
280
  * @property {Function} before-remove 删除前钩子,返回false或Promise.reject则阻止删除
268
281
  * @property {Boolean} to-json 如果上传后的返回值为json字符串,是否自动转为json格式(默认true)
282
+ * @property {Boolean} custom-choose 是否使用自定义文件选择,开启后点击选择文件会触发 on-choose 事件而不调用默认选择API(默认false)
269
283
  *
270
284
  * @event {Function} on-oversize 文件大小超出max-size限制时触发
271
285
  * @event {Function} on-exceed 文件数量超出max-count限制时触发
@@ -279,6 +293,7 @@ import type { UploadFileItem } from '../../types/global';
279
293
  * @event {Function} on-remove 移除文件时触发
280
294
  * @event {Function} on-preview 预览文件时触发
281
295
  * @event {Function} on-list-change 文件列表发生变化时触发
296
+ * @event {Function} on-choose 启用 custom-choose 时触发,参数为 { accept, maxCount, fileList, index },用户可自定义文件选择逻辑
282
297
  *
283
298
  * @example <u-upload :action="action" :file-list="fileList" accept="image"></u-upload>
284
299
  * @example <u-upload :action="action" accept="file" mode="list" :show-file-name="true"></u-upload>
@@ -292,6 +307,7 @@ const emit = defineEmits([
292
307
  'on-list-change',
293
308
  'on-oversize',
294
309
  'on-exceed',
310
+ 'on-choose',
295
311
  'on-choose-complete',
296
312
  'on-choose-fail',
297
313
  'on-uploaded',
@@ -594,6 +610,17 @@ function reUpload() {
594
610
  function selectFile() {
595
611
  if (props.disabled) return;
596
612
 
613
+ // 如果启用了自定义选择,触发 on-choose 事件,由用户自行处理文件选择
614
+ if (props.customChoose) {
615
+ emit('on-choose', {
616
+ accept: props.accept,
617
+ maxCount: props.maxCount,
618
+ fileList: lists.value,
619
+ index: props.index
620
+ });
621
+ return;
622
+ }
623
+
597
624
  // 根据 accept 类型选择不同的文件选择方式
598
625
  switch (props.accept) {
599
626
  case 'image':
@@ -751,6 +778,8 @@ function chooseFile() {
751
778
 
752
779
  /**
753
780
  * 处理选中的文件
781
+ * @param files 文件数组
782
+ * @param sourceType 文件来源类型
754
783
  */
755
784
  function handleFilesSelected(files: any[], sourceType: 'image' | 'video' | 'media' | 'file') {
756
785
  let listOldLength = lists.value.length;
@@ -781,8 +810,12 @@ function handleFilesSelected(files: any[], sourceType: 'image' | 'video' | 'medi
781
810
  } else if (props.accept === 'file') {
782
811
  fileType = 'file';
783
812
  } else {
784
- // media 或 all 时,根据路径或 sourceType 检测
785
- fileType = detectFileTypeFromPath(val.path || val.name || '');
813
+ // media 或 all 时,根据 sourceType 或路径检测
814
+ if (sourceType === 'image' || sourceType === 'video') {
815
+ fileType = sourceType;
816
+ } else {
817
+ fileType = detectFileTypeFromPath(val.path || val.name || '');
818
+ }
786
819
  }
787
820
 
788
821
  lists.value.push({
@@ -805,9 +838,19 @@ function handleFilesSelected(files: any[], sourceType: 'image' | 'video' | 'medi
805
838
 
806
839
  // 每次文件选择完,抛出一个事件,并将当前内部选择的文件数组抛出去
807
840
  emit('on-choose-complete', lists.value, props.index);
841
+ // 使用 props.autoUpload 是否立即上传
808
842
  if (props.autoUpload) uploadFile(listOldLength);
809
843
  }
810
844
 
845
+ /**
846
+ * 添加文件到列表(供外部调用,配合 custom-choose 使用)
847
+ * @param files 文件数组,格式为 { path: string, name?: string, size?: number, fileType?: 'image'|'video'|'file', ... }
848
+ */
849
+ function addFiles(files: any[]) {
850
+ if (!files || !Array.isArray(files) || files.length === 0) return;
851
+ handleFilesSelected(files, props.accept as 'image' | 'video' | 'media' | 'file');
852
+ }
853
+
811
854
  /**
812
855
  * 从路径中获取文件扩展名
813
856
  */
@@ -1187,7 +1230,18 @@ function checkFileExt(file: { name?: string; path?: string }): boolean {
1187
1230
  return isValid;
1188
1231
  }
1189
1232
 
1190
- defineExpose({ clear, reUpload, selectFile, upload, retry, remove, doPreviewImage, doPreviewFile, lists });
1233
+ defineExpose({
1234
+ lists,
1235
+ clear,
1236
+ reUpload,
1237
+ selectFile,
1238
+ upload,
1239
+ retry,
1240
+ remove,
1241
+ previewImage: doPreviewImage,
1242
+ previewFile: doPreviewFile,
1243
+ addFiles
1244
+ });
1191
1245
  </script>
1192
1246
 
1193
1247
  <style lang="scss" scoped>
@@ -1241,6 +1295,27 @@ defineExpose({ clear, reUpload, selectFile, upload, retry, remove, doPreviewImag
1241
1295
  border-radius: 10rpx;
1242
1296
  }
1243
1297
 
1298
+ .u-upload-grid__image--circle {
1299
+ border-radius: 50%;
1300
+ }
1301
+
1302
+ .u-upload-grid__item--circle {
1303
+ border-radius: 50%;
1304
+ }
1305
+
1306
+ .u-upload-grid__item--circle .u-upload-grid__delete {
1307
+ top: 20rpx;
1308
+ right: 30rpx;
1309
+ width: 36rpx;
1310
+ height: 36rpx;
1311
+ }
1312
+
1313
+ .u-upload-grid__item--circle .u-upload-grid__progress {
1314
+ bottom: 16rpx;
1315
+ left: 16rpx;
1316
+ right: 16rpx;
1317
+ }
1318
+
1244
1319
  .u-upload-grid__delete {
1245
1320
  position: absolute;
1246
1321
  top: 10rpx;
@@ -1390,6 +1465,10 @@ defineExpose({ clear, reUpload, selectFile, upload, retry, remove, doPreviewImag
1390
1465
  background: var(--u-bg-gray-light);
1391
1466
  }
1392
1467
 
1468
+ .u-upload-list__thumb--circle {
1469
+ border-radius: 50%;
1470
+ }
1471
+
1393
1472
  .u-upload-list__icon {
1394
1473
  width: 80rpx;
1395
1474
  height: 80rpx;
@@ -1399,6 +1478,10 @@ defineExpose({ clear, reUpload, selectFile, upload, retry, remove, doPreviewImag
1399
1478
  justify-content: center;
1400
1479
  }
1401
1480
 
1481
+ .u-upload-list__icon--circle {
1482
+ border-radius: 50%;
1483
+ }
1484
+
1402
1485
  // 中间:文件名信息
1403
1486
  .u-upload-list__center {
1404
1487
  flex: 1;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
4
  "displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的高质量UI组件库,支持多主题、暗黑模式、多语言",
5
- "version": "0.6.0-beta.0",
5
+ "version": "0.6.0-beta.1",
6
6
  "description": "uView Pro是基于Vue3+TS的多平台UI框架,提供80+高质量组件、便捷工具和常用模板,支持多主题、暗黑模式、多语言,支持H5/APP/鸿蒙/小程序多端开发。已在鸿蒙应用商店上架,欢迎体验!",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",