From 79e5b2fb8494dff4b0431fd335d7e31de924bd08 Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Wed, 25 Aug 2021 18:58:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E5=80=92?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/index.tsx | 6 +++--- src/pages/login/index.tsx | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 09181be5..98c018f9 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -45,11 +45,11 @@ export default function (props: any) { }, [props.location.pathname]); useEffect(() => { - const theme = localStorage.getItem('qinglong_dark_theme') || 'auto'; + const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto'; setFetchMethod(window.fetch); - if (theme === 'dark') { + if (_theme === 'dark') { enableDarkMode({}); - } else if (theme === 'light') { + } else if (_theme === 'light') { disableDarkMode(); } else { followSystemColorScheme({}); diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index e72dda1a..b85c879c 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -12,6 +12,7 @@ import config from '@/utils/config'; import { history, Link } from 'umi'; import styles from './index.less'; import { request } from '@/utils/http'; +import { useTheme } from '@/utils/hooks'; const FormItem = Form.Item; const { Countdown } = Statistic; @@ -19,6 +20,7 @@ const { Countdown } = Statistic; const Login = () => { const [loading, setLoading] = useState(false); const [waitTime, setWaitTime] = useState(); + const { theme } = useTheme(); const handleOk = (values: any) => { setLoading(true); @@ -106,7 +108,12 @@ const Login = () => {