mirror of
https://github.com/Buriburizaem0n/nezha-dash-v1.git
synced 2026-09-19 09:40:14 +00:00
83 lines
2.9 KiB
HTML
83 lines
2.9 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<script>
|
|
;(() => {
|
|
const storageKey = "vite-ui-theme"
|
|
const root = document.documentElement
|
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)")
|
|
|
|
const resolveTheme = (theme) =>
|
|
theme === "system" ? (mediaQuery.matches ? "dark" : "light") : theme
|
|
|
|
function updateThemeColor(nextTheme) {
|
|
const themeColor = nextTheme === "dark" ? "hsl(30 15% 8%)" : "hsl(0 0% 98%)"
|
|
let meta = document.querySelector('meta[name="theme-color"]')
|
|
|
|
if (!meta) {
|
|
meta = document.createElement("meta")
|
|
meta.setAttribute("name", "theme-color")
|
|
document.head.appendChild(meta)
|
|
}
|
|
|
|
meta.setAttribute("content", themeColor)
|
|
}
|
|
|
|
function applyResolvedTheme(resolvedTheme) {
|
|
root.classList.remove("light", "dark")
|
|
root.classList.add(resolvedTheme)
|
|
root.style.colorScheme = resolvedTheme
|
|
root.style.backgroundColor =
|
|
resolvedTheme === "dark" ? "hsl(30 15% 8%)" : "hsl(0 0% 98%)"
|
|
updateThemeColor(resolvedTheme)
|
|
}
|
|
|
|
let theme = "system"
|
|
|
|
try {
|
|
const storedTheme = localStorage.getItem(storageKey)
|
|
if (storedTheme === "light" || storedTheme === "dark" || storedTheme === "system") {
|
|
theme = storedTheme
|
|
}
|
|
} catch (_e) {
|
|
theme = "system"
|
|
}
|
|
|
|
applyResolvedTheme(resolveTheme(theme))
|
|
|
|
// Add loaded class after React has mounted
|
|
window.addEventListener("load", () => {
|
|
const root = document.getElementById("root")
|
|
if (root) {
|
|
// 使用 RAF 确保在下一帧渲染
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
root.classList.add("loaded")
|
|
})
|
|
})
|
|
}
|
|
})
|
|
})()
|
|
</script>
|
|
<meta charset="UTF-8" />
|
|
<link rel="icon" type="image/png" href="/apple-touch-icon.png" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>哪吒监控 Nezha Monitoring</title>
|
|
|
|
<!-- PWA -->
|
|
<link rel="manifest" href="/manifest.json" />
|
|
<meta name="theme-color" content="hsl(0 0% 98%)" />
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
|
<meta name="apple-mobile-web-app-title" content="Nezha Monitoring" />
|
|
<link rel="apple-touch-icon" href="/android-chrome-192x192.png" />
|
|
|
|
<link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/lipis/flag-icons@7.0.0/css/flag-icons.min.css" />
|
|
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/font-logos@1/assets/font-logos.css" />
|
|
</head>
|
|
<body>
|
|
<div id="root"></div>
|
|
<script type="module" src="/src/main.tsx"></script>
|
|
</body>
|
|
</html>
|