libyue 的 MoonBit 封装:统一跨平台 GUI API,平台差异由库内部吸收,消费方无感

@yue.theme_apply({ ..@yue.default_theme(), primary: "#1E4FA3" })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() },
)let clicks = @yue.Signal::new(0)
@yue.button("Click me", on_click=fn() { clicks.update(fn(n) { n + 1 }) }),
@yue.bind(clicks, fn(n) { "Clicked \{n} times" }), // derived text, updates on click# Ubuntu 24.04: one-time system dependencies (GTK/WebKit dev packages)
sudo apt install build-essential cmake pkg-config \
libgtk-3-dev libpango1.0-dev libfontconfig1-dev libx11-dev libwebkit2gtk-4.1-dev
# As a dependency: prebuilt native libraries ship with the package — zero C++ compilation
moon add NoahLiu/moonbit-libyue
moon run src
# Run the demo board
git clone https://github.com/lb091188/moonbit-libyue && cd moonbit-libyue
moon run examples/showcaseirm https://cli.moonbitlang.com/install/powershell.ps1 | iex # MoonBit
winget install Kitware.CMake
winget install Microsoft.VisualStudio.2022.BuildTools -e --override "--quiet --wait --norestart --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
# Add the ATL component:
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 -Wait| Layer | Style | Best for |
|---|---|---|
| 1 | Themed library + declarative + reactive: button_t / side_menu / tag … nodes + Store bindings | Modern app shells, recommended |
| 2 | libyue native widgets + declarative + reactive: button / entry / slider … nodes + Store bindings | Native look with declarative code |
| 3 | libyue native widgets + imperative: Window::new + set_content + setters | Closest to raw libyue |
moon run examples/hello # minimal native-widget window
moon run examples/hello-themed # themed minimal example (theme_apply + button_t/input_t/label_t)
moon run examples/showcase # full demo board: 15 pages, 3 collapsible side-menu groups
| Doc | Content |
|---|---|
| components-ui.md | Themed component library API + theme customization |
| 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 API,平台差异由库内部吸收,消费方无感