'f'
mh-two-thousand-and-two
2024-04-12 26f2711ef9461961fb953e2b497bd314ef95e345
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const MEDIA_TYPE = ['all', 'image', 'video']
const SOURCE_TYPES = ['album', 'camera']
 
export const chooseFile = {
  count: {
    type: Number,
    required: false,
    default: 100,
    validator (count, params) {
      if (count <= 0) {
        params.count = 100
      }
    }
  },
  sourceType: {
    type: Array,
    required: false,
    default: SOURCE_TYPES,
    validator (sourceType, params) {
      sourceType = sourceType.filter(sourceType => SOURCE_TYPES.includes(sourceType))
      params.sourceType = sourceType.length ? sourceType : SOURCE_TYPES
    }
  },
  type: {
    type: String,
    required: false,
    default: 'all',
    validator (type, params) {
      if (!MEDIA_TYPE.includes(type)) params.type = MEDIA_TYPE[0]
      params.type = params.type === 'all' ? params.type = '*' : params.type
    }
  },
  extension: {
    type: Array,
    default: [''],
    validator (extension, params) {
      if (extension.length === 0) { return 'param extension should not be empty.' }
    }
  }
}