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">
|
||||
<head>
|
||||
<script is:inline>
|
||||
function th() {
|
||||
var cl = document.documentElement.classList;
|
||||
if ('theme' in localStorage || 'af_mode' in localStorage) {
|
||||
if (localStorage.af_enabled === '1' && localStorage.af_mode === 'df') {
|
||||
af_enabled = 'af_enabled' in localStorage && localStorage.af_enabled === '1' ? true : false;
|
||||
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');
|
||||
} else {
|
||||
if (localStorage.theme === 'dark' || window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
return;
|
||||
case 'hc':
|
||||
cl.add('hc');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (theme === 'dark') {
|
||||
cl.add('dark');
|
||||
}
|
||||
if (localStorage.af_enabled === '1' && localStorage.af_mode == 'hc') {
|
||||
cl.add('hc');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
th();
|
||||
</script>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue