发送系统通知时携带folder名
This commit is contained in:
38
src-tauri/src/commands/notification.rs
Normal file
38
src-tauri/src/commands/notification.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use tauri::AppHandle;
|
||||
|
||||
use crate::app_error::AppCommandError;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn send_notification(
|
||||
#[allow(unused_variables)] app: AppHandle,
|
||||
title: String,
|
||||
body: String,
|
||||
) -> Result<(), AppCommandError> {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let app_id = if tauri::is_dev() {
|
||||
"com.apple.Terminal"
|
||||
} else {
|
||||
"app.codeg"
|
||||
};
|
||||
let _ = mac_notification_sys::set_application(app_id);
|
||||
|
||||
let _ = mac_notification_sys::Notification::default()
|
||||
.title(&title)
|
||||
.message(&body)
|
||||
.send();
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
use tauri_plugin_notification::NotificationExt;
|
||||
let _ = app
|
||||
.notification()
|
||||
.builder()
|
||||
.title(title)
|
||||
.body(body)
|
||||
.show();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user