Support website message notification display

This commit is contained in:
Tw93
2024-12-24 20:33:26 +08:00
parent 7a02d8fb71
commit c06182151e
6 changed files with 240 additions and 20 deletions

View File

@@ -18,6 +18,13 @@ pub struct BinaryDownloadParams {
binary: Vec<u8>,
}
#[derive(serde::Deserialize)]
pub struct NotificationParams {
title: String,
body: String,
icon: String,
}
#[command]
pub async fn download_file(app: AppHandle, params: DownloadFileParams) -> Result<(), String> {
let window: WebviewWindow = app.get_webview_window("pake").unwrap();
@@ -71,3 +78,16 @@ pub async fn download_file_by_binary(
}
}
}
#[command]
pub fn send_notification(app: AppHandle, params: NotificationParams) -> Result<(), String> {
use tauri_plugin_notification::NotificationExt;
app.notification()
.builder()
.title(&params.title)
.body(&params.body)
.icon(&params.icon)
.show()
.unwrap();
Ok(())
}