07541ed686
- useGeolocation: 将 PanicPage 中 ~50 行 GPS 定位逻辑(requestGps + reverseGeocode + 状态管理)提取为独立 hook - joinRoom: 统一 3 处重复的 POST /api/room/:id/join 调用(room、invite、panic 页面)
12 lines
386 B
TypeScript
12 lines
386 B
TypeScript
export async function joinRoom(roomId: string, userId: string): Promise<void> {
|
|
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 || "加入房间失败");
|
|
}
|
|
}
|