1 | import { ComponentType } from 'react'
|
2 | import { StandardProps, CommonEventFunction } from './common'
|
3 | interface CameraProps extends StandardProps {
|
4 | /** 模式,有效值为normal, scanCode
|
5 | * @default "normal"
|
6 | * @supported weapp, alipay, tt, qq, jd, rn
|
7 | */
|
8 | mode?: keyof CameraProps.Mode
|
9 |
|
10 | /** 分辨率,不支持动态修改
|
11 | * @default "medium"
|
12 | * @supported weapp, tt
|
13 | */
|
14 | resolution?: keyof CameraProps.Resolution
|
15 |
|
16 | /** 摄像头朝向
|
17 | * @default "back"
|
18 | * @supported weapp, alipay, swan, tt, qq, jd, rn
|
19 | */
|
20 | devicePosition?: keyof CameraProps.DevicePosition
|
21 |
|
22 | /** 闪光灯
|
23 | * @default "auto"
|
24 | * @supported weapp, alipay, swan, tt, qq, jd, rn
|
25 | */
|
26 | flash?: keyof CameraProps.Flash
|
27 |
|
28 | /** 指定期望的相机帧数据尺寸
|
29 | * @default "medium"
|
30 | * @supported weapp, alipay, tt
|
31 | */
|
32 | frameSize?: keyof CameraProps.FrameSize
|
33 |
|
34 | /** 相机拍照,录制的分辨率。
|
35 | * @supported alipay
|
36 | * @default "720P"
|
37 | */
|
38 | outputDimension?: '360P' | '540P' | '720P' | '1080P' | 'max'
|
39 |
|
40 | /** 摄像头在非正常终止时触发,
|
41 | * 如退出后台等情况
|
42 | * @supported weapp, alipay, swan, tt, qq, jd, rn
|
43 | */
|
44 | onStop?: CommonEventFunction
|
45 |
|
46 | /** 用户不允许使用摄像头时触发
|
47 | * @supported weapp, alipay, swan, tt, qq, jd, rn
|
48 | */
|
49 | onError?: CommonEventFunction
|
50 |
|
51 | /** 相机初始化完成时触发
|
52 | * @supported weapp, tt, rn
|
53 | */
|
54 | onInitDone?: CommonEventFunction<CameraProps.onInitDoneEventDetail>
|
55 |
|
56 | /** 相机初始化成功时触发。
|
57 | * @supported alipay
|
58 | */
|
59 | onReady?: CommonEventFunction<CameraProps.onInitDoneEventDetail>
|
60 |
|
61 | /** 在成功识别到一维码时触发,
|
62 | * 仅在 mode="scanCode" 时生效
|
63 | * @supported weapp, alipay, tt, qq, rn
|
64 | */
|
65 | onScanCode?: CommonEventFunction<CameraProps.onScanCodeEventDetail>
|
66 | }
|
67 | declare namespace CameraProps {
|
68 | /** mode 的合法值 */
|
69 | interface Mode {
|
70 | /** 相机模式 */
|
71 | normal
|
72 |
|
73 | /** 扫码模式 */
|
74 | scanCode
|
75 | }
|
76 |
|
77 | /** resolution 的合法值 */
|
78 | interface Resolution {
|
79 | /** 低 */
|
80 | low
|
81 |
|
82 | /** 中 */
|
83 | medium
|
84 |
|
85 | /** 高 */
|
86 | high
|
87 | }
|
88 |
|
89 | /** device-position 的合法值 */
|
90 | interface DevicePosition {
|
91 | /** 前置 */
|
92 | front
|
93 |
|
94 | /** 后置 */
|
95 | back
|
96 | }
|
97 |
|
98 | /** flash 的合法值 */
|
99 | interface Flash {
|
100 | /** 自动 */
|
101 | auto
|
102 |
|
103 | /** 打开 */
|
104 | on
|
105 |
|
106 | /** 关闭 */
|
107 | off
|
108 |
|
109 | /** 常亮 */
|
110 | torch
|
111 | }
|
112 |
|
113 | /** frame-size 的合法值 */
|
114 | interface FrameSize {
|
115 | /** 小尺寸帧数据 */
|
116 | small
|
117 |
|
118 | /** 中尺寸帧数据 */
|
119 | medium
|
120 |
|
121 | /** 大尺寸帧数据 */
|
122 | large
|
123 | }
|
124 | interface onInitDoneEventDetail {
|
125 | /** 最大变焦 */
|
126 | maxZoom: number
|
127 | }
|
128 | interface onScanCodeEventDetail {
|
129 | /** 字符集 */
|
130 | charSet: string
|
131 |
|
132 | /** 原始数据
|
133 | * @supported weapp
|
134 | */
|
135 | rawData: string
|
136 |
|
137 | /** 码类型 */
|
138 | type: string
|
139 |
|
140 | /** 识别结果 */
|
141 | result: string
|
142 |
|
143 | /** 识别结果(完整)
|
144 | * @supported alipay
|
145 | */
|
146 | fullResult: string
|
147 | }
|
148 | }
|
149 |
|
150 | /** 系统相机
|
151 | * @classification media
|
152 | * @supported weapp, alipay, swan, tt, qq, jd, rn, harmony
|
153 | * @see https://developers.weixin.qq.com/miniprogram/dev/component/camera.html
|
154 | */
|
155 | declare const Camera: ComponentType<CameraProps>
|
156 | export { Camera, CameraProps }
|