安装
| 用途 | 要求 |
|---|---|
| 构建库(必需) | Rust 1.70+,2021 edition |
| 运行 Python 示例 | Python ≥ 3.9,无需第三方依赖(ctypes 为标准库) |
| 运行 Node.js 示例 | Node ≥ 16,且已 npm install koffi |
| Linux 会话 | 一个可用的 D-Bus 会话总线(桌面环境默认提供) |
| Windows | Windows 10 / 11 |
方式零:沿用 SDK 自带的 Python / Node.js 绑定
Section titled “方式零:沿用 SDK 自带的 Python / Node.js 绑定”无需 pip install——Python 绑定只依赖标准库 ctypes,把 examples/python/ 加入路径即可;Node.js 绑定基于 koffi,在 examples/nodejs/ 下执行 npm install 即可,不涉及 node-gyp 或原生编译步骤。
方式一:从源码构建
Section titled “方式一:从源码构建”git clone https://github.com/UniDesktop/SDK.gitcd SDK
# 构建 C-ABI 共享库(Python / Node.js SDK 加载的目标)cargo build -p uda-ffi
# 发布版本cargo build -p uda-ffi --release产物位置:
| 平台 | 文件名 |
|---|---|
| Linux | libuda_ffi.so |
| Windows | uda_ffi.dll |
方式二:下载预编译产物
Section titled “方式二:下载预编译产物”从 Releases 页面下载对应平台的压缩包,内含共享库与 include/uda.h。
方式三:作为子模块集成
Section titled “方式三:作为子模块集成”git submodule add https://github.com/UniDesktop/SDK.git third_party/uda然后在你的 Cargo.toml 中按平台引入实现 crate:
uda-core = { path = "third_party/uda/crates/uda-core" }
[target.'cfg(windows)'.dependencies]uda-platform-windows = { path = "third_party/uda/crates/uda-platform-windows" }
[target.'cfg(unix)'.dependencies]uda-platform-linux = { path = "third_party/uda/crates/uda-platform-linux" }跑第一个示例,它只读取系统外观,无任何副作用:
cargo build -p uda-ffipython3 examples/python/01_appearance.py预期输出当前深浅色,以及平台支持时返回的强调色。若提示找不到动态库,见故障排查。
Linux 运行时依赖
Section titled “Linux 运行时依赖”| 功能 | 依赖 |
|---|---|
| 所有 D-Bus 功能 | dbus(会话总线必须可达) |
| Portal 功能(外观) | xdg-desktop-portal |
| 通知 | 任一 org.freedesktop.Notifications 实现(dunst、mako 等) |
| 系统托盘 | StatusNotifierWatcher——GNOME 需要 AppIndicator 扩展 |
| X11 壁纸 | feh 或 nitrogen(仅在无 DE IPC 时) |
以上均非硬依赖:UDA 会逐项探测,全部缺失时返回类型化错误。
Windows 运行时依赖
Section titled “Windows 运行时依赖”除 Windows 10 / 11 本身外无其他依赖。toast、托盘、媒体与电源均使用平台内置 API,未打包进程所需的 AppUserModelID 也由 UDA 自行注册。
