fix: fix color scheme switcher
This commit is contained in:
parent
f5238985a7
commit
b20821073f
@ -194,7 +194,7 @@ export default {
|
|||||||
return error.name ? `${error.name}: ${error.message}` : error.message
|
return error.name ? `${error.name}: ${error.message}` : error.message
|
||||||
},
|
},
|
||||||
colorScheme () {
|
colorScheme () {
|
||||||
if (!this.colorSchemeOption || !this.mql) {
|
if (!this.colorSchemeOption) {
|
||||||
return 'dark'
|
return 'dark'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +253,7 @@ export default {
|
|||||||
mounted () {
|
mounted () {
|
||||||
this.mql = window.matchMedia('(prefers-color-scheme: dark)')
|
this.mql = window.matchMedia('(prefers-color-scheme: dark)')
|
||||||
this.mql.addEventListener('change', this.handleColorSchemeChange)
|
this.mql.addEventListener('change', this.handleColorSchemeChange)
|
||||||
|
this.colorSchemeSystemPref = this.mql.matches ? 'dark' : 'light'
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
this.mql.removeEventListener('change', this.handleColorSchemeChange)
|
this.mql.removeEventListener('change', this.handleColorSchemeChange)
|
||||||
|
@ -19,7 +19,7 @@ i18n.register(
|
|||||||
{
|
{
|
||||||
showCode: 'Show code',
|
showCode: 'Show code',
|
||||||
hideCode: 'Hide code',
|
hideCode: 'Hide code',
|
||||||
expandEditor: 'Expand Live Editor',
|
expandEditor: 'Expand Live editor',
|
||||||
playInCodeSandbox: 'Open in CodeSandbox',
|
playInCodeSandbox: 'Open in CodeSandbox',
|
||||||
playInStackBlitz: 'Open in StackBlitz'
|
playInStackBlitz: 'Open in StackBlitz'
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user