From c7766edb01d393502319221b567e23fc652c013d Mon Sep 17 00:00:00 2001 From: xy <10816187@qq.com> Date: Mon, 13 Jul 2026 16:06:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E6=9A=97=E8=89=B2?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=97=B6=20=20meta=20theme-color=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E4=BF=AE=E6=94=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ThemeIcon.astro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ThemeIcon.astro b/src/components/ThemeIcon.astro index 2371e30..4f84c41 100644 --- a/src/components/ThemeIcon.astro +++ b/src/components/ThemeIcon.astro @@ -54,12 +54,12 @@ if (theme === 'light') { document.documentElement.classList.remove('dark'); + meta.setAttribute('content', '#ffffff'); } else { document.documentElement.classList.add('dark'); + meta.setAttribute('content', '#0a0a0a'); } - meta.setAttribute('content', theme === 'dark' ? '#0a0a0a' : '#ffffff'); - window.localStorage.setItem('theme', theme); const handleToggleClick = () => { @@ -67,6 +67,7 @@ element.classList.toggle("dark"); const isDark = element.classList.contains("dark"); + meta.setAttribute('content', isDark ? '#0a0a0a' : '#ffffff'); localStorage.setItem("theme", isDark ? "dark" : "light"); }