import Link from "next/link"; import { FileText, MessageCircle, AlertCircle } from "lucide-react"; import Pagination from "@/components/Pagination"; import { IconComment, IconEye, IconHeart } from "@/components/Icons"; import type { UserProfile, UserCommentsResponse } from "@/lib/api"; /** * 用户主页内容区(纯服务端渲染): * tab 与分页全部走 URL(?tab=comments&page=N),刷新/后退/分享链接均保持一致。 */ export default function UserProfileContent({ userId, profile, tab, commentData, commentError, page, }: { userId: string; profile: UserProfile; tab: "posts" | "comments"; commentData: UserCommentsResponse | null; commentError: boolean; page: number; }) { const tabLink = (t: "posts" | "comments", label: string, count: number, icon: React.ReactNode) => { const active = tab === t; const href = t === "posts" ? `/u/${userId}` : `/u/${userId}?tab=comments`; return ( {icon} {label} {count} ); }; return (
{tabLink("posts", "发帖", profile.stats.post_count, )} {tabLink("comments", "评论", profile.stats.comment_count, )}
{tab === "posts" ? (
{profile.posts.length > 0 ? (
{profile.posts.map((post, i) => (
{post.board.name} {post.pinned > 0 && 置顶} {post.recommended && 推荐}

{post.title}

{new Date(post.created_at).toLocaleDateString("zh-CN")} {post.comment_count} {post.view_count} {post.like_count}
))}
) : (

暂无发帖

)}
) : commentError ? (

评论加载失败

网络异常,请稍后重试

重新加载
) : commentData && commentData.comments.length > 0 ? (
{commentData.comments.map((c, i) => (
评论于《{c.post_title}》

{c.content}

{new Date(c.created_at).toLocaleString("zh-CN")}
))}
) : (

暂无评论

)}
); }