Documentation
¶
Index ¶
- func CreateQRCodeImage(text string, size int, filename string) error
- func ShowQRCodeFromText(text string, timeout time.Duration, width int, successChan <-chan bool, ...) error
- func ShowQRCodeWithCallback(imageURL string, timeout time.Duration, successChan <-chan bool, ...) error
- func ShowQRCodeWithLipgloss(imageURL string, timeout time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShowQRCodeFromText ¶ added in v0.0.9
func ShowQRCodeFromText(text string, timeout time.Duration, width int, successChan <-chan bool, cancelChan chan<- bool, timeoutChan chan<- bool) error
ShowQRCodeFromText 从文本内容本地生成 QR 码并通过 Bubble Tea 展示。
设计说明(D-06, D-07, D-08): - 完全本地生成,不发起 HTTP 请求 - 支持 --width 参数控制显示宽度 - 支持自动终端检测(width=0 时) - 保留与 ShowQRCodeWithCallback 相同的 channel 通信接口 - 支持 Kitty/iTerm2 图片协议,不支持时降级到半块字符
渲染流程: 1. 检测终端图片协议 2. 如果支持 Kitty/iTerm2:
- 生成 QR 码图片
- 在 Bubble Tea 之前显示图片
- 启动 Bubble Tea 只处理倒计时
3. 如果不支持:
- 降级到半块字符渲染
- 启动 Bubble Tea 处理倒计时和字符渲染
参数: - text: QR 码内容(通常是登录 URL) - timeout: 二维码显示超时时间 - width: 目标显示宽度(列数),0 表示自动检测 - successChan: 接收登录成功通知的 channel - cancelChan: 发送用户取消通知的 channel - timeoutChan: 发送超时通知的 channel
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.