From 03e0c596928e66695f080fecae64d27828c50353 Mon Sep 17 00:00:00 2001 From: NanGua-QWQ Date: Tue, 24 Mar 2026 18:37:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E5=90=8E=E4=B8=BB=E9=A2=98=E4=B8=8D=E8=83=BD=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/state.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs index db3741c..9798ee5 100644 --- a/src-tauri/src/state.rs +++ b/src-tauri/src/state.rs @@ -6,7 +6,7 @@ use tauri::AppHandle; use crate::services::{ auth::AuthService, auto_score::AutoScoreService, data::DataService, logger::LoggerService, permission::PermissionService, security::SecurityService, settings::SettingsService, - theme::ThemeService, + theme::ThemeService, SettingsKey, SettingsValue, }; pub struct AppState { @@ -51,7 +51,22 @@ impl AppState { pub async fn initialize(&self) -> Result<(), Box> { self.settings.write().initialize().await?; self.logger.write().initialize(&self.app_handle).await?; - self.theme.write().initialize(&self.app_handle).await?; + + { + let settings = self.settings.read(); + let current_theme_id = match settings.get_value(SettingsKey::CurrentThemeId) { + SettingsValue::String(s) => s, + _ => "light-default".to_string(), + }; + let themes_custom = match settings.get_value(SettingsKey::ThemesCustom) { + SettingsValue::Json(j) => j, + _ => serde_json::Value::Array(vec![]), + }; + let mut theme = self.theme.write(); + theme.load_custom_themes(themes_custom); + theme.load_saved_theme(¤t_theme_id); + } + self.auto_score.write().initialize(&self.app_handle).await?; Ok(()) }