diff --git a/src/app/sw.ts b/src/app/sw.ts index ddb9afc5..e35c1510 100644 --- a/src/app/sw.ts +++ b/src/app/sw.ts @@ -17,9 +17,9 @@ * - clientsClaim: true 新 SW 立即接管所有打开的 client * - navigationPreload: 用 preload API 加速文档请求(资源请求 SW 完成前先发) * - * Offline fallback:`/~offline` 路由(next.config.ts Serwist 配置里也登记了 - * `additionalPrecacheEntries`,双保险)。注意本项目目前**没实现**这个路由, - * 真要落地需要新增 src/app/~/offline/page.tsx —— 未做。 + * Offline fallback:`/~offline` 路由(serwist route handler 里也登记了 + * `additionalPrecacheEntries`,双保险)。对应页面: + * `src/app/~offline/page.tsx`。 */ import { defaultCache } from "@serwist/turbopack/worker"; import type { PrecacheEntry, SerwistGlobalConfig } from "serwist"; @@ -51,4 +51,4 @@ const serwist = new Serwist({ }, }); -serwist.addEventListeners(); \ No newline at end of file +serwist.addEventListeners(); diff --git a/src/app/~offline/page.tsx b/src/app/~offline/page.tsx new file mode 100644 index 00000000..cf412b6b --- /dev/null +++ b/src/app/~offline/page.tsx @@ -0,0 +1,84 @@ +import Link from "next/link"; + +import { ROUTES } from "@/router/routes"; + +export default function OfflinePage() { + return ( +
+
+

+ Offline +

+

+ You are offline +

+

+ Check your connection, then return to CozSweet when the network is + available again. +

+ + Back to start + +
+
+ ); +}