发送系统通知时携带folder名
This commit is contained in:
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -804,6 +804,7 @@ dependencies = [
|
||||
"futures",
|
||||
"keyring",
|
||||
"kill_tree",
|
||||
"mac-notification-sys",
|
||||
"notify",
|
||||
"portable-pty",
|
||||
"regex",
|
||||
|
||||
@@ -58,6 +58,9 @@ tauri-plugin-process = "2"
|
||||
tauri-plugin-notification = "2"
|
||||
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
mac-notification-sys = "0.6"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows-sys = { version = "0.59", features = ["Win32_Storage_FileSystem"] }
|
||||
|
||||
|
||||
@@ -6,4 +6,5 @@ pub mod mcp;
|
||||
pub mod system_settings;
|
||||
pub mod terminal;
|
||||
pub mod version_control;
|
||||
pub mod notification;
|
||||
pub mod windows;
|
||||
|
||||
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(())
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user