diff --git a/app/(main)/community/page.tsx b/app/(main)/community/page.tsx index e0cb707..12798af 100644 --- a/app/(main)/community/page.tsx +++ b/app/(main)/community/page.tsx @@ -1,13 +1,33 @@ +"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 { mockPosts } from "@/lib/mock-data" +import { mockGames, mockPosts } from "@/lib/mock-data" 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 (
@@ -20,8 +40,41 @@ export default function CommunityPage() {
+
+
+ + +
+
+ {mockGames.map((game) => ( + setSelectedGame(selectedGame === game.name ? null : game.name)} + > + {game.name} + + ))} +
+
+
- {mockPosts.map((post) => ( + {filteredPosts.map((post) => ( diff --git a/app/(main)/post/new/page.tsx b/app/(main)/post/new/page.tsx index c9a8e50..1e5c1b0 100644 --- a/app/(main)/post/new/page.tsx +++ b/app/(main)/post/new/page.tsx @@ -20,6 +20,7 @@ import { SelectValue, } from "@/components/ui/select" import { Textarea } from "@/components/ui/textarea" +import { mockPosts } from "@/lib/mock-data" import { useRequireAuth } from "@/lib/use-require-auth" const postSchema = z.object({ @@ -35,6 +36,7 @@ export default function NewPostPage() { const [postType, setPostType] = useState("normal") const [selectedTags, setSelectedTags] = useState([]) const [imageCount, setImageCount] = useState(0) + const [selectedQuotePostId, setSelectedQuotePostId] = useState(undefined) const { register, @@ -104,6 +106,28 @@ export default function NewPostPage() {
)} + {postType === "quote" && ( +
+ + +
+

预览:

+

选择一个帖子以查看预览...

+
+
+ )} +