"use client" import { ClipboardList, Heart, MessageCircle, PenSquare, Pin } from "lucide-react" import Link from "next/link" import { useState } from "react" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card" import { roleLabels } from "@/lib/constants" import { mockGames, mockPosts } from "@/lib/mock" export default function CommunityPage() { const [sortMode, setSortMode] = useState<"latest" | "hot">("latest") const [selectedGame, setSelectedGame] = useState(null) const filteredPosts = mockPosts .filter((post) => { if (!selectedGame) return true return post.tags.includes(selectedGame) }) .sort((a, b) => { if (sortMode === "latest") { return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() } const scoreA = a.likeCount + a.commentCount const scoreB = b.likeCount + b.commentCount return scoreB - scoreA }) return (

社区

{mockGames.map((game) => ( setSelectedGame(selectedGame === game.name ? null : game.name)} > {game.name} ))}
{filteredPosts.map((post) => (
{post.author.nickname[0]}
{post.author.nickname} {roleLabels[post.authorRole]} {post.pinned && }
{new Date(post.createdAt).toLocaleDateString("zh-CN")}

{post.title}

{post.content}

{post.tags.length > 0 && (
{post.tags.map((tag) => ( {tag} ))}
)} {post.linkedOrderId && (
关联订单秀单
)}
{post.likeCount} {post.commentCount}
))}
) }