ThoughtChain 思考链
AI 对话组件。公开入口:ThoughtChain。
在线演示
本页复用官方 Go gallery 的真实示例。下方可以切换场景、主题和深浅色;长页面支持滚动,复杂布局可以横向滚动或在独立页面打开。
ThoughtChain 思考链 · 在线体验真实 Go 组件
在独立页面打开 ↗示例代码
以下是上方在线演示运行的 Go 源码(来自官方 gallery),点击标题展开。函数接收的 c *ui.Context 由窗口的 UI 循环每帧传入,接入方式见 Go GUI 入门。
API
签名与说明由 site/tools/compdoc 从 Go 源码和文档注释提取;点击名称跳到 Go API 参考 的对应条目。
入口函数
ui.ThoughtChain
go
func ThoughtChain(c *Context, items []ChainItem) *ThoughtChainWThoughtChain adds a chain of steps.
ui.ThoughtChain(c, steps).Title("思考过程").Card()
返回 *ThoughtChainW,可链式调用的方法见 ThoughtChainW 方法。
ThoughtChainW 方法
ui.ThoughtChainW:ThoughtChainW is a vertical chain of steps with status icons, durations and collapsible details, optionally under a collapsible title.
| 方法 | 说明 | 签名 |
|---|---|---|
Card | Card draws the chain inside a bordered card. | Card() *ThoughtChainW |
DefaultCollapsed | DefaultCollapsed starts with the steps hidden (needs Title). | DefaultCollapsed() *ThoughtChainW |
Expanded | Expanded reports whether the steps are shown. | Expanded() bool |
ItemToggled | ItemToggled returns the key of the step whose detail was opened or closed this frame. | ItemToggled() (string, bool) |
Layout | Layout applies layout options to the chain. | Layout(opts ...layout.Option) *ThoughtChainW |
Title | Title adds a header that collapses the chain and shows its progress. | Title(s string) *ThoughtChainW |
Toggled | Toggled reports a click on the title this frame. | Toggled() bool |
ChainItem 参数类型
ui.ChainItem:ChainItem is one step of a ThoughtChain.
| 字段 | 说明 | 类型 |
|---|---|---|
Key | stable key (default: the index) | string |
Title | string | |
Description | secondary line under the title | string |
Status | ChainStatus | |
Duration | shown at the end (0: hidden) | time.Duration |
Started | a running step shows the time elapsed since then | time.Time |
Detail | collapsible Markdown detail | string |
Content | collapsible custom detail (instead of Detail) | func() |
相关链接
本页由完整组件表、实际 gallery 注册信息和 Go 源码(site/tools/compdoc)生成;新增组件未接入演示时,文档构建会报错。场景中的表单、表格、图表和移动端屏幕使用示例数据。