修复运行问题

This commit is contained in:
tangly1024
2022-03-03 16:41:33 +08:00
parent cd4c230861
commit f061d8fc03
2 changed files with 5 additions and 6 deletions

View File

@@ -8,10 +8,10 @@ import BLOG from '@/blog.config'
* @description 读取cookie中存的用户主题
*/
export const initDarkMode = (isDarkMode, updateDarkMode) => {
if (!isDarkMode) {
isDarkMode = isPreferDark()
}
if (typeof window !== 'undefined') {
if (!isDarkMode) {
isDarkMode = isPreferDark()
}
updateDarkMode(isDarkMode)
saveDarkModeToCookies(isDarkMode)
document.getElementsByTagName('html')[0].setAttribute('class', isDarkMode ? 'dark' : 'light')