mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-30 06:27:38 +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'],
|
css: ['~/assets/global.css'],
|
||||||
app: {
|
app: {
|
||||||
head: {
|
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: [
|
link: [
|
||||||
{
|
{
|
||||||
rel: 'stylesheet',
|
rel: 'stylesheet',
|
||||||
|
|||||||
Reference in New Issue
Block a user