chore: minor changes

This commit is contained in:
Ou
2024-10-19 13:15:48 +08:00
parent 179358c919
commit 89fe57c5a2
5 changed files with 173 additions and 40 deletions
+8 -1
View File
@@ -5,7 +5,14 @@
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>
const theme = localStorage.getItem("color-scheme") || "auto"
function safeParseString(str) {
try {
return JSON.parse(str)
} catch {
return ""
}
}
const theme = safeParseString(localStorage.getItem("color-scheme")) || "auto"
const isDark = window.matchMedia("(prefers-color-scheme: dark)").matches
if (theme === "auto" ? isDark : theme === "dark") {
document.documentElement.classList.add("dark")