feat: 增加滑动参与感 - 进度条、实时气泡、热度标签
- 卡片上方显示滑动进度条和计数 (3/15)
- 轮询检测到当前卡片新增 like 时弹出"有人也想去这家!"气泡
- 卡片图片角落显示"🔥N 人想去"热度标签
- 后端 GET /api/room/[id] 新增 likeCounts 字段
This commit is contained in:
@@ -37,12 +37,20 @@ export async function GET(
|
||||
matchLikes = best.likes;
|
||||
}
|
||||
|
||||
const likeCounts: Record<string, number> = {};
|
||||
for (const [rid, users] of Object.entries(data.likes)) {
|
||||
if (users.length > 0) {
|
||||
likeCounts[rid] = users.length;
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
roomId: id,
|
||||
userCount: data.users.length,
|
||||
match,
|
||||
matchType,
|
||||
matchLikes,
|
||||
likeCounts,
|
||||
restaurants: data.restaurants,
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
@@ -14,8 +14,9 @@ export default function RoomPage() {
|
||||
const [userId, setUserId] = useState("");
|
||||
const [joined, setJoined] = useState(false);
|
||||
|
||||
const { userCount, match, matchType, matchLikes, restaurants, mutate } =
|
||||
useRoomPolling(roomId);
|
||||
const {
|
||||
userCount, match, matchType, matchLikes, likeCounts, restaurants, mutate,
|
||||
} = useRoomPolling(roomId);
|
||||
|
||||
useEffect(() => {
|
||||
const id = getUserId();
|
||||
@@ -54,6 +55,7 @@ export default function RoomPage() {
|
||||
matchedRestaurantId={match}
|
||||
matchType={matchType}
|
||||
matchLikes={matchLikes}
|
||||
likeCounts={likeCounts}
|
||||
userCount={userCount}
|
||||
onReset={handleReset}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user