File tree 2 files changed +16
-9
lines changed
effects/plugins/src/vxe-table
2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -198,9 +198,16 @@ class PreferenceManager {
198
198
window
199
199
. matchMedia ( '(prefers-color-scheme: dark)' )
200
200
. 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
+ }
204
211
} ) ;
205
212
}
206
213
Original file line number Diff line number Diff line change @@ -106,19 +106,19 @@ export function setupVbenVxeTable(setupOptions: SetupVxeTable) {
106
106
initVxeTable ( ) ;
107
107
useTableForm = useVbenForm ;
108
108
109
- const preference = usePreferences ( ) ;
109
+ const { isDark , locale } = usePreferences ( ) ;
110
110
111
111
const localMap = {
112
112
'zh-CN' : zhCN ,
113
113
'en-US' : enUS ,
114
114
} ;
115
115
116
116
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 ) ;
122
122
} ,
123
123
{
124
124
immediate : true ,
You can’t perform that action at this time.
0 commit comments