Fix FOUC. Again.
This commit is contained in:
parent
54f3c40e7d
commit
4d8f83a63c
1 changed files with 26 additions and 13 deletions
|
|
@ -14,19 +14,32 @@ const base = import.meta.env.BASE_URL;
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script is:inline>
|
<script is:inline>
|
||||||
|
function th() {
|
||||||
var cl = document.documentElement.classList;
|
var cl = document.documentElement.classList;
|
||||||
if ('theme' in localStorage || 'af_mode' in localStorage) {
|
af_enabled = 'af_enabled' in localStorage && localStorage.af_enabled === '1' ? true : false;
|
||||||
if (localStorage.af_enabled === '1' && localStorage.af_mode === 'df') {
|
af_mode = 'af_mode' in localStorage ? localStorage.af_mode : '';
|
||||||
|
theme = 'theme' in localStorage ? localStorage.theme : '';
|
||||||
|
|
||||||
|
if (theme === '' || theme === 'system') {
|
||||||
|
theme = window.matchMedia('(prefers-color-scheme: dark)') ? 'dark' : 'light';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (af_enabled) {
|
||||||
|
switch (af_mode) {
|
||||||
|
case 'df':
|
||||||
cl.add('df');
|
cl.add('df');
|
||||||
} else {
|
return;
|
||||||
if (localStorage.theme === 'dark' || window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
case 'hc':
|
||||||
|
cl.add('hc');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theme === 'dark') {
|
||||||
cl.add('dark');
|
cl.add('dark');
|
||||||
}
|
}
|
||||||
if (localStorage.af_enabled === '1' && localStorage.af_mode == 'hc') {
|
|
||||||
cl.add('hc');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
th();
|
||||||
</script>
|
</script>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue