From 3e7bb51618de0fde9e6d82ac8e627b64c903cd07 Mon Sep 17 00:00:00 2001 From: kurihada Date: Sat, 28 Feb 2026 17:30:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=88=BF=E9=97=B4=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E6=98=BE=E7=A4=BA=E5=85=B7=E4=BD=93?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=8E=9F=E5=9B=A0=EF=BC=8C=E4=BE=BF=E4=BA=8E?= =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/blindbox/page.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/blindbox/page.tsx b/src/app/blindbox/page.tsx index 7478b8c..3412f68 100644 --- a/src/app/blindbox/page.tsx +++ b/src/app/blindbox/page.tsx @@ -179,7 +179,7 @@ export default function BlindboxLobbyPage() { const [creating, setCreating] = useState(false); const [joining, setJoining] = useState(false); const [error, setError] = useState(""); - const [loadError, setLoadError] = useState(false); + const [loadError, setLoadError] = useState(false); const [confirmDeleteId, setConfirmDeleteId] = useState(null); const [deletingId, setDeletingId] = useState(null); @@ -193,12 +193,15 @@ export default function BlindboxLobbyPage() { } try { const res = await fetch(`/api/blindbox/rooms?userId=${p.id}`, { cache: "no-store" }); - if (!res.ok) throw new Error(); + if (!res.ok) { + const body = await res.json().catch(() => null); + throw new Error(body?.error ?? `HTTP ${res.status}`); + } const data = await res.json(); setRooms(Array.isArray(data.rooms) ? data.rooms : []); setLoadError(false); - } catch { - if (!silent) setLoadError(true); + } catch (e) { + if (!silent) setLoadError(e instanceof Error ? e.message : "未知错误"); } finally { if (!silent) setLoading(false); } @@ -434,6 +437,9 @@ export default function BlindboxLobbyPage() { >

加载房间失败

+ {typeof loadError === "string" && ( +

{loadError}

+ )}