docs: fix dark mode refresh miss dark attr (#47558)

* docs: fix dark mode refresh miss dark attr

* docs: fix dark mode refresh miss dark attr
This commit is contained in:
winches 2024-02-24 14:49:26 +08:00 committed by GitHub
parent 1b696510e5
commit 0a83d5b34b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -112,6 +112,10 @@ const GlobalLayout: React.FC = () => {
direction: _direction === 'rtl' ? 'rtl' : 'ltr',
// bannerVisible: storedBannerVisibleLastTime ? !!storedBannerVisible : true,
});
document.documentElement.setAttribute(
'data-prefers-color',
_theme.includes('dark') ? 'dark' : 'light',
);
// Handle isMobile
updateMobileMode();