Add installable PWA support

This commit is contained in:
Codex committed 2026-09-17 12:43:01 +08:00
1 parent 0e118b6eaf
commit 310087ad84
4 files changed
+30 -1

No files matched your search

+5 -1
View File
@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import "./globals.css";
import PwaRegister from "./pwa-register";
export const metadata: Metadata = {
title: "大学英语六级 · 90天打卡",
@@ -8,6 +9,9 @@ export const metadata: Metadata = {
icon: "/favicon.svg",
shortcut: "/favicon.svg",
},
manifest: "/manifest.webmanifest",
applicationName: "大学英语六级 · 90天打卡",
themeColor: "#1d4ed8",
};
export default function RootLayout({
@@ -17,7 +21,7 @@ export default function RootLayout({
}>) {
return (
<html lang="zh-CN">
<body className="antialiased">{children}</body>
<body className="antialiased"><PwaRegister />{children}</body>
</html>
);
}
+3
View File
@@ -0,0 +1,3 @@
"use client";
import { useEffect } from "react";
export default function PwaRegister() { useEffect(() => { if ("serviceWorker" in navigator) navigator.serviceWorker.register("/sw.js").catch(() => undefined); }, []); return null; }
+12
View File
@@ -0,0 +1,12 @@
{
"name": "大学英语六级 · 90天打卡",
"short_name": "CET-6 打卡",
"description": "CET-6 90 天复习计划、云端打卡与复盘。",
"lang": "zh-CN",
"start_url": "/",
"scope": "/",
"display": "standalone",
"background_color": "#eef4ff",
"theme_color": "#1d4ed8",
"icons": [{ "src": "/favicon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any maskable" }]
}
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff. Show more