bricks/docs/ai/countdown.md
2025-11-18 16:01:43 +08:00

37 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TimePassed
控件功能:显示自计时开始以来经过的时间(以时:分:秒格式展示),每秒自动更新一次。
类型:普通控件
父类控件bricks.VBox
## 初始化参数
- `opts`:继承自 VBox 的选项对象,无特殊参数。
- 控件内部初始化时从零秒开始计时,并通过 `bricks.formatTime` 格式化时间显示。
## 主要事件
- 无自定义事件触发。
- 内部使用 `schedule_once` 实现周期性更新,但不对外派发事件。
---
# Countdown
控件功能:实现一个倒计时控件,支持设定初始时间(如 "01:00:00"),启动后每秒递减并更新显示,倒计时结束时触发 `timeout` 事件。
类型:普通控件
父类控件bricks.VBox
## 初始化参数
- `opts.limit_time`:字符串类型,表示倒计时的总时间,格式为 `"HH:MM:SS"``"MM:SS"``"SS"`
- 示例:
- `"30"` → 30 秒
- `"01:30"` → 1 分 30 秒
- `"01:00:00"` → 1 小时
- `opts.text_rate`:可选参数,用于设置文本显示刷新率(若底层 Text 控件支持)。
## 主要事件
- `timeout`:当倒计时归零时,控件会调用 `this.dispatch('timeout')` 派发该事件,可用于通知外部逻辑执行后续操作。