fix(theme): fixed auto theme mode for new reader window (#2238)

This commit is contained in:
Huang Xin
2025-10-15 20:36:02 +08:00
committed by GitHub
parent 854a578929
commit 126981d085
+6 -1
View File
@@ -141,7 +141,12 @@ export const loadDataTheme = () => {
const themeMode = localStorage.getItem('themeMode');
const themeColor = localStorage.getItem('themeColor');
if (themeMode && themeColor) {
document.documentElement.setAttribute('data-theme', `${themeColor}-${themeMode}`);
const systemIsDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
const isDarkMode = themeMode === 'dark' || (themeMode === 'auto' && systemIsDarkMode);
document.documentElement.setAttribute(
'data-theme',
`${themeColor}-${isDarkMode ? 'dark' : 'light'}`,
);
}
};