File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 document . head . appendChild ( style ) ;
2020 }
2121
22- function readThemeCookie ( ) {
22+ function isDarkTheme ( ) {
2323 var themeCookie = document . cookie
2424 . split ( "; " )
2525 . find ( function ( row ) {
3939 }
4040
4141 function initTheme ( ) {
42- var dark = readThemeCookie ( ) ;
42+ var dark = isDarkTheme ( ) ;
4343 syncThemeDom ( dark ) ;
4444 return dark ;
4545 }
5555 }
5656
5757 window . __NODEGET_THEME__ = {
58- readThemeCookie : readThemeCookie ,
58+ isDarkTheme : isDarkTheme ,
5959 syncThemeDom : syncThemeDom ,
6060 initTheme : initTheme ,
6161 applyTheme : applyTheme ,
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ import { createPersistedState } from "pinia-plugin-persistedstate";
44import { createI18n } from "vue-i18n" ;
55import App from "./App.vue" ;
66import router from "./router" ;
7- import { useThemeStore } from "./stores/theme" ;
87import routePrefetchPlugin from "./router/prefetchPlugin" ;
98import "./style/app.css" ;
109import en from "./locales/en" ;
@@ -32,7 +31,6 @@ const i18n = createI18n({
3231} ) ;
3332
3433pinia . use ( createPersistedState ( ) ) ;
35- useThemeStore ( pinia ) . init ( ) ;
3634
3735app . use ( pinia ) ;
3836app . use ( routePrefetchPlugin ( router ) ) ;
Original file line number Diff line number Diff line change @@ -3,11 +3,7 @@ import { ref } from "vue";
33import { applyTheme , initTheme } from "@/theme/dom" ;
44
55export const useThemeStore = defineStore ( "theme" , ( ) => {
6- const isDark = ref ( false ) ;
7-
8- const init = ( ) => {
9- isDark . value = initTheme ( ) ;
10- } ;
6+ const isDark = ref ( ! ! initTheme ( ) ) ;
117
128 const setTheme = ( dark : boolean ) => {
139 isDark . value = dark ;
@@ -18,5 +14,5 @@ export const useThemeStore = defineStore("theme", () => {
1814 setTheme ( ! isDark . value ) ;
1915 } ;
2016
21- return { isDark, init , setTheme, toggle } ;
17+ return { isDark, setTheme, toggle } ;
2218} ) ;
Original file line number Diff line number Diff line change 11type ThemeApi = {
2- readThemeCookie : ( ) => boolean ;
2+ isDarkTheme : ( ) => boolean ;
33 syncThemeDom : ( dark : boolean ) => void ;
44 initTheme : ( ) => boolean ;
55 applyTheme : ( dark : boolean ) => void ;
@@ -21,7 +21,7 @@ const getThemeApi = () => {
2121 return api ;
2222} ;
2323
24- export const readThemeCookie = ( ) => getThemeApi ( ) . readThemeCookie ( ) ;
24+ export const isDarkTheme = ( ) => getThemeApi ( ) . isDarkTheme ( ) ;
2525
2626export const syncThemeDom = ( dark : boolean ) => getThemeApi ( ) . syncThemeDom ( dark ) ;
2727
You can’t perform that action at this time.
0 commit comments