fix: 移除静默 fallback 数据,API 失败时明确提示用户
This commit is contained in:
+8
-7
@@ -153,20 +153,21 @@ export default function LandingPage() {
|
||||
body: JSON.stringify({ ...coords, radius, priceRange, cuisine, userId: getUserId() }),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error("创建房间失败");
|
||||
throw new Error(data.error || "创建房间失败");
|
||||
}
|
||||
|
||||
const { roomId } = await res.json();
|
||||
if (!roomId) {
|
||||
if (!data.roomId) {
|
||||
throw new Error("创建房间失败");
|
||||
}
|
||||
|
||||
setLoadingText("正在进入房间...");
|
||||
await joinRoom(roomId);
|
||||
router.push(`/room/${roomId}`);
|
||||
} catch {
|
||||
setError("创建失败,请重试");
|
||||
await joinRoom(data.roomId);
|
||||
router.push(`/room/${data.roomId}`);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : "创建失败,请重试");
|
||||
setLoading(false);
|
||||
setLoadingText("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user