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 { formatRelative } from "@/lib/format"; import type { UserProfile, UserCommentsResponse } from "@/lib/api"; /** 本页卡片统一阴影;用 color-mix 让暗色主题自动加深,避免写死浅色阴影 */ const CARD_SHADOW = "0 1px 3px color-mix(in srgb, #000 18%, transparent)"; const ITEM_BASE = "group block rounded-xl px-6 py-5 border transition-[background-color,box-shadow,border-color] duration-150"; /** * 用户主页内容区(纯服务端渲染): * tab 与分页全部走 URL(?tab=comments&page=N),刷新/后退/分享链接均保持一致。 * Tab 切换栏已移至 page.tsx 统一渲染(含 settings / security),此组件仅负责 posts / comments 列表。 */ export default function UserProfileContent({ userId, profile, tab, commentData, commentError, page, allowComments = true, }: { userId: string; profile: UserProfile; tab: "posts" | "comments"; commentData: UserCommentsResponse | null; commentError: boolean; page: number; allowComments?: boolean; }) { return (
{tab === "posts" ? (
{Array.isArray(profile.posts) && profile.posts.length > 0 ? (
{profile.posts.map((post) => { const pinned = post.pinned > 0; return (
{pinned && ( 置顶 )}

{post.title}

{post.recommended && 推荐}
{post.board.name} {formatRelative(post.created_at)} {allowComments ? ( {post.comment_count} 评论 ) : null} {post.view_count} 浏览 {post.like_count} 点赞
); })}
) : (

暂无发帖

)}
) : commentError ? (

评论加载失败

网络异常,请稍后重试

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

{c.content}

{formatRelative(c.created_at)}
))}
) : (

暂无评论

)}
); }