From 2cf1fae21dd4db98577c6b6e5c9198d9c2fbb01a Mon Sep 17 00:00:00 2001 From: feie9456 Date: Fri, 17 Apr 2026 14:06:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20pwa=20=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/layout.tsx | 4 +- app/manifest.ts | 4 +- components/pwa-controls.tsx | 75 ++++++++++++++++++++++--------------- public/sw.js | 2 +- 4 files changed, 50 insertions(+), 35 deletions(-) diff --git a/app/layout.tsx b/app/layout.tsx index d403bf9..5171711 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -16,7 +16,7 @@ const displayFont = Noto_Serif_SC({ export const metadata: Metadata = { metadataBase: new URL("https://digital-human.xn--876a.net"), - title: "安智伴 - 家人连线台", + title: "安智伴 家人连线台", description: "随时了解长辈的近况,查看留言、使用动态,给长辈写问候。", manifest: "/manifest.webmanifest", icons: { @@ -44,7 +44,7 @@ export const metadata: Metadata = { appleWebApp: { capable: true, statusBarStyle: "default", - title: "安智伴 - 家人连线台", + title: "安智伴 家人连线台", }, }; diff --git a/app/manifest.ts b/app/manifest.ts index 3785dba..d74ff87 100644 --- a/app/manifest.ts +++ b/app/manifest.ts @@ -2,8 +2,8 @@ import type { MetadataRoute } from "next"; export default function manifest(): MetadataRoute.Manifest { return { - name: "安智伴 - 家人连线台", - short_name: "安智伴 - 家人连线台", + name: "安智伴 家人连线台", + short_name: "安智伴 家人连线台", description: "随时了解长辈的近况,查看留言、使用动态,给长辈写问候。", start_url: "/", display: "standalone", diff --git a/components/pwa-controls.tsx b/components/pwa-controls.tsx index f751a6a..e4260f6 100644 --- a/components/pwa-controls.tsx +++ b/components/pwa-controls.tsx @@ -73,6 +73,13 @@ export function PwaControls() { const [notificationState, setNotificationState] = useState("checking"); const [notice, setNotice] = useState(null); + const isInstalled = hasInstalledHint || isStandalone; + const notificationLabel = + notificationState === "enabled" + ? "消息提醒已开启" + : notificationState === "blocked" + ? "通知权限已被拒绝" + : "消息提醒未开启"; useEffect(() => { let active = true; @@ -309,48 +316,56 @@ export function PwaControls() { return (

- 快捷设置 + {isInstalled ? "桌面版" : "快捷设置"}

- 安装到桌面,随时收到长辈的消息 + {isInstalled + ? isStandalone + ? "已从桌面版打开" + : "这台设备已添加到主屏幕" + : "安装到桌面,随时收到长辈的消息"}

- 安装后打开更快,开启提醒后,长辈每次留言都能立刻收到通知。 + {isInstalled + ? notificationState === "enabled" + ? "新留言会直接推送到这台设备。" + : "如需新留言提醒,可在下方开启通知。" + : "安装后打开更快,开启提醒后,长辈每次留言都能立刻收到通知。"}

+ {isInstalled ? ( + + {isStandalone ? "桌面版运行中" : "已添加到主屏幕"} + + ) : ( + <> + + {isStandalone ? "当前正以桌面应用方式运行" : "当前正以浏览器方式运行"} + + + {hasInstalledHint ? "这台设备已有主屏幕安装记录" : "暂未检测到主屏幕安装记录"} + + + )} - {isStandalone ? "当前正以桌面应用方式运行" : "当前正以浏览器方式运行"} - - - {hasInstalledHint ? "这台设备已有主屏幕安装记录" : "暂未检测到主屏幕安装记录"} - - - {notificationState === "enabled" - ? "消息提醒已开启" - : notificationState === "blocked" - ? "通知权限已被拒绝" - : "消息提醒未开启"} + {notificationLabel}
- + {!isInstalled ? ( + + ) : null} {notificationState === "enabled" ? (