mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 09:56:32 +08:00
fix: auto mode error
This commit is contained in:
parent
658fad2898
commit
8ab5ec409f
17361
package-lock.json
generated
Normal file
17361
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -74,7 +74,7 @@ const actions = {
|
||||||
},
|
},
|
||||||
async changeMode({ commit, state }, payload: IStateType) {
|
async changeMode({ commit, state }, payload: IStateType) {
|
||||||
let theme = payload.mode;
|
let theme = payload.mode;
|
||||||
const isDarkMode = theme === 'dark';
|
|
||||||
if (payload.mode === 'auto') {
|
if (payload.mode === 'auto') {
|
||||||
const media = window.matchMedia('(prefers-color-scheme:dark)');
|
const media = window.matchMedia('(prefers-color-scheme:dark)');
|
||||||
if (media.matches) {
|
if (media.matches) {
|
||||||
|
@ -83,6 +83,7 @@ const actions = {
|
||||||
theme = 'light';
|
theme = 'light';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const isDarkMode = theme === 'dark';
|
||||||
if (theme !== state.mode) {
|
if (theme !== state.mode) {
|
||||||
document.documentElement.setAttribute('theme-mode', isDarkMode ? 'dark' : '');
|
document.documentElement.setAttribute('theme-mode', isDarkMode ? 'dark' : '');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user