@@ -18,7 +18,7 @@ const { userTheme, applyThemePreference, applySystemThemePreference } = useTheme
1818const { applyPrimaryColor } = useColor ();
1919const settingManager = useSettingManager ();
2020
21- const { fontFamily, primaryColorLight, primaryColorDark, setLang } = settingManager ;
21+ const { fontFamily, primaryColorLight, primaryColorDark, setLang, hydrationPromise, isHydrated } = settingManager ;
2222
2323const backgroundColor = computed (() => {
2424 const isDark = userTheme .value === " dark" ;
@@ -75,6 +75,17 @@ function applyFont(font: string) {
7575 document .documentElement .style .setProperty (" --font-heading" , font );
7676}
7777
78+ const applyAfterHydration = async () => {
79+ if (hydrationPromise .value ) {
80+ try {
81+ await hydrationPromise .value ;
82+ } catch (err ) {
83+ console .error (" wait hydration failed" , err );
84+ }
85+ }
86+ applyCurrentThemeColor ();
87+ };
88+
7889onMounted (async () => {
7990 try {
8091 await useTauriEventListen (" primary-color-changed" , (event : any ) => {
@@ -125,11 +136,21 @@ onMounted(async () => {
125136 });
126137
127138 await useWarmupSetting ();
139+ await applyAfterHydration ();
128140 } catch (error ) {
129141 console .error (error );
130142 }
131143});
132144
145+ watch (
146+ () => isHydrated .value ,
147+ (ready ) => {
148+ if (ready ) {
149+ applyAfterHydration ();
150+ }
151+ }
152+ );
153+
133154// 切换账号时,按站点映射立即应用语言
134155watch (
135156 () => currentSite .value ,
0 commit comments