diff --git a/src/app/invite/[id]/page.tsx b/src/app/invite/[id]/page.tsx index 817475a..15bed4c 100644 --- a/src/app/invite/[id]/page.tsx +++ b/src/app/invite/[id]/page.tsx @@ -29,6 +29,7 @@ export default function InvitePage() { const [userCount, setUserCount] = useState(0); const [scene, setScene] = useState("eat"); const [joining, setJoining] = useState(false); + const [joinError, setJoinError] = useState(""); const sceneConfig = getSceneConfig(scene); @@ -48,10 +49,12 @@ export default function InvitePage() { const handleJoin = async () => { setJoining(true); + setJoinError(""); try { await joinRoom(roomId, getUserId()); router.push(`/room/${roomId}`); - } catch { + } catch (e) { + setJoinError(e instanceof Error ? e.message : "加入失败,请重试"); setJoining(false); } }; @@ -187,6 +190,15 @@ export default function InvitePage() { animate={{ y: 0, opacity: 1 }} transition={{ duration: 0.5, delay: 0.3 }} > + {joinError && ( + + {joinError} + + )}