添加账号系统

This commit is contained in:
2026-04-17 12:58:38 +08:00
parent 032e207888
commit d3b03cecf2
27 changed files with 931 additions and 254 deletions
+44 -3
View File
@@ -3,7 +3,7 @@ import { redirect } from "next/navigation";
import { bindDeviceToCaregiver } from "@/lib/monitor-data";
import {
buildCaregiverSessionBootstrapPath,
buildCaregiverLoginPath,
getCaregiverSession,
} from "@/lib/session";
@@ -58,13 +58,54 @@ export default async function BindPage({ searchParams }: BindPageProps) {
if (!caregiver) {
redirect(
buildCaregiverSessionBootstrapPath(
buildCaregiverLoginPath(
`/bind?deviceUuid=${encodeURIComponent(rawDeviceValue)}`,
),
);
}
const device = await bindDeviceToCaregiver(caregiver.id, rawDeviceValue);
let device: Awaited<ReturnType<typeof bindDeviceToCaregiver>> | null = null;
let bindError: string | null = null;
try {
device = await bindDeviceToCaregiver(caregiver.id, rawDeviceValue);
} catch (error) {
bindError =
error instanceof Error ? error.message : "绑定失败,请稍后再试。";
}
if (!device) {
return (
<main className="mx-auto flex min-h-screen max-w-3xl items-center px-4 py-8 sm:px-6">
<section className="w-full rounded-[36px] border border-white/70 bg-white/84 p-8 shadow-[0_30px_70px_rgba(115,76,42,0.14)] backdrop-blur">
<p className="text-sm font-medium tracking-[0.18em] text-[var(--copper)] uppercase">
暂时没连上
</p>
<h1 className="mt-4 font-[family-name:var(--font-display)] text-4xl text-[var(--ink)]">
这次还没能完成设备连接
</h1>
<p className="mt-4 text-base leading-8 text-[var(--muted)]">
{bindError || "请重新扫码,或请长辈重新打开设备连接页面后再试一次。"}
</p>
<div className="mt-6 flex flex-wrap gap-3">
<Link
href="/scan"
className="inline-flex h-12 items-center justify-center rounded-full bg-[var(--copper)] px-5 text-sm font-semibold text-white transition hover:bg-[var(--copper-deep)]"
>
重新扫码
</Link>
<Link
href="/devices"
className="inline-flex h-12 items-center justify-center rounded-full border border-[var(--line)] bg-white px-5 text-sm font-semibold text-[var(--ink)] transition hover:bg-[var(--paper-soft)]"
>
返回设备页
</Link>
</div>
</section>
</main>
);
}
return (
<main className="mx-auto flex min-h-screen max-w-3xl items-center px-4 py-8 sm:px-6">