From 17ec70f839ff90098e446500c0edfe9d1ea8aa34 Mon Sep 17 00:00:00 2001 From: jialin Date: Thu, 15 May 2025 19:03:33 +0800 Subject: [PATCH] chore: init mask theme --- src/components/dark-mask/index.tsx | 9 +++++++++ src/layouts/index.tsx | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/dark-mask/index.tsx b/src/components/dark-mask/index.tsx index 42a7b169..a14b27f0 100644 --- a/src/components/dark-mask/index.tsx +++ b/src/components/dark-mask/index.tsx @@ -37,6 +37,15 @@ const DarkModeMask = () => { const maskRef = useRef(null); const timerRef = useRef(null); + const initTheme = () => { + const html = document.querySelector('html'); + if (html) { + html.setAttribute('data-theme', savedTheme); + } + }; + + initTheme(); + useEffect(() => { if (savedTheme === 'realDark') { setVisible(true); diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 84cb7e8f..868b56b9 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -431,7 +431,7 @@ export default (props: any) => { ...themeData }} > - +