import Link from "next/link"; import { PanelShell } from "@/components/panel-shell"; import { PwaControls } from "@/components/pwa-controls"; import { getCaregiverOverview } from "@/lib/caregiver-panel"; import { formatDateTime, getDeviceName, getImportanceLabel, getMessageHref, truncateText, } from "@/lib/panel-format"; import { requireCaregiverSession } from "@/lib/page-auth"; export const dynamic = "force-dynamic"; export default async function Home() { const caregiver = await requireCaregiverSession("/"); const { dashboard, recentIncomingMessages, recentOutgoingMessages } = await getCaregiverOverview(caregiver.id); const totalUnreadForElder = dashboard.devices.reduce( (total, device) => total + device.familyUnreadCount, 0, ); const totalUnreadForCaregiver = dashboard.devices.reduce( (total, device) => total + device.elderUnreadCount, 0, ); const totalConversations = dashboard.devices.reduce( (total, device) => total + device.elderDevice._count.conversationTurns, 0, ); return ( } >

已连接老人设备

{dashboard.devices.length}

老人给家里的未读留言

{totalUnreadForCaregiver}

待老人查看的家属留言

{totalUnreadForElder}

最近存档对话条数

{totalConversations}

{[ { href: "/messages", title: "留言中心", text: "集中看所有老人留言和家属留言,每条消息都有 URL 编号可直接打开。", tone: "bg-[rgba(53,84,141,0.12)]", }, { href: "/devices", title: "设备与绑定", text: "去管理设备、扫码绑定、查看某一台设备的专属详情页和留言入口。", tone: "bg-[rgba(118,132,94,0.14)]", }, { href: "/activity", title: "活动回看", text: "把使用事件、工具调用和对话片段拆出来,回看时不再和留言混在一起。", tone: "bg-[rgba(199,103,51,0.12)]", }, { href: "/scan", title: "扫码绑定", text: "拿起另一台手机时,直接走扫码页,不必再回首页寻找入口。", tone: "bg-[rgba(36,27,20,0.08)]", }, ].map((item) => (
跳转路径

{item.title}

{item.text}

前往 {item.href}

))}
{dashboard.devices.length === 0 ? (

还没有绑定老人设备

先去设备页或扫码页建立第一条连接

绑定完成后,留言中心会出现 URL 编号消息卡,活动页会出现陪伴记录,推送也能直达具体留言。

去设备页 直接扫码
) : (

新收到的老人留言

点一下就能按编号直达

查看全部留言
{recentIncomingMessages.length === 0 ? (

目前还没有新的老人留言。

) : ( recentIncomingMessages.map((message) => (
#{message.publicId} {getDeviceName(message.elderDevice.displayName)} {getImportanceLabel(message.importance)} {formatDateTime(message.createdAt)}

{truncateText(message.content)}

)) )}

最近发给老人的问候

发出后也能按编号回看

去设备页留言
{recentOutgoingMessages.length === 0 ? (

还没有新的家属留言,可以到设备页针对某一台设备写下问候。

) : ( recentOutgoingMessages.map((message) => (
#{message.publicId} {getDeviceName(message.elderDevice.displayName)} {getImportanceLabel(message.importance)} {formatDateTime(message.createdAt)}

{truncateText(message.content)}

)) )}
)}
); }