File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -5,17 +5,17 @@ type ThemeValue = "light" | "dark"
55const theme = ref < ThemeValue > ( )
66
77const initTheme = ( ) => {
8-
9- if ( window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) {
10- setTheme ( 'dark' )
11- }
12- if ( window . matchMedia && window . matchMedia ( '(prefers-color-scheme: light)' ) . matches ) {
13- setTheme ( 'light' )
14- }
15-
168 let theme = localStorage . getItem ( 'theme' )
9+
1710 if ( theme ) {
1811 setTheme ( theme as ThemeValue )
12+ } else {
13+ if ( window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) {
14+ setTheme ( 'dark' )
15+ }
16+ if ( window . matchMedia && window . matchMedia ( '(prefers-color-scheme: light)' ) . matches ) {
17+ setTheme ( 'light' )
18+ }
1919 }
2020}
2121
@@ -50,4 +50,4 @@ const toggleTheme = () => {
5050
5151export const themeHandler = {
5252 theme, toggleTheme, initTheme
53- }
53+ }
You can’t perform that action at this time.
0 commit comments