提交 825345e2 编写于 作者: Q qiang

fix: 优化 uni.chooseVideo 参数校验

上级 ef2fcc21
......@@ -6,17 +6,16 @@ export const chooseVideo = {
required: false,
default: SOURCE_TYPES,
validator (sourceType, params) {
const length = sourceType.length
if (!length) {
params.sourceType = SOURCE_TYPES
} else {
for (let i = 0; i < length; i++) {
if (typeof sourceType[i] !== 'string' || !~SOURCE_TYPES.indexOf(sourceType[i])) {
params.sourceType = SOURCE_TYPES
break
}
}
}
sourceType = sourceType.filter(sourceType => SOURCE_TYPES.includes(sourceType))
params.sourceType = sourceType.length ? sourceType : SOURCE_TYPES
}
},
maxDuration: {
type: Number,
default: 60
},
camera: {
type: String,
default: 'back'
}
}
}
......@@ -11,9 +11,9 @@ import {
} from '../util'
export function chooseVideo ({
sourceType = ['album', 'camera'],
maxDuration = 60,
camera = 'back'
sourceType,
maxDuration,
camera
} = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'chooseVideo', 'cancel')
......@@ -53,10 +53,10 @@ export function chooseVideo ({
}
if (sourceType.length === 1) {
if (sourceType[0] === 'album') {
if (sourceType.includes('album')) {
openAlbum()
return
} else if (sourceType[0] === 'camera') {
} else if (sourceType.includes('camera')) {
openCamera()
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册