MyGo 原生 UI 的 Go 组件库:1501 个组件,分 39 类,每类一个包。沿用 MyGo 自己的外观:锌灰底色,跟随系统的强调色,6 DIP 圆角,4 DIP 间距单位,系统字体。每个组件都会动,每个可交互组件都有合成音效。
界面由 MyGo 在 GPU 上自绘,不用 HTML、JavaScript 或 WebView。
go get github.com/ELY-Open-Source/CrychicUI要求 Go 1.27.3 与 MyGo v0.8.3。
组件是函数:第一个参数是 *ui.Context,返回 ui.Element;可选项放在最后的 NameOptions 里。容器把内容作为最后一个 func(),放在选项之后。有多个动作的组件返回多个命名的 ui.Element,root 在前,例如 button.SplitButton。
import (
"github.com/ELY-Open-Source/CrychicUI/button"
"github.com/egoist/mygo/ui"
)
func view(c *ui.Context) {
if button.Solid(c, "Save").Clicked() {
save() // 按钮已经播放了自己的音效
}
}| 类 | 包 | 数量 |
|---|---|---|
| Layout | layout |
50 |
| Typography | typography |
40 |
| Button | button |
45 |
| Display | display |
55 |
| Input | input |
55 |
| Choice | choice |
50 |
| Feedback | feedback |
55 |
| Motion | motion |
55 |
| Effects | fx |
45 |
| Form | form |
40 |
| Date & Time | datetime |
45 |
| Color | color |
20 |
| Navigation | navigation |
55 |
| Overlay | overlay |
45 |
| Data | data |
55 |
| Chart | chart |
60 |
| Media | media |
45 |
| Chat | chat |
45 |
| Agent | agent |
40 |
| Code | code |
40 |
| Files | files |
35 |
| Shop | shop |
40 |
| Finance | finance |
40 |
| Dashboard | dashboard |
35 |
| Schedule | schedule |
30 |
| Project | project |
40 |
mail |
30 | |
| Social | social |
35 |
| Account | account |
40 |
| Devtools | devtools |
35 |
| Game | game |
30 |
| Learn | learn |
20 |
| Health | health |
20 |
| Home | home |
20 |
| Marketing | marketing |
40 |
| Content | content |
25 |
| Desktop | desktop |
30 |
| Geo | geo |
15 |
| Diagram | diagram |
1 |
sound、icon、kit 是组件共用的底层包。
diagram.Mermaid 把 Mermaid 源码画成主题色的图:流程图、时序图、饼图等 33 种。图按自身尺寸显示,容器窄时等比缩小;源码有错时显示 Pele 的报错和行列号。
diagram.Mermaid(c, "flowchart LR\n Wedge[Wedge clay] --> Throw[Throw]", diagram.MermaidOptions{})引擎是 pele-go(Pele 的 Go 移植,MIT)。只有导入 diagram 的程序才链接它,体积增加约 6 MB。链接、远程图片和数学公式不绘制。
可交互组件在动作时播放一个音效,默认开启。音效在 sound 包里合成,不读音频文件。
sound.SetEnabled(false) // 全部静音
sound.SetVolume(0.5)go run ./cmd/gallery同一个程序编译成 WebAssembly,就是网站:https://crychicui.zhangyanghaha0407.workers.dev
go vet ./... && go tool mygo vet . && go test ./...
GOOS=js GOARCH=wasm go vet ./...
cd web && npm install && npm test # 构建 web/dist,Playwright 本地跑网站检查需要 Node 22+(Wrangler 的要求)、PATH 里的 python3(本地测试服务器),以及一次 npx playwright install chromium。
npm run deploy(在 web/ 里)先在预览地址测试新版,再切到线上并重测。
MIT。第三方声明见 THIRD_PARTY_NOTICES.md。