发送系统通知时携带folder名

This commit is contained in:
xintaofei
2026-03-21 19:14:38 +08:00
parent a9e0a742ac
commit d0655066b6
9 changed files with 63 additions and 13 deletions

View File

@@ -6,4 +6,5 @@ pub mod mcp;
pub mod system_settings;
pub mod terminal;
pub mod version_control;
pub mod notification;
pub mod windows;

View 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(())
}

View File

@@ -15,7 +15,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use acp::manager::ConnectionManager;
use commands::{
acp as acp_commands, conversations, folder_commands, folders, mcp as mcp_commands,
system_settings, terminal as terminal_commands, version_control, windows,
notification, system_settings, terminal as terminal_commands, version_control, windows,
};
use tauri::Manager;
use terminal::manager::TerminalManager;
@@ -319,6 +319,7 @@ pub fn run() {
mcp_commands::mcp_upsert_local_server,
mcp_commands::mcp_set_server_apps,
mcp_commands::mcp_remove_server,
notification::send_notification,
])
.build(tauri::generate_context!())
.expect("error while building tauri application")