From 409e90d2c5ff4f2621e8eb695fc8ea2e50e4d9b6 Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Wed, 29 May 2024 14:26:20 +0800 Subject: [PATCH] fix: the issue where the auto theme is invalid due to an incorrect class setting (#5194) --- frontend/src/hooks/use-theme.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/src/hooks/use-theme.ts b/frontend/src/hooks/use-theme.ts index f56f35385..a2a137934 100644 --- a/frontend/src/hooks/use-theme.ts +++ b/frontend/src/hooks/use-theme.ts @@ -32,6 +32,9 @@ export const useTheme = () => { }; const updateTheme = (theme: string) => { + if (theme === 'auto') { + theme = prefersDark.matches ? 'dark' : 'light'; + } const body = document.documentElement as HTMLElement; body.setAttribute('class', theme); };