uview-plus 3.4.22 → 3.4.24

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,16 @@
1
+ ## 3.4.24(2025-04-25)
2
+ fix: 修复upload上传逻辑(感谢@semdy)
3
+
4
+ ## 3.4.23(2025-04-24)
5
+ chore: 补全chooseFile TS类型(感谢@semdy)
6
+
7
+ feat: u-search组件的图标支持显示在右边(感谢@semdy)
8
+
9
+ chore: 修正chooseFile返回的数据TS类型(感谢@semdy)
10
+
11
+ fix: PR导致缺失name影响uplad自动上传扩展名
12
+
13
+
1
14
  ## 3.4.22(2025-04-22)
2
15
  fix: 修复自动上传偶发的success被覆盖为uploading
3
16
 
@@ -129,6 +129,10 @@ export const props = defineMixin({
129
129
  autoBlur: {
130
130
  type: Boolean,
131
131
  default: () => false
132
+ },
133
+ iconPosition: {
134
+ type: String,
135
+ default: () => defProps.search.iconPosition
132
136
  }
133
137
  }
134
138
  })
@@ -27,6 +27,7 @@ export default {
27
27
  color: '#606266',
28
28
  placeholderColor: '#909399',
29
29
  searchIcon: 'search',
30
+ iconPosition: 'left',
30
31
  margin: '0',
31
32
  animation: false,
32
33
  value: '',
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <view
3
3
  class="u-search"
4
+ :class="[iconPosition === 'right' && 'u-search__reverse']"
4
5
  @tap="clickHandler"
5
6
  :style="[{
6
7
  margin: margin,
@@ -100,6 +101,7 @@
100
101
  * @property {String} color 输入框字体颜色(默认 '#606266' )
101
102
  * @property {String} placeholderColor placeholder的颜色(默认 '#909399' )
102
103
  * @property {String} searchIcon 输入框左边的图标,可以为uView图标名称或图片路径 (默认 'search' )
104
+ * @property {String} iconPosition 输入框图标位置,left-左边, right-右边 (默认 'left' )
103
105
  * @property {String} margin 组件与其他上下左右元素之间的距离,带单位的字符串形式,如"30px" (默认 '0' )
104
106
  * @property {Boolean} animation 是否开启动画,见上方说明(默认 false )
105
107
  * @property {String} value 输入框初始值
@@ -328,5 +330,13 @@ $u-search-action-margin-left: 5px !default;
328
330
  margin-left: $u-search-action-margin-left;
329
331
  }
330
332
  }
333
+
334
+ &__reverse &__content__icon {
335
+ order: 3;
336
+ }
337
+
338
+ &__reverse &__content__close {
339
+ order: 2;
340
+ }
331
341
  }
332
342
  </style>
@@ -200,6 +200,7 @@
200
200
  * @tutorial https://uview-plus.jiangruyi.com/components/upload.html
201
201
  * @property {String} accept 接受的文件类型, 可选值为all media image file video (默认 'image' )
202
202
  * @property {String | Array} capture 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头(默认 ['album', 'camera'] )
203
+ * @property {Array} extension 选择文件的后缀名,暂只支持.zip、.png等,不支持application/msword等值
203
204
  * @property {Boolean} compressed 当accept为video时生效,是否压缩视频,默认为true(默认 true )
204
205
  * @property {String} camera 当accept为video时生效,可选值为back或front(默认 'back' )
205
206
  * @property {Number} maxDuration 当accept为video时生效,拍摄视频最长拍摄时间,单位秒(默认 60 )
@@ -334,8 +335,8 @@
334
335
  const name = item.name || item.url || item.thumb
335
336
  return Object.assign(Object.assign({}, item), {
336
337
  // 如果item.url为本地选择的blob文件的话,无法判断其为video还是image,此处优先通过accept做判断处理
337
- isImage: name ? test.image(name) : (this.accept === 'image' || test.image(name)),
338
- isVideo: name ? test.video(name) : (this.accept === 'video' || test.video(name)),
338
+ isImage: item.name ? test.image(item.name) : (this.accept === 'image' || test.image(name)),
339
+ isVideo: item.name ? test.video(item.name) : (this.accept === 'video' || test.video(name)),
339
340
  deletable: typeof item.deletable === 'boolean' ? item.deletable : this.deletable,
340
341
  })
341
342
  });
@@ -349,31 +350,25 @@
349
350
  lists,
350
351
  disabled
351
352
  } = this;
352
- if (disabled) return;
353
- // 如果用户传入的是字符串,需要格式化成数组
354
- let capture;
355
- try {
356
- capture = test.array(this.capture) ? this.capture : this.capture.split(',');
357
- }catch(e) {
358
- capture = [];
359
- }
360
- chooseFile(
361
- Object.assign({
362
- accept: this.accept,
363
- extension: this.extension,
364
- multiple: this.multiple,
365
- capture: this.capture,
366
- compressed: this.compressed,
367
- maxDuration: this.maxDuration,
368
- sizeType: this.sizeType,
369
- camera: this.camera,
370
- }, {
371
- maxCount: maxCount - lists.length,
372
- ...params
373
- })
374
- )
353
+ if (disabled) return Promise.reject();
354
+ const chooseParams = Object.assign({
355
+ accept: this.accept,
356
+ extension: this.extension,
357
+ multiple: this.multiple,
358
+ capture: this.capture,
359
+ compressed: this.compressed,
360
+ maxDuration: this.maxDuration,
361
+ sizeType: this.sizeType,
362
+ camera: this.camera,
363
+ }, {
364
+ maxCount: maxCount - lists.length,
365
+ ...params
366
+ })
367
+ return chooseFile(chooseParams)
375
368
  .then((res) => {
376
- this.onBeforeRead(multiple ? res : res[0]);
369
+ const result = chooseParams.multiple ? res : res[0]
370
+ this.onBeforeRead(result);
371
+ return result
377
372
  })
378
373
  .catch((error) => {
379
374
  this.$emit('error', error);
@@ -385,7 +380,7 @@
385
380
  beforeRead,
386
381
  useBeforeRead,
387
382
  } = this;
388
- let res = true
383
+ let res = file
389
384
  // beforeRead是否为一个方法
390
385
  if (test.func(beforeRead)) {
391
386
  // 如果用户定义了此方法,则去执行此方法,并传入读取的文件回调
@@ -405,13 +400,10 @@
405
400
  );
406
401
  });
407
402
  }
408
- if (!res) {
409
- return;
410
- }
411
403
  if (test.promise(res)) {
412
404
  res.then((data) => this.onAfterRead(data || file));
413
405
  } else {
414
- this.onAfterRead(res);
406
+ this.onAfterRead(res || file);
415
407
  }
416
408
  },
417
409
  getDetail(index) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.4.22",
5
+ "version": "3.4.24",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
7
7
  "keywords": [
8
8
  "uview",
@@ -89,6 +89,11 @@ declare interface SearchProps {
89
89
  * @default "search"
90
90
  */
91
91
  searchIcon?: string
92
+ /**
93
+ * 输入框图标位置,left-左边,right-右边
94
+ * @default "left"
95
+ */
96
+ iconPosition?: 'left' | 'right'
92
97
  /**
93
98
  * 组件与其他上下左右元素之间的距离,带单位的字符串形式,如"30rpx"、"30rpx 20rpx"等写法
94
99
  * @default "0"
@@ -1,6 +1,33 @@
1
1
  import { AllowedComponentProps, VNodeProps } from './_common'
2
2
  import { ImageMode } from './image';
3
3
 
4
+ type BaseFileInfo = {
5
+ type: string
6
+ url: string
7
+ name: string
8
+ size: number
9
+ file: File
10
+ [key: string]: any
11
+ }
12
+
13
+ type ImageFileInfo = BaseFileInfo & {
14
+ type: 'image'
15
+ thumb: string
16
+ }
17
+
18
+ type VideoFileInfo = BaseFileInfo & {
19
+ type: 'video'
20
+ thumb: string
21
+ width: number
22
+ height: number
23
+ }
24
+
25
+ type MediaFileInfo = BaseFileInfo & {
26
+ thumb: string
27
+ }
28
+
29
+ type FileInfo = BaseFileInfo | ImageFileInfo | VideoFileInfo | MediaFileInfo
30
+
4
31
  declare interface UploadProps {
5
32
  /**
6
33
  * 接受的文件类型,file只支持H5(只有微信小程序才支持把accept配置为all、media)
@@ -12,6 +39,10 @@ declare interface UploadProps {
12
39
  * @default ["album", "camera"]
13
40
  */
14
41
  capture?: 'album' | 'camera' | ('album' | 'camera')[]
42
+ /**
43
+ * 选择文件的后缀名,暂只支持.zip、.png等,不支持application/msword等值
44
+ */
45
+ extension?: string [];
15
46
  /**
16
47
  * 当accept为video时生效,是否压缩视频,默认为true
17
48
  * @default true
@@ -131,6 +162,11 @@ declare interface UploadProps {
131
162
  onDelete?: (index, file, name) => any
132
163
  }
133
164
 
165
+ type ChooseFileParams = Pick<
166
+ UploadProps,
167
+ 'accept' | 'multiple' | 'capture' | 'compressed' | 'maxDuration' | 'sizeType' | 'camera' | 'maxCount' | 'extension'
168
+ >;
169
+
134
170
  declare interface UploadSlots {
135
171
  /**
136
172
  * 自定义上传样式
@@ -147,6 +183,11 @@ declare interface _UploadRef {
147
183
  * 读取前的处理函数
148
184
  */
149
185
  beforeRead: (file, lists, name) => any
186
+ /**
187
+ * 触发文件选择器
188
+ */
189
+ chooseFile(params: ChooseFileParams & { multiple: true }): Promise<FileInfo[]>;
190
+ chooseFile(params?: ChooseFileParams & { multiple?: false }): Promise<FileInfo>;
150
191
  }
151
192
 
152
193
  declare interface _Upload {