| @@ -1,4 +1,4 @@ | |||||
| import { StrictMode } from 'react'; | |||||
| import { StrictMode, useEffect, useContext } from 'react'; | |||||
| import { createRoot } from 'react-dom/client'; | import { createRoot } from 'react-dom/client'; | ||||
| import { BrowserRouter } from 'react-router-dom'; | import { BrowserRouter } from 'react-router-dom'; | ||||
| import "./assets/style/styles.css" | import "./assets/style/styles.css" | ||||
| @@ -19,21 +19,28 @@ import reportWebVitals from './reportWebVitals'; | |||||
| import { I18nProvider } from "components/I18nProvider"; | import { I18nProvider } from "components/I18nProvider"; | ||||
| import { AutoLogoutProvider } from "components/AutoLogoutProvider"; | import { AutoLogoutProvider } from "components/AutoLogoutProvider"; | ||||
| import { RefreshTokenProvider } from "components/RefreshTokenProvider"; | import { RefreshTokenProvider } from "components/RefreshTokenProvider"; | ||||
| import { SysSettingProvider } from "components/SysSettingProvider"; | |||||
| import { SysSettingProvider, SysContext } from 'components/SysSettingProvider'; | |||||
| import { useLocation } from 'react-router-dom'; | import { useLocation } from 'react-router-dom'; | ||||
| import { useEffect } from 'react'; | |||||
| function GreyWrapper({ children }) { | function GreyWrapper({ children }) { | ||||
| const location = useLocation(); | const location = useLocation(); | ||||
| const { sysSetting } = useContext(SysContext); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| if (location.pathname === "/login") { | |||||
| document.body.classList.add("page-grey"); | |||||
| const isLoginPage = location.pathname === '/login'; | |||||
| const enableGrey = sysSetting?.greyLogin === true; | |||||
| if (isLoginPage && enableGrey) { | |||||
| document.body.classList.add('page-grey'); | |||||
| } else { | } else { | ||||
| document.body.classList.remove("page-grey"); | |||||
| document.body.classList.remove('page-grey'); | |||||
| } | } | ||||
| }, [location.pathname]); | |||||
| return () => { | |||||
| document.body.classList.remove('page-grey'); | |||||
| }; | |||||
| }, [location.pathname, sysSetting?.greyLogin]); | |||||
| return children; | return children; | ||||
| } | } | ||||