mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
chore: apply color immediately
This commit is contained in:
parent
3dc9c4b28c
commit
0d84e4b70d
@ -4,6 +4,13 @@
|
||||
<meta charset="UTF-8" />
|
||||
<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"
|
||||
const isDark = window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
if (theme === "auto" ? isDark : theme === "dark") {
|
||||
document.documentElement.classList.add("dark")
|
||||
}
|
||||
</script>
|
||||
<title>NewsNow</title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -17,12 +17,6 @@ export const Route = createRootRouteWithContext<{
|
||||
component: RootComponent,
|
||||
notFoundComponent: NotFoundComponent,
|
||||
beforeLoad: () => {
|
||||
const theme = 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")
|
||||
}
|
||||
|
||||
const query = new URLSearchParams(window.location.search)
|
||||
if (query.has("login")) {
|
||||
[...query.entries()].forEach(key => localStorage.setItem(key[0], key[1]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user