KennethCheng ac5d0cb1d0 feat(windows): Phase 6 C1 — 单实例 mutex + HKCU Run 启动项
- src/windows/mod.rs: cfg(windows) 模块入口,pub use single_
  instance + startup;其他 Phase 6 模块(C2 托盘 / C3 Toast / URL
  打开)在后续 commit 加
- src/windows/single_instance.rs: CreateMutexExW("Local\\...")
  → mutex 名称 user-scope(多 RDP 会话各自能跑一个实例);第
  二参 bInitialOwner=true 让 GetLastError() 可靠;返回 Acquired
  / AlreadyRunning enum
- src/windows/startup.rs: HKCU\Software\Microsoft\Windows\
  CurrentVersion\Run\WindowsGotifyClientRust = 当前 exe 路径;set_
  enabled / is_enabled 接口给 C2 Settings toggle 留口子;自定义
  Win32Error 类型(windows-sys 0.59 没有 core::Error)
- src/lib.rs: 加 #[cfg(windows)] pub mod windows 入口
- src/main.rs: 启动前 enforce_single_instance() 检查;已有实
  例直接 std::process::exit(0)(不抢前台窗口,留给 C2 tray
  拿 hwnd 后再做)
- Cargo.toml: windows-sys 0.59 features 加 Win32 / Win32_Security
  / Win32_Foundation / Win32_System_Threading / Win32_System_
  Registry / Win32_UI_WindowsAndMessaging / Win32_UI_Shell

避坑:
- windows-sys 0.59 没有 CreateMutexW(只是宏名 / 16-bit 兼容)
  → 用 CreateMutexExW
- HANDLE 不是 newtype struct,是裸 *mut c_void → 直接 as
  isize,不要 .0
- CreateMutex[A/ExA/ExW/W] 全部 cfg-gated 在 Win32_Security feature
  → 必须开
- windows-sys 子 feature(Win32_System_Threading 等)依赖顶层
  Win32 feature → 必须同时开
- std::mem::zeroed() 必须放 unsafe block 里

验证:cargo build / build --release 都 exit 0,0 warning
- cargo test: 15 passed; 0 failed
- debug   35.56 MB, subsystem = WINDOWS_CUI
- release  9.77 MB, subsystem = WINDOWS_GUI
- 实际功能(重复启动会 exit 0)只能手测;test 只能覆盖 JSON /
  Rust 内部状态
2026-09-19 07:03:29 +08:00

Windows-Gotify-Client-Rust

轻量、现代、Windows 原生体验良好的 Gotify 桌面客户端,使用 Rust + Slint 构建。

详细的产品定位、技术栈约束、架构、UI 规范与分阶段实施计划全部记录在 AGENTS.md。本文档只做项目导览。

状态

🚧 从 0 起步 —— 当前仓库只有目录骨架与占位 Cargo.toml,尚未进入 Phase 1(Bootstrap)。 完整 8 阶段路线图见 AGENTS.md §57。

目标平台

  • Windows 10 x64
  • Windows 11 x64(ARM64 条件允许时支持)
  • 后台常驻、托盘型客户端

技术栈

层 选型
语言 Rust stable
UI Slint 1.17.x
HTTP reqwest(blocking + rustls)
WebSocket tungstenite
Windows 集成 windows-rs focused crates(按需引入)
配置 / 状态 JSON 文件(%APPDATA%/WindowsGotify/)
日志 tracing + tracing-subscriber

显式禁用:Tauri / Wails / Electron / WebView2 / WPF / WinUI 3 / Node 运行时。 理由见 AGENTS.md §2。

仓库布局

Windows-Gotify-Client-Rust/
├── Cargo.toml          # 占位 — 见 AGENTS.md §44
├── AGENTS.md           # AI Agent 实施计划(1363 行)
├── README.md
├── LICENSE             # MIT(占位)
├── .gitignore
├── assets/             # 图标、字体等
├── ui/                 # Slint 视图
├── src/                # Rust 业务代码
│   ├── gotify/         # HTTP + WebSocket
│   ├── storage/        # config.json / state.json
│   ├── windows/        # 托盘 / Toast / 启动 / 单实例 / URL
│   └── services/       # 生命周期
├── tests/              # 集成测试
└── scripts/            # PowerShell 构建脚本

开发环境

本仓库目前还没有源码,本节将在 Phase 1 完成后补全具体的 cargo run / cargo build --release 步骤。

隐私与安全

  • App Token 默认以 JSON 明文存储在 %APPDATA%/WindowsGotify/config.json,仅当前用户可访问
  • 日志永不打印完整 Authorization 头
  • 通知点击的 click.url 仅允许 http:// / https://,拒绝 file:// / javascript: / 自定义 scheme
  • 详细策略见 AGENTS.md §13 / §20 / §38 / §51

License

MIT(见 LICENSE)。

S
Description
No description provided
Readme MIT
637 KiB
2026-09-19 20:40:55 +08:00
Languages
Rust 73.7%
Slint 26.3%