diff --git a/app/(main)/user/[id]/page.tsx b/app/(main)/user/[id]/page.tsx new file mode 100644 index 0000000..93e6da6 --- /dev/null +++ b/app/(main)/user/[id]/page.tsx @@ -0,0 +1,159 @@ +import { MessageSquare, Star, ThumbsUp } from "lucide-react" +import Link from "next/link" +import { notFound } from "next/navigation" +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" +import { Badge } from "@/components/ui/badge" +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" +import { mockFavorites, mockPlayers, mockPosts, mockShops, mockUsers } from "@/lib/mock-data" + +export default async function UserProfilePage({ params }: { params: Promise<{ id: string }> }) { + const { id } = await params + const user = mockUsers.find((u) => u.id === id) + + if (!user) { + notFound() + } + + const userPosts = mockPosts.filter((p) => p.author.id === user.id) + const userFavorites = mockFavorites.filter((f) => f.userId === user.id) + const favoritePlayers = userFavorites + .filter((f) => f.targetType === "player") + .map((f) => mockPlayers.find((p) => p.id === f.targetId)) + .filter((p): p is NonNullable => p != null) + const favoriteShops = userFavorites + .filter((f) => f.targetType === "shop") + .map((f) => mockShops.find((s) => s.id === f.targetId)) + .filter((s): s is NonNullable => s != null) + + return ( +
+
+ + + {user.nickname[0]} + +
+

{user.nickname}

+

{user.bio || "这个人很懒,什么都没写~"}

+
+ {userPosts.length} 帖子 + {userFavorites.length} 收藏 +
+
+
+ + + + 帖子 + 收藏 + + + + {userPosts.length === 0 ? ( +
暂无帖子
+ ) : ( + userPosts.map((post) => ( + + + +
+ {post.title} + {post.pinned && 置顶} +
+
+ +

+ {post.content} +

+
+ + + {post.likeCount} + + + + {post.commentCount} + + {new Date(post.createdAt).toLocaleDateString("zh-CN")} +
+
+
+ + )) + )} +
+ + + {favoritePlayers.length > 0 && ( +
+

收藏的打手

+
+ {favoritePlayers.map((player) => ( + + + + + + {player.user.nickname[0]} + +
+

{player.user.nickname}

+
+ + {player.rating} + · + {player.totalOrders}单 +
+
+ + {player.status === "available" ? "可接单" : "忙碌"} + +
+
+ + ))} +
+
+ )} + + {favoriteShops.length > 0 && ( +
+

收藏的店铺

+
+ {favoriteShops.map((shop) => ( + + + + + + {shop.name[0]} + +
+

{shop.name}

+
+ + {shop.rating} + · + {shop.totalOrders}单 +
+
+
+
+ + ))} +
+
+ )} + + {favoritePlayers.length === 0 && favoriteShops.length === 0 && ( +
暂无收藏
+ )} +
+
+
+ ) +} diff --git a/components/header.tsx b/components/header.tsx index 3bd8c81..9d27eea 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -142,14 +142,18 @@ export function Header() { {currentUser.nickname} - {currentRole === "player" && ( - - - - 个人主页 - - - )} + + + + 个人主页 + +