Merge pull request #440 from nagisa77/codex/fix-flash-of-white-on-night-mode

fix: apply theme before render to avoid flash
This commit is contained in:
Tim
2025-08-08 17:02:58 +08:00
committed by GitHub

View File

@@ -5,6 +5,21 @@ export default defineNuxtConfig({
css: ['~/assets/global.css'],
app: {
head: {
script: [
{
tagPriority: 'high',
children: `
(function () {
try {
const mode = localStorage.getItem('theme-mode');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = mode === 'dark' || mode === 'light' ? mode : (prefersDark ? 'dark' : 'light');
document.documentElement.dataset.theme = theme;
} catch (e) {}
})();
`
}
],
link: [
{
rel: 'stylesheet',