libyue 的 MoonBit 封装:统一跨平台 GUI 库,👏Windows - win 32、👏Linux - GTK、‼️Mac - Cocoa
| # | Stack | Typical code | For |
|---|---|---|---|
| 1 | Themed component library + declarative + reactive | button_t / side_menu / tag / alert … nodes bound to Store | Modern app shells — recommended |
| 2 | Native libyue widgets + declarative + reactive | button / entry / slider … nodes + Store bindings | Native look with declarative code |
| 3 | Native libyue widgets + imperative | Window::new + set_content + setters | Close to the raw libyue API |





sudo apt install build-essential cmake pkg-config \
libgtk-3-dev libpango1.0-dev libfontconfig1-dev libx11-dev \
libwebkit2gtk-4.1-devmoon run examples/helloirm https://cli.moonbitlang.com/install/powershell.ps1 | iexwinget install Kitware.CMake
winget install Microsoft.VisualStudio.2022.BuildTools -e --override "--quiet --wait --norestart --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe' -ArgumentList 'modify','--installPath','"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"','--add','Microsoft.VisualStudio.Component.VC.ATL','--quiet','--norestart' -Verb RunAs -Waitcall "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
python3 scripts\prepare.py
moon run examples/hellomoon add NoahLiu/moonbit-libyue
moon run srcfn main {
if !@yue.initialize() {
return
}
let window = @yue.mount_window(
[
@yue.label("Hello, MoonBit + libyue!", style=[("margin", 20.0)]),
@yue.button("Quit", on_click=fn() { @yue.quit() }),
],
title="Hello",
size=Some((420.0, 160.0)),
center=true,
on_close=fn(_w) { @yue.quit() },
)
window.activate()
@yue.run()
}
let clicks : @yue.Store[Int] = @yue.Store::new(0)
let window = @yue.mount_window(
[
@yue.vbox(
[
@yue.button("Click me", on_click=fn() { clicks.update(fn(n) { n + 1 }) }),
@yue.bind_label(clicks, fn(n) { "Clicked \{n} times" }),
],
style=[("padding", 24.0)],
),
],
title="Counter",
size=Some((320.0, 160.0)),
center=true,
on_close=fn(_w) { @yue.quit() },
)
| Document | Content |
|---|---|
| components-ui.md | Themed component library API with demo screenshots |
| declarative.md | Declarative Node/mount trees + Store reactive bindings |
| components.md | Widget API quick reference: classic setters and X::make props styles |
| layout.md | Layout style keys (Yoga flexbox) |
| adaptation.md | Platform pitfalls, root causes and verification conclusions |
| tray.md | Linux tray: SNI protocol stack design and backend fallback |
| relink.md | Forcing a relink after native-layer changes |
Install
Download ziplibyue 的 MoonBit 封装:统一跨平台 GUI 库,👏Windows - win 32、👏Linux - GTK、‼️Mac - Cocoa