用纯 Go 写桌面界面,不需要 HTML、CSS、JavaScript 或 WebView。界面由 Gio 绘制;Gio 没有的原生能力(权限、截图、合成输入、全局快捷键)在 native/ 下。
type hello struct {
name *kit.InputView
result string
}
func (h *hello) Render(cx *el.Context) el.Element {
return el.Div().P(24).Gap(12).Child(
h.name.Render(cx),
el.Div().Row().Child(kit.Button("打招呼", func() { h.result = "你好," + h.name.Value() }).Render(cx)),
el.Text(h.result),
)
}
window.Open(window.Options{Title: "Hello", Content: el.Root(&hello{name: kit.Input("你的名字")})})
window.Main()
go run ./examples/hello
go run ./examples/multiwindow
go run ./examples/hotkey
go run ./examples/chat -sample=all
go run ./examples/components # 组件库:侧栏选择、搜索
go test -race ./...
需要 Go 1.26+;macOS 上需要 Xcode Command Line Tools。
模块
| 模块 | 做什么 |
|---|---|
| ui/core | 地基:Widget 接口、回调、线程规则 |
| ui/theme | 颜色、字号、字体 |
| ui/locale | 框架文字,中英文切换 |
| ui/el | GPUI 风格:视图 + 链式样式元素 + flexbox |
| ui/kit | 组件:Button、Input、Table、Dialog、Chart … |
| ui/window | 窗口:Open、Main、快捷键、截图 |
| ui/markdown | Markdown 渲染,针对 AI 流式输出优化 |
| native/permission | 检查、申请系统权限 |
| native/screen | 显示器列表、截图 |
| native/input | 合成鼠标、键盘事件 |
| native/hotkey | 全局快捷键 |
另有工具 cmd/keel-mcp:MCP server,让 Agent 对应用做端到端测试(启动、读元素、点击、输入、滚动、截图),见 Agent 端到端测试。
依赖只往下走、同层不互相引用,ui 和 native 互不依赖,由 go test ./... 里的边界测试保证。每个模块目录下有 README。总览见 ui/README.md 和 native/README.md。
文档
完整文档在 docs/: