File tree Expand file tree Collapse file tree 4 files changed +41
-7
lines changed
Expand file tree Collapse file tree 4 files changed +41
-7
lines changed Original file line number Diff line number Diff line change 11<template >
22 <router-view />
33</template >
4+ <script >
5+ import { onBeforeMount } from ' vue'
6+ import { useStore } from ' vuex'
7+ import { useColorModes } from ' @coreui/vue'
8+
9+ export default {
10+ setup () {
11+ const { isColorModeSet , setColorMode } = useColorModes (
12+ ' coreui-free-vue-admin-template-theme' ,
13+ )
14+ const store = useStore ()
15+
16+ onBeforeMount (() => {
17+ const urlParams = new URLSearchParams (window .location .href .split (' ?' )[1 ])
18+ if (urlParams .get (' theme' )) {
19+ setColorMode (urlParams .get (' theme' ))
20+ return
21+ }
22+
23+ if (isColorModeSet ()) {
24+ return
25+ }
26+
27+ setColorMode (store .state .theme )
28+ })
29+ },
30+ }
31+ </script >
432
533<style lang="scss">
634// Import Main styles for this application
Original file line number Diff line number Diff line change 9797</template >
9898
9999<script >
100- import { useColorModes } from ' @coreui/vue/ '
100+ import { useColorModes } from ' @coreui/vue'
101101import AppBreadcrumb from ' ./AppBreadcrumb'
102102import AppHeaderDropdownAccnt from ' ./AppHeaderDropdownAccnt'
103103import { logo } from ' @/assets/brand/logo'
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export default createStore({
44 state : {
55 sidebarVisible : '' ,
66 sidebarUnfoldable : false ,
7+ theme : 'light' ,
78 } ,
89 mutations : {
910 toggleSidebar ( state ) {
Original file line number Diff line number Diff line change @@ -386,12 +386,17 @@ export default {
386386
387387 onMounted (() => {
388388 document .documentElement .addEventListener (' ColorSchemeChange' , () => {
389- widgetChartRef1 .value .chart .data .datasets [0 ].pointBackgroundColor =
390- getStyle (' --cui-primary' )
391- widgetChartRef2 .value .chart .data .datasets [0 ].pointBackgroundColor =
392- getStyle (' --cui-info' )
393- widgetChartRef1 .value .chart .update ()
394- widgetChartRef2 .value .chart .update ()
389+ if (widgetChartRef1 .value ) {
390+ widgetChartRef1 .value .chart .data .datasets [0 ].pointBackgroundColor =
391+ getStyle (' --cui-primary' )
392+ widgetChartRef1 .value .chart .update ()
393+ }
394+
395+ if (widgetChartRef2 .value ) {
396+ widgetChartRef2 .value .chart .data .datasets [0 ].pointBackgroundColor =
397+ getStyle (' --cui-info' )
398+ widgetChartRef2 .value .chart .update ()
399+ }
395400 })
396401 })
397402
You can’t perform that action at this time.
0 commit comments