mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-21 22:41:05 +08:00
fix: apply theme before render to avoid flash
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user