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

fix: 优化 uni.chooseVideo 参数校验

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