-
Notifications
You must be signed in to change notification settings - Fork 391
Expand file tree
/
Copy pathcamera.js
More file actions
106 lines (103 loc) · 3.2 KB
/
camera.js
File metadata and controls
106 lines (103 loc) · 3.2 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const { isMustache } = require('../../../../utils/string')
const TAG_NAME = 'camera'
module.exports = function ({ print }) {
const ttValueLogError = print({ platform: 'bytedance', tag: TAG_NAME, isError: true, type: 'value' })
const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
const baiduValueLogError = print({ platform: 'baidu', tag: TAG_NAME, isError: true, type: 'value' })
const baiduEventLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
const qqValueLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'value' })
const qqPropLog = print({ platform: 'qq', tag: TAG_NAME, isError: false })
const qqEventLog = print({ platform: 'qq', tag: TAG_NAME, isError: false, type: 'event' })
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
const qaEventLog = print({ platform: 'qa', tag: TAG_NAME, isError: false, type: 'event' })
const ksPropLog = print({ platform: 'ks', tag: TAG_NAME, isError: false })
const ksEventLog = print({ platform: 'ks', tag: TAG_NAME, isError: false, type: 'event' })
return {
test: TAG_NAME,
ios (tag, { el }) {
el.isBuiltIn = true
return 'mpx-camera'
},
android (tag, { el }) {
el.isBuiltIn = true
return 'mpx-camera'
},
harmony (tag, { el }) {
el.isBuiltIn = true
return 'mpx-camera'
},
props: [
{
test: 'mode',
swan ({ name, value }) {
// 百度只有相机模式,也就是微信的mode=normal
if (value !== 'normal') {
baiduValueLogError({ name, value })
}
return false
},
tt ({ name, value }) {
if (value !== 'normal') {
ttValueLogError({ name, value })
}
return false
},
qa: qaPropLog
},
{
test: 'flash',
qq ({ name, value }) {
const supportList = ['auto', 'on', 'off']
if (isMustache(value) || supportList.indexOf(value) === -1) {
// 如果是个变量,或者是不支持的属性值,报warning
qqValueLog({ name, value })
}
},
tt: ttPropLog
},
{
test: /^(resolution|frame-size)$/,
qq: qqPropLog,
ks: ksPropLog
},
{
test: /^(frame-size|device-position)$/,
qa (prop) {
const propsMap = {
'device-position': 'deviceposition',
'frame-size': 'framesize'
}
prop.name = propsMap[prop.name]
if (prop.name === 'framesize') {
const valueMap = {
small: 'low',
medium: 'medium',
large: 'high'
}
prop.value = valueMap[prop.value]
}
return prop
}
}
],
event: [
{
test: /^(scancode)$/,
swan: baiduEventLog,
tt: ttEventLog,
qa: qaEventLog,
ks: ksEventLog
},
{
test: /^(initdone)$/,
qq: qqEventLog,
ks: ksEventLog
},
{
test: /^(stop|error)$/,
ks: ksEventLog
}
]
}
}