File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed
effects/plugins/src/vxe-table Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -198,9 +198,16 @@ class PreferenceManager {
198198 window
199199 . matchMedia ( '(prefers-color-scheme: dark)' )
200200 . addEventListener ( 'change' , ( { matches : isDark } ) => {
201- this . updatePreferences ( {
202- theme : { mode : isDark ? 'dark' : 'light' } ,
203- } ) ;
201+ // 如果偏好设置中主题模式为auto,则跟随系统更新
202+ if ( this . state . theme . mode === 'auto' ) {
203+ this . updatePreferences ( {
204+ theme : { mode : isDark ? 'dark' : 'light' } ,
205+ } ) ;
206+ // 恢复为auto模式
207+ this . updatePreferences ( {
208+ theme : { mode : 'auto' } ,
209+ } ) ;
210+ }
204211 } ) ;
205212 }
206213
Original file line number Diff line number Diff line change @@ -106,19 +106,19 @@ export function setupVbenVxeTable(setupOptions: SetupVxeTable) {
106106 initVxeTable ( ) ;
107107 useTableForm = useVbenForm ;
108108
109- const preference = usePreferences ( ) ;
109+ const { isDark , locale } = usePreferences ( ) ;
110110
111111 const localMap = {
112112 'zh-CN' : zhCN ,
113113 'en-US' : enUS ,
114114 } ;
115115
116116 watch (
117- [ ( ) => preference . theme . value , ( ) => preference . locale . value ] ,
118- ( [ theme , locale ] ) => {
119- VxeUI . setTheme ( theme === 'dark' ? 'dark' : 'light' ) ;
120- VxeUI . setI18n ( locale , localMap [ locale ] ) ;
121- VxeUI . setLanguage ( locale ) ;
117+ [ ( ) => isDark . value , ( ) => locale . value ] ,
118+ ( [ isDarkValue , localeValue ] ) => {
119+ VxeUI . setTheme ( isDarkValue ? 'dark' : 'light' ) ;
120+ VxeUI . setI18n ( localeValue , localMap [ localeValue ] ) ;
121+ VxeUI . setLanguage ( localeValue ) ;
122122 } ,
123123 {
124124 immediate : true ,
You can’t perform that action at this time.
0 commit comments