add: 增加任务完成的提示音
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::app_error::AppCommandError;
|
||||
use crate::db::service::app_metadata_service;
|
||||
#[cfg(feature = "tauri-runtime")]
|
||||
use crate::db::AppDatabase;
|
||||
use crate::models::{SystemLanguageSettings, SystemProxySettings};
|
||||
use crate::models::{SystemLanguageSettings, SystemNotificationSettings, SystemProxySettings};
|
||||
#[cfg(feature = "tauri-runtime")]
|
||||
use crate::models::SystemRenderingSettings;
|
||||
#[cfg(feature = "tauri-runtime")]
|
||||
@@ -16,6 +16,7 @@ use crate::network::proxy;
|
||||
|
||||
const SYSTEM_PROXY_SETTINGS_KEY: &str = "system_proxy_settings";
|
||||
const SYSTEM_LANGUAGE_SETTINGS_KEY: &str = "system_language_settings";
|
||||
const SYSTEM_NOTIFICATION_SETTINGS_KEY: &str = "system_notification_settings";
|
||||
#[cfg(feature = "tauri-runtime")]
|
||||
const LANGUAGE_SETTINGS_UPDATED_EVENT: &str = "app://language-settings-updated";
|
||||
|
||||
@@ -174,3 +175,46 @@ pub async fn update_system_rendering_settings(
|
||||
})?;
|
||||
Ok(settings)
|
||||
}
|
||||
|
||||
pub(crate) async fn load_system_notification_settings(
|
||||
conn: &DatabaseConnection,
|
||||
) -> Result<SystemNotificationSettings, AppCommandError> {
|
||||
let raw = app_metadata_service::get_value(conn, SYSTEM_NOTIFICATION_SETTINGS_KEY)
|
||||
.await
|
||||
.map_err(AppCommandError::from)?;
|
||||
|
||||
let Some(raw) = raw else {
|
||||
return Ok(SystemNotificationSettings::new_enabled());
|
||||
};
|
||||
|
||||
serde_json::from_str::<SystemNotificationSettings>(&raw).map_err(|e| {
|
||||
AppCommandError::configuration_invalid("Failed to parse stored notification settings")
|
||||
.with_detail(e.to_string())
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "tauri-runtime")]
|
||||
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
|
||||
pub async fn get_system_notification_settings(
|
||||
db: State<'_, AppDatabase>,
|
||||
) -> Result<SystemNotificationSettings, AppCommandError> {
|
||||
load_system_notification_settings(&db.conn).await
|
||||
}
|
||||
|
||||
#[cfg(feature = "tauri-runtime")]
|
||||
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
|
||||
pub async fn update_system_notification_settings(
|
||||
settings: SystemNotificationSettings,
|
||||
db: State<'_, AppDatabase>,
|
||||
) -> Result<SystemNotificationSettings, AppCommandError> {
|
||||
let serialized = serde_json::to_string(&settings).map_err(|e| {
|
||||
AppCommandError::invalid_input("Failed to serialize notification settings")
|
||||
.with_detail(e.to_string())
|
||||
})?;
|
||||
|
||||
app_metadata_service::upsert_value(&db.conn, SYSTEM_NOTIFICATION_SETTINGS_KEY, &serialized)
|
||||
.await
|
||||
.map_err(AppCommandError::from)?;
|
||||
|
||||
Ok(settings)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user