Skip to content

Commit 3bf1011

Browse files
committed
pref: pwa
1 parent ed1c57c commit 3bf1011

File tree

7 files changed

+7
-1
lines changed

7 files changed

+7
-1
lines changed

Diff for: astro.config.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export default defineConfig({
5353
lang: "zh-cn",
5454
short_name: "ChatGPT",
5555
background_color: "#f6f8fa",
56-
theme_color: "#f6f8fa",
5756
icons: [
5857
{
5958
src: "192.png",

Diff for: public/1024.png

16.7 KB
Loading

Diff for: public/192.png

1.03 KB
Loading

Diff for: public/256.png

1.61 KB
Loading

Diff for: public/512.png

4.18 KB
Loading

Diff for: src/components/ThemeToggle.astro

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838

3939
function listener() {
4040
document.documentElement.classList.toggle("dark", darkSchema?.matches)
41+
document
42+
.querySelector('meta[name="theme-color"]')
43+
.setAttribute("content", darkSchema?.matches ? "#16161a" : "#f6f8fa")
4144
}
4245

4346
if (persistentTheme) {
@@ -55,6 +58,9 @@
5558
element.classList.toggle("dark")
5659

5760
const isDark = element.classList.contains("dark")
61+
document
62+
.querySelector('meta[name="theme-color"]')
63+
.setAttribute("content", isDark ? "#16161a" : "#f6f8fa")
5864
darkSchema.removeEventListener("change", listener)
5965
localStorage.setItem("theme", isDark ? "dark" : "light")
6066
}

Diff for: src/layouts/Layout.astro

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const { title } = Astro.props
1919
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="192x192" />
2020
<meta name="generator" content={Astro.generator} />
2121
<title>{title}</title>
22+
<meta name="theme-color" content="#f6f8fa">
2223
<script src="/src/pwa.ts"></script>
2324
{pwaInfo && <Fragment set:html={pwaInfo.webManifest.linkTag} />}
2425
</head>

0 commit comments

Comments
 (0)