From 05e42ffe22bc818bb148d881b3c528fee100bb2a Mon Sep 17 00:00:00 2001 From: kurihada Date: Thu, 26 Feb 2026 14:54:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=86=B3=E7=AD=96=E6=AC=A1=E6=95=B0=E5=BE=BD?= =?UTF-8?q?=E7=AB=A0=E3=80=8C=E5=B7=B2=E6=8B=AF=E6=95=91=20X=20=E6=AC=A1?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=9B=B0=E9=9A=BE=E7=97=87=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/user/route.ts | 3 +++ src/app/profile/page.tsx | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/api/user/route.ts b/src/app/api/user/route.ts index 60a8725..2719750 100644 --- a/src/app/api/user/route.ts +++ b/src/app/api/user/route.ts @@ -13,6 +13,8 @@ export async function GET(req: NextRequest) { return NextResponse.json(null); } + const decisionCount = await prisma.decision.count({ where: { userId } }); + return NextResponse.json({ id: user.id, username: user.username, @@ -20,6 +22,7 @@ export async function GET(req: NextRequest) { email: user.email, preferences: JSON.parse(user.preferences), createdAt: user.createdAt.toISOString(), + decisionCount, }); } diff --git a/src/app/profile/page.tsx b/src/app/profile/page.tsx index 0debe0e..62fe551 100644 --- a/src/app/profile/page.tsx +++ b/src/app/profile/page.tsx @@ -19,6 +19,7 @@ import { X, Eye, EyeOff, + Zap, } from "lucide-react"; import { getUserId, getCachedProfile, setCachedProfile, setCachedPreferences, logout } from "@/lib/userId"; import { getAvatarBg, AVATARS } from "@/lib/avatars"; @@ -33,7 +34,7 @@ function firstImage(r: Restaurant): string { export default function ProfilePage() { const router = useRouter(); const [userId, setUserId] = useState(""); - const [profile, setProfile] = useState<(UserProfile & { email?: string; preferences?: UserPreferences }) | null>(null); + const [profile, setProfile] = useState<(UserProfile & { email?: string; preferences?: UserPreferences; decisionCount?: number }) | null>(null); const [loading, setLoading] = useState(true); const [history, setHistory] = useState([]); @@ -333,6 +334,12 @@ export default function ProfilePage() { )} {usernameMsg &&

{usernameMsg}

} + {(profile.decisionCount ?? 0) > 0 && ( +

+ + 已拯救 {profile.decisionCount} 次选择困难症 +

+ )}