forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #435 from yorunning/fix-1
fix: add media query to theme-color, fix auto theme not updating theme-color
This commit is contained in:
commit
15429cd67f
@ -52,11 +52,23 @@ function useSwitchTheme() {
|
|||||||
document.body.classList.add("light");
|
document.body.classList.add("light");
|
||||||
}
|
}
|
||||||
|
|
||||||
const themeColor = getComputedStyle(document.body)
|
const metaDescriptionDark = document.querySelector(
|
||||||
.getPropertyValue("--theme-color")
|
'meta[name="theme-color"][media]',
|
||||||
.trim();
|
);
|
||||||
const metaDescription = document.querySelector('meta[name="theme-color"]');
|
const metaDescriptionLight = document.querySelector(
|
||||||
metaDescription?.setAttribute("content", themeColor);
|
'meta[name="theme-color"]:not([media])',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (config.theme === "auto") {
|
||||||
|
metaDescriptionDark?.setAttribute("content", "#151515");
|
||||||
|
metaDescriptionLight?.setAttribute("content", "#fafafa");
|
||||||
|
} else {
|
||||||
|
const themeColor = getComputedStyle(document.body)
|
||||||
|
.getPropertyValue("--theme-color")
|
||||||
|
.trim();
|
||||||
|
metaDescriptionDark?.setAttribute("content", themeColor);
|
||||||
|
metaDescriptionLight?.setAttribute("content", themeColor);
|
||||||
|
}
|
||||||
}, [config.theme]);
|
}, [config.theme]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export const metadata = {
|
|||||||
description: "Your personal ChatGPT Chat Bot.",
|
description: "Your personal ChatGPT Chat Bot.",
|
||||||
appleWebApp: {
|
appleWebApp: {
|
||||||
title: "ChatGPT Next Web",
|
title: "ChatGPT Next Web",
|
||||||
statusBarStyle: "black-translucent",
|
statusBarStyle: "default",
|
||||||
},
|
},
|
||||||
themeColor: "#fafafa",
|
themeColor: "#fafafa",
|
||||||
};
|
};
|
||||||
@ -53,6 +53,11 @@ export default function RootLayout({
|
|||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
|
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
|
||||||
/>
|
/>
|
||||||
|
<meta
|
||||||
|
name="theme-color"
|
||||||
|
content="#151515"
|
||||||
|
media="(prefers-color-scheme: dark)"
|
||||||
|
/>
|
||||||
<Meta />
|
<Meta />
|
||||||
<link rel="manifest" href="/site.webmanifest"></link>
|
<link rel="manifest" href="/site.webmanifest"></link>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com"></link>
|
<link rel="preconnect" href="https://fonts.googleapis.com"></link>
|
||||||
|
Loading…
Reference in New Issue
Block a user