mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
optimise dark mode setting saving
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
<title>
|
<title>
|
||||||
<%= htmlWebpackPlugin.options.title %>
|
<%= htmlWebpackPlugin.options.title %>
|
||||||
|
|||||||
@@ -164,18 +164,18 @@ export default {
|
|||||||
if ( this.theme === '☼' ) {
|
if ( this.theme === '☼' ) {
|
||||||
document.documentElement.classList.remove( 'dark' );
|
document.documentElement.classList.remove( 'dark' );
|
||||||
document.documentElement.classList.add( 'light' );
|
document.documentElement.classList.add( 'light' );
|
||||||
sessionStorage.setItem( 'theme', '☽' );
|
localStorage.setItem( 'theme', '☽' );
|
||||||
this.theme = '☽';
|
this.theme = '☽';
|
||||||
} else if ( this.theme === '☽' ) {
|
} else if ( this.theme === '☽' ) {
|
||||||
document.documentElement.classList.remove( 'light' );
|
document.documentElement.classList.remove( 'light' );
|
||||||
document.documentElement.classList.add( 'dark' );
|
document.documentElement.classList.add( 'dark' );
|
||||||
sessionStorage.setItem( 'theme', '☼' );
|
localStorage.setItem( 'theme', '☼' );
|
||||||
this.theme = '☼';
|
this.theme = '☼';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.theme = sessionStorage.getItem( 'theme' ) ? sessionStorage.getItem( 'theme' ) : '';
|
this.theme = localStorage.getItem( 'theme' ) ? localStorage.getItem( 'theme' ) : '';
|
||||||
if ( window.matchMedia( '(prefers-color-scheme: dark)' ).matches || this.theme === '☼' ) {
|
if ( window.matchMedia( '(prefers-color-scheme: dark)' ).matches || this.theme === '☼' ) {
|
||||||
document.documentElement.classList.add( 'dark' );
|
document.documentElement.classList.add( 'dark' );
|
||||||
this.theme = '☼';
|
this.theme = '☼';
|
||||||
|
|||||||
Reference in New Issue
Block a user