bricks/dist/docs/en/camera.md
yumoqing 2e22085122 feat: 401后登录成功自动重试原始请求
- withLoginInfo 改为接收完整 opts(含 method/headers/params)
- 等待 login_window 的 destroy 事件(=登录成功信号)
- 登录成功后重试原始请求
- 重试仍401则返回null(避免死循环)
- 用户手动关闭登录窗口时也触发重试,401则返回null
2026-05-27 15:39:34 +08:00

26 lines
1.4 KiB
Markdown

# Camera
**Widget Functionality**: Used to access the device's camera for taking photos or recording videos. Supports features such as switching cameras, starting/stopping video recording, and capturing photos.
**Type**: Standard widget (an extension based on `Popup`)
**Parent Widget**: `bricks.Popup`
## Initialization Parameters
| Parameter | Type | Description |
|---------|------|-------------|
| `fps` | Number | Frame rate for video capture; default is 60 FPS |
| `type` | String | Widget mode; allowed values are `'picture'` (photo mode) or `'recorder'` (video recording mode) |
| `auto_dismiss` | Boolean | Whether the popup should automatically close; default is `false` (explicitly set in code) |
> **Note**: `opts.auto_dismiss = false;` is forcibly set within the constructor.
## Main Events
| Event | Trigger Condition | Data Carried |
|------|-------------------|------------|
| `shot` | Triggered when the user clicks the capture button | The captured image data URL (JPEG image in base64 format) |
| `recorded` | Triggered when video recording ends | The recorded video file object (`File` type, WebM format) |
> **Explanation**:
> - When `type='picture'`, clicking the capture button triggers the `shot` event and returns the captured image data.
> - When `type='recorder'`, clicking the record button starts or stops recording. After stopping, the `recorded` event is triggered and returns the recorded video file.