uview-plus 3.4.22 → 3.4.23
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.
|
@@ -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
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
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);
|
|
@@ -411,7 +406,7 @@
|
|
|
411
406
|
if (test.promise(res)) {
|
|
412
407
|
res.then((data) => this.onAfterRead(data || file));
|
|
413
408
|
} else {
|
|
414
|
-
this.onAfterRead(
|
|
409
|
+
this.onAfterRead(file);
|
|
415
410
|
}
|
|
416
411
|
},
|
|
417
412
|
getDetail(index) {
|
package/package.json
CHANGED
package/types/comps/search.d.ts
CHANGED
|
@@ -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"
|
package/types/comps/upload.d.ts
CHANGED
|
@@ -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 {
|