forked from open-webui/open-webui
main #2
1 changed files with 18 additions and 2 deletions
20
src/app.html
20
src/app.html
|
@ -13,13 +13,29 @@
|
||||||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: light)').matches)
|
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: light)').matches)
|
||||||
) {
|
) {
|
||||||
document.documentElement.classList.add('light');
|
document.documentElement.classList.add('light');
|
||||||
} else if (localStorage.theme) {
|
} else if (localStorage.theme && localStorage.theme !== 'system') {
|
||||||
localStorage.theme.split(' ').forEach((e) => {
|
localStorage.theme.split(' ').forEach((e) => {
|
||||||
document.documentElement.classList.add(e);
|
document.documentElement.classList.add(e);
|
||||||
});
|
});
|
||||||
} else {
|
} else if (localStorage.theme && localStorage.theme === 'system') {
|
||||||
|
systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
document.documentElement.classList.add(systemTheme ? 'dark' : 'light');
|
||||||
|
}
|
||||||
|
else {
|
||||||
document.documentElement.classList.add('dark');
|
document.documentElement.classList.add('dark');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').addListener((e) => {
|
||||||
|
if (localStorage.theme === 'system') {
|
||||||
|
if (e.matches) {
|
||||||
|
document.documentElement.classList.add('dark');
|
||||||
|
document.documentElement.classList.remove('light');
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.add('light');
|
||||||
|
document.documentElement.classList.remove('dark');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
|
|
Loading…
Reference in a new issue