feat(native): Tier A desktop features (P5-46/36/44/43/49) + window chrome (P5-47)
Adds a `native/` module system (each feature = its own module exposing `#[tauri::command]`s + optional `setup`; `emit_to_web` pushes DOM CustomEvents to the web like `forward_deeplink`). Wired into generate_handler! + native::setup; windows-crate feature union added to Cargo.toml. - power.rs (P5-46): SetThreadExecutionState held on the main thread while a call is active; released on end. Cross-platform (no-op off Windows). - jumplist.rs (P5-36): ICustomDestinationList "Recent Rooms" of IShellLink tasks launching the exe with a matrix: arg (existing deep-link handler opens the room). - thumbbar.rs (P5-44): ITaskbarList3 ThumbBar Mute/Deafen/End (GDI HICONs) + a window subclass catching THBN_CLICKED → emit thumbbar-action. - smtc.rs (P5-43): WinRT SystemMediaTransportControls via GetForWindow; ButtonPressed → smtc-action; call-state command. (Experimental for a non-media app.) - network.rs (P5-49): INetworkListManager poll thread → emit network-changed. - chrome.rs (P5-47): cross-platform window-control commands + set_custom_chrome (set_decorations) for the opt-in TDS titlebar. NOT compile-verified locally (no Rust/Windows toolchain on the dev box) — this is for the CI Windows compile pass (GitHub test.yml / Gitea windows runner). Expect a possible fixup round (windows-crate feature/namespace paths, e.g. subclass APIs). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
//! Native desktop feature modules (Lotus Chat).
|
||||
//!
|
||||
//! Each feature lives in its own submodule exposing `#[tauri::command]`(s) and,
|
||||
//! when it needs to register listeners/state, a `setup(&AppHandle)`. lib.rs adds
|
||||
//! the commands to `generate_handler!` and calls `native::setup()` once during
|
||||
//! app setup. Windows-only pieces are guarded with `#[cfg(target_os = "windows")]`
|
||||
//! and compile-verified in CI (Gitea `windows` runner / GitHub `windows-latest`).
|
||||
|
||||
use tauri::{AppHandle, Manager};
|
||||
|
||||
pub mod chrome;
|
||||
pub mod jumplist;
|
||||
pub mod network;
|
||||
pub mod power;
|
||||
pub mod smtc;
|
||||
pub mod thumbbar;
|
||||
|
||||
/// Dispatch a DOM `CustomEvent` to the web client (mirrors `forward_deeplink` in
|
||||
/// lib.rs) so native modules can push data to the frontend without pulling in
|
||||
/// `@tauri-apps/api` on the web side. `detail_json` MUST be valid JSON (use
|
||||
/// `serde_json::to_string`). `event` is a static, trusted name.
|
||||
#[allow(dead_code)]
|
||||
pub fn emit_to_web(app: &AppHandle, event: &str, detail_json: &str) {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.eval(&format!(
|
||||
"window.dispatchEvent(new CustomEvent('{event}',{{detail:{detail_json}}}))"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// Called once from lib.rs `.setup()`. Feature modules that need to register OS
|
||||
/// listeners or managed state get initialized here. (power/jumplist/chrome are
|
||||
/// command-only and need no setup.)
|
||||
pub fn setup(app: &AppHandle) -> tauri::Result<()> {
|
||||
thumbbar::setup(app)?;
|
||||
smtc::setup(app)?;
|
||||
network::setup(app)?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user