fix: fix color scheme switcher

This commit is contained in:
Justineo
2021-11-25 16:14:35 +08:00
parent f5238985a7
commit b20821073f
2 changed files with 3 additions and 2 deletions

View File

@@ -194,7 +194,7 @@ export default {
return error.name ? `${error.name}: ${error.message}` : error.message
},
colorScheme () {
if (!this.colorSchemeOption || !this.mql) {
if (!this.colorSchemeOption) {
return 'dark'
}
@@ -253,6 +253,7 @@ export default {
mounted () {
this.mql = window.matchMedia('(prefers-color-scheme: dark)')
this.mql.addEventListener('change', this.handleColorSchemeChange)
this.colorSchemeSystemPref = this.mql.matches ? 'dark' : 'light'
},
beforeDestroy () {
this.mql.removeEventListener('change', this.handleColorSchemeChange)