添加全局主题className

This commit is contained in:
hanhh 2021-09-19 21:27:20 +08:00
parent 0baf0d23ae
commit 1cc54b5da6

View File

@ -64,6 +64,16 @@ export default function (props: any) {
} }
}, [props.location.pathname]); }, [props.location.pathname]);
useEffect(() => {
if (theme && theme.theme) {
if (theme.theme === 'vs-dark') {
document.body.classList.add('dark');
} else {
document.body.classList.add('white');
}
}
}, [theme]);
useEffect(() => { useEffect(() => {
const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto'; const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto';
setFetchMethod(window.fetch); setFetchMethod(window.fetch);
@ -92,7 +102,6 @@ export default function (props: any) {
<ProLayout <ProLayout
selectedKeys={[props.location.pathname]} selectedKeys={[props.location.pathname]}
loading={loading} loading={loading}
className={theme.theme === 'vs-dark' ? 'dark' : 'white'}
title={ title={
<> <>