export async function joinRoom(roomId: string, userId: string): Promise { const res = await fetch(`/api/room/${roomId}/join`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ userId }), }); if (!res.ok) { const data = await res.json().catch(() => ({})); throw new Error(data.error || "加入房间失败"); } }