设置页面修改语言和Agent,其它页面实时更新状态

This commit is contained in:
xintaofei
2026-03-07 21:36:00 +08:00
parent 8f265f8c0c
commit 62d8e1a0b0
5 changed files with 215 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
use sea_orm::DatabaseConnection;
use tauri::State;
use tauri::{Emitter, State};
use crate::app_error::AppCommandError;
use crate::db::service::app_metadata_service;
@@ -9,6 +9,7 @@ use crate::network::proxy;
const SYSTEM_PROXY_SETTINGS_KEY: &str = "system_proxy_settings";
const SYSTEM_LANGUAGE_SETTINGS_KEY: &str = "system_language_settings";
const LANGUAGE_SETTINGS_UPDATED_EVENT: &str = "app://language-settings-updated";
fn normalize_proxy_settings(
settings: SystemProxySettings,
@@ -118,6 +119,7 @@ pub async fn get_system_language_settings(
pub async fn update_system_language_settings(
settings: SystemLanguageSettings,
db: State<'_, AppDatabase>,
app: tauri::AppHandle,
) -> Result<SystemLanguageSettings, AppCommandError> {
let serialized = serde_json::to_string(&settings).map_err(|e| {
AppCommandError::invalid_input("Failed to serialize language settings")
@@ -128,5 +130,7 @@ pub async fn update_system_language_settings(
.await
.map_err(AppCommandError::from)?;
let _ = app.emit(LANGUAGE_SETTINGS_UPDATED_EVENT, &settings);
Ok(settings)
}