Fix flash of wrong theme on initial UI load (#485)

Co-authored-by: Tonya <tonya@tokia.dev>
This commit is contained in:
FjellOverflow
2025-01-23 03:29:19 +02:00
committed by GitHub
parent f317bb6d88
commit a6b25f7a1c
2 changed files with 15 additions and 0 deletions

View File

@@ -20,6 +20,12 @@ export default defineNuxtConfig({
},
},
app: {
head: {
script: [{ src: "/set-theme.js" }],
},
},
css: ["@/assets/css/main.css"],
pwa: {

View File

@@ -0,0 +1,9 @@
try {
console.log('Setting theme');
const theme = JSON.parse(
localStorage.getItem('homebox/preferences/location')
).theme;
if (theme) document.documentElement.setAttribute('data-theme', theme);
} catch (e) {
console.error('Failed to set theme', e);
}