mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 09:31:55 +08:00
fix: pwa color
This commit is contained in:
parent
59ec052374
commit
66b474c5de
10
index.html
10
index.html
@ -10,6 +10,7 @@
|
|||||||
name="apple-mobile-web-app-status-bar-style"
|
name="apple-mobile-web-app-status-bar-style"
|
||||||
content="black-translucent"
|
content="black-translucent"
|
||||||
/>
|
/>
|
||||||
|
<meta name="theme-color" content="#242424" />
|
||||||
<title>NEZHA</title>
|
<title>NEZHA</title>
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
@ -17,14 +18,23 @@
|
|||||||
const theme = localStorage.getItem(storageKey) || "system";
|
const theme = localStorage.getItem(storageKey) || "system";
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
|
|
||||||
|
function updateThemeColor(isDark) {
|
||||||
|
const themeColor = isDark ? "#242424" : "#fafafa";
|
||||||
|
document
|
||||||
|
.querySelector('meta[name="theme-color"]')
|
||||||
|
.setAttribute("content", themeColor);
|
||||||
|
}
|
||||||
|
|
||||||
if (theme === "system") {
|
if (theme === "system") {
|
||||||
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
|
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
|
||||||
.matches
|
.matches
|
||||||
? "dark"
|
? "dark"
|
||||||
: "light";
|
: "light";
|
||||||
root.classList.add(systemTheme);
|
root.classList.add(systemTheme);
|
||||||
|
updateThemeColor(systemTheme === "dark");
|
||||||
} else {
|
} else {
|
||||||
root.classList.add(theme);
|
root.classList.add(theme);
|
||||||
|
updateThemeColor(theme === "dark");
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
@ -40,10 +40,18 @@ export function ThemeProvider({
|
|||||||
: "light";
|
: "light";
|
||||||
|
|
||||||
root.classList.add(systemTheme);
|
root.classList.add(systemTheme);
|
||||||
|
const themeColor = systemTheme === "dark" ? "#242424" : "#fafafa";
|
||||||
|
document
|
||||||
|
.querySelector('meta[name="theme-color"]')
|
||||||
|
?.setAttribute("content", themeColor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
root.classList.add(theme);
|
root.classList.add(theme);
|
||||||
|
const themeColor = theme === "dark" ? "#242424" : "#fafafa";
|
||||||
|
document
|
||||||
|
.querySelector('meta[name="theme-color"]')
|
||||||
|
?.setAttribute("content", themeColor);
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
|
@ -15,7 +15,7 @@ export default defineConfig({
|
|||||||
name: "哪吒面板",
|
name: "哪吒面板",
|
||||||
short_name: "哪吒",
|
short_name: "哪吒",
|
||||||
description: "哪吒监控面板",
|
description: "哪吒监控面板",
|
||||||
theme_color: "#ffffff",
|
theme_color: "#242424",
|
||||||
icons: [
|
icons: [
|
||||||
{
|
{
|
||||||
src: "pwa-192x192.png",
|
src: "pwa-192x192.png",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user