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 1
1
<template >
2
2
<router-view />
3
3
</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 >
4
32
5
33
<style lang="scss">
6
34
// Import Main styles for this application
Original file line number Diff line number Diff line change 97
97
</template >
98
98
99
99
<script >
100
- import { useColorModes } from ' @coreui/vue/ '
100
+ import { useColorModes } from ' @coreui/vue'
101
101
import AppBreadcrumb from ' ./AppBreadcrumb'
102
102
import AppHeaderDropdownAccnt from ' ./AppHeaderDropdownAccnt'
103
103
import { logo } from ' @/assets/brand/logo'
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export default createStore({
4
4
state : {
5
5
sidebarVisible : '' ,
6
6
sidebarUnfoldable : false ,
7
+ theme : 'light' ,
7
8
} ,
8
9
mutations : {
9
10
toggleSidebar ( state ) {
Original file line number Diff line number Diff line change @@ -386,12 +386,17 @@ export default {
386
386
387
387
onMounted (() => {
388
388
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
+ }
395
400
})
396
401
})
397
402
You can’t perform that action at this time.
0 commit comments