fixed bug
This commit is contained in:
1 parent
54b18039e3
commit
8c3232fadf
16 files changed
+1134
-97
No files matched your search
@@ -52,6 +52,19 @@
|
||||
}
|
||||
}
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
|
||||
// Listen for system changes
|
||||
if (window.matchMedia) {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
||||
// Only switch if user hasn't manually set a preference
|
||||
// Or maybe we should respect system change if user hasn't explicitly locked it?
|
||||
// Common behavior: manual override sticks.
|
||||
if (!localStorage.getItem('theme')) {
|
||||
var newTheme = event.matches ? "dark" : "light";
|
||||
document.documentElement.setAttribute('data-theme', newTheme);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user