Merge pull request #1450 from yorunning/fix-1

fix: the theme-color selector
This commit is contained in:
Yifei Zhang
2023-05-13 14:50:54 +08:00
committed by GitHub
2 changed files with 13 additions and 15 deletions

View File

@@ -64,17 +64,17 @@ export function useSwitchTheme() {
}
const metaDescriptionDark = document.querySelector(
'meta[name="theme-color"][media]',
'meta[name="theme-color"][media*="dark"]',
);
const metaDescriptionLight = document.querySelector(
'meta[name="theme-color"]:not([media])',
'meta[name="theme-color"][media*="light"]',
);
if (config.theme === "auto") {
metaDescriptionDark?.setAttribute("content", "#151515");
metaDescriptionLight?.setAttribute("content", "#fafafa");
} else {
const themeColor = getCSSVar("--themeColor");
const themeColor = getCSSVar("--theme-color");
metaDescriptionDark?.setAttribute("content", themeColor);
metaDescriptionLight?.setAttribute("content", themeColor);
}