2026-07-01 09:07:38 -04:00
|
|
|
//! 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;
|
2026-07-01 10:01:31 -04:00
|
|
|
pub mod focus_assist;
|
2026-07-01 09:07:38 -04:00
|
|
|
pub mod jumplist;
|
|
|
|
|
pub mod network;
|
|
|
|
|
pub mod power;
|
|
|
|
|
pub mod smtc;
|
|
|
|
|
pub mod thumbbar;
|
2026-07-01 10:01:31 -04:00
|
|
|
pub mod toast;
|
2026-07-01 09:07:38 -04:00
|
|
|
|
|
|
|
|
/// 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)?;
|
2026-07-01 10:01:31 -04:00
|
|
|
focus_assist::setup(app)?;
|
2026-07-01 09:07:38 -04:00
|
|
|
Ok(())
|
|
|
|
|
}
|