新增设置页
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { sendCaregiverTestPush } from "@/lib/push";
|
||||
import { getCaregiverDisplayName, getCaregiverSession } from "@/lib/session";
|
||||
|
||||
export async function POST() {
|
||||
const caregiver = await getCaregiverSession();
|
||||
|
||||
if (!caregiver) {
|
||||
return NextResponse.json({ error: "请先登录。" }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await sendCaregiverTestPush({
|
||||
caregiverId: caregiver.id,
|
||||
caregiverLabel: getCaregiverDisplayName(caregiver),
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
...result,
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: error instanceof Error ? error.message : "测试推送发送失败。",
|
||||
},
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import Link from "next/link";
|
||||
|
||||
import { BindDeviceForm } from "@/components/dashboard-actions";
|
||||
import { PanelShell } from "@/components/panel-shell";
|
||||
import { PwaControls } from "@/components/pwa-controls";
|
||||
import { getCaregiverDevices } from "@/lib/caregiver-panel";
|
||||
import { formatDateTime, getDeviceName, truncateText } from "@/lib/panel-format";
|
||||
import { requireCaregiverSession } from "@/lib/page-auth";
|
||||
@@ -20,7 +19,6 @@ export default async function DevicesPage() {
|
||||
title="我的设备"
|
||||
description="管理已连接的长辈设备,点击进入设备详情查看留言和使用动态。"
|
||||
caregiverLabel={getCaregiverDisplayName(caregiver)}
|
||||
actions={<PwaControls />}
|
||||
>
|
||||
<section className="grid gap-6 xl:grid-cols-[0.95fr_1.05fr]">
|
||||
<BindDeviceForm />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { PanelShell } from "@/components/panel-shell";
|
||||
import { PwaControls } from "@/components/pwa-controls";
|
||||
import { getCaregiverMessages } from "@/lib/caregiver-panel";
|
||||
import {
|
||||
formatDateTime,
|
||||
@@ -35,7 +34,6 @@ export default async function MessagesPage() {
|
||||
title="留言板"
|
||||
description="长辈捆来的话和您发出的问候,都在这里。"
|
||||
caregiverLabel={getCaregiverDisplayName(caregiver)}
|
||||
actions={<PwaControls />}
|
||||
>
|
||||
<section className="grid gap-4 md:grid-cols-3">
|
||||
<div className="rounded-[28px] border border-white/80 bg-white/88 p-5">
|
||||
|
||||
@@ -2,7 +2,6 @@ import Link from "next/link";
|
||||
import { MessageCircle, Smartphone, Activity, ScanLine } from "lucide-react";
|
||||
|
||||
import { PanelShell } from "@/components/panel-shell";
|
||||
import { PwaControls } from "@/components/pwa-controls";
|
||||
import { getCaregiverOverview } from "@/lib/caregiver-panel";
|
||||
import {
|
||||
formatDateTime,
|
||||
@@ -40,7 +39,6 @@ export default async function Home() {
|
||||
title="今日概览"
|
||||
description="随时了解长辈的近况,留言和动态一目了然。"
|
||||
caregiverLabel={getCaregiverDisplayName(dashboard.caregiver)}
|
||||
actions={<PwaControls />}
|
||||
>
|
||||
<section className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div className="rounded-[28px] border border-white/80 bg-white/88 p-5 shadow-[0_20px_50px_rgba(115,76,42,0.10)]">
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { PanelShell } from "@/components/panel-shell";
|
||||
import { PwaControls } from "@/components/pwa-controls";
|
||||
import { PushTestPanel } from "@/components/push-test-panel";
|
||||
import { getCaregiverSettingsOverview } from "@/lib/caregiver-panel";
|
||||
import { requireCaregiverSession } from "@/lib/page-auth";
|
||||
import { getCaregiverDisplayName } from "@/lib/session";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function SettingsPage() {
|
||||
const caregiver = await requireCaregiverSession("/settings");
|
||||
const overview = await getCaregiverSettingsOverview(caregiver.id);
|
||||
|
||||
return (
|
||||
<PanelShell
|
||||
currentPath="/settings"
|
||||
title="设置"
|
||||
description="桌面版安装、消息提醒和推送测试统一放在这里,不再分散显示在各个页面。"
|
||||
caregiverLabel={getCaregiverDisplayName(caregiver)}
|
||||
>
|
||||
<section className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div className="rounded-[28px] border border-white/80 bg-white/88 p-5 shadow-[0_20px_50px_rgba(115,76,42,0.10)]">
|
||||
<p className="text-sm text-[var(--muted)]">已连接设备</p>
|
||||
<p className="mt-3 font-[family-name:var(--font-display)] text-4xl text-[var(--ink)]">
|
||||
{overview.deviceCount}
|
||||
</p>
|
||||
</div>
|
||||
<div className="rounded-[28px] border border-white/80 bg-white/88 p-5 shadow-[0_20px_50px_rgba(115,76,42,0.10)]">
|
||||
<p className="text-sm text-[var(--muted)]">已开启提醒的设备</p>
|
||||
<p className="mt-3 font-[family-name:var(--font-display)] text-4xl text-[var(--ink)]">
|
||||
{overview.pushSubscriptionCount}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="grid gap-6 xl:grid-cols-2">
|
||||
<PwaControls />
|
||||
<PushTestPanel
|
||||
initialSubscriptionCount={overview.pushSubscriptionCount}
|
||||
deviceCount={overview.deviceCount}
|
||||
/>
|
||||
</section>
|
||||
</PanelShell>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user