File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -64,13 +64,29 @@ export default {
6464 },
6565 data () {
6666 return {
67- logoPath: this .$store .getters .darkMode ? this .$config .whiteLogo : this .$config .logo
67+ logoPath: ( this .$store .getters .darkMode || this . $store . getters . theme === ' dark ' ) ? this .$config .whiteLogo : this .$config .logo
6868 }
6969 },
7070 watch: {
71+ ' $store.getters.theme' (theme) {
72+ this .logoPath = (this .$store .getters .darkMode || theme === ' dark' ) ? this .$config .whiteLogo : this .$config .logo
73+ },
7174 ' $store.getters.darkMode' (darkMode) {
72- this .logoPath = darkMode ? this .$config .whiteLogo : this .$config .logo
75+ document .body .classList .toggle (' dark-mode' , darkMode)
76+ this .logoPath = (darkMode || this .$store .getters .theme === ' dark' ) ? this .$config .whiteLogo : this .$config .logo
7377 }
78+ },
79+ mounted () {
80+ // 시스템 테마 변경되었을때 감지 후 테마 변경
81+ window .matchMedia (' (prefers-color-scheme: dark)' ).addEventListener (' change' , (event ) => {
82+ this .$localStorage .set (' DARK_MODE' , event .matches )
83+ this .$store .dispatch (' SetDarkMode' , event .matches )
84+ document .body .classList .toggle (' dark-mode' , event .matches )
85+ })
86+ // 로컬스토리지 다크 모드 확인 후 변경
87+ const isDark = !! this .$localStorage .get (' DARK_MODE' )
88+ this .$store .dispatch (' SetDarkMode' , isDark)
89+ document .body .classList .toggle (' dark-mode' , isDark)
7490 }
7591}
7692 </script >
You can’t perform that action at this time.
0 commit comments