File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Suspense , useEffect } from 'react'
2
2
import { HashRouter , Route , Routes } from 'react-router-dom'
3
+ import { useSelector } from 'react-redux'
3
4
4
5
import { CSpinner , useColorModes } from '@coreui/react'
5
6
import './scss/style.scss'
@@ -14,14 +15,21 @@ const Page404 = React.lazy(() => import('./views/pages/page404/Page404'))
14
15
const Page500 = React . lazy ( ( ) => import ( './views/pages/page500/Page500' ) )
15
16
16
17
const App = ( ) => {
17
- const { setColorMode } = useColorModes ( 'coreui-free-react-admin-template-theme' )
18
- const urlParams = new URLSearchParams ( window . location . href . split ( '?' ) [ 1 ] )
18
+ const { isColorModeSet , setColorMode } = useColorModes ( 'coreui-free-react-admin-template-theme' )
19
+ const theme = useSelector ( ( state ) => state . theme )
19
20
20
21
useEffect ( ( ) => {
22
+ const urlParams = new URLSearchParams ( window . location . href . split ( '?' ) [ 1 ] )
21
23
if ( urlParams . get ( 'theme' ) ) {
22
24
setColorMode ( urlParams . get ( 'theme' ) )
23
25
}
24
- } , [ ] )
26
+
27
+ if ( isColorModeSet ( ) ) {
28
+ return
29
+ }
30
+
31
+ setColorMode ( theme )
32
+ } , [ ] ) // eslint-disable-line react-hooks/exhaustive-deps
25
33
26
34
return (
27
35
< HashRouter >
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { createStore } from 'redux'
2
2
3
3
const initialState = {
4
4
sidebarShow : true ,
5
+ theme : 'light' ,
5
6
}
6
7
7
8
const changeState = ( state = initialState , { type, ...rest } ) => {
You can’t perform that action at this time.
0 commit comments