mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-26 05:01:12 +00:00
Single-instance + openclaw:// deep links (openclaw://dashboard opens and connects the dashboard; the tiny URL contract is routed entirely in Rust), a Start at Login tray toggle (tauri-plugin-autostart, default off), native notifications for update-ready/update-available when the window is unfocused, and window-state persistence (canvas window excluded). All official Tauri v2 plugins; cross-platform deps so the macOS/Windows test builds keep compiling.
27 lines
939 B
Rust
27 lines
939 B
Rust
use tauri::AppHandle;
|
|
use tauri_plugin_notification::{NotificationExt, PermissionState};
|
|
|
|
pub fn notify(app: &AppHandle, title: &str, body: &str) {
|
|
let notification = app.notification();
|
|
let permission = match notification.permission_state() {
|
|
Ok(PermissionState::Granted) => PermissionState::Granted,
|
|
Ok(_) => match notification.request_permission() {
|
|
Ok(permission) => permission,
|
|
Err(error) => {
|
|
eprintln!("Could not request notification permission: {error}");
|
|
return;
|
|
}
|
|
},
|
|
Err(error) => {
|
|
eprintln!("Could not check notification permission: {error}");
|
|
return;
|
|
}
|
|
};
|
|
if !matches!(permission, PermissionState::Granted) {
|
|
return;
|
|
}
|
|
if let Err(error) = notification.builder().title(title).body(body).show() {
|
|
eprintln!("Could not show notification: {error}");
|
|
}
|
|
}
|