import { useContext } from "react"; import { PostDetailContext } from "./context/PostDetailContext"; import { motion } from "framer-motion"; import { CalendarIcon, UserCircleIcon, LockClosedIcon, LockOpenIcon, StarIcon, ClockIcon, EyeIcon, ChatBubbleLeftIcon, } from "@heroicons/react/24/outline"; import { Button, Typography, Space, Tooltip } from "antd"; import { useVisitor } from "@nice/client"; import { PostState, VisitType } from "@nice/common"; import { CalendarOutlined, ClockCircleOutlined, CommentOutlined, EyeOutlined, FileTextOutlined, FolderOutlined, LikeFilled, LikeOutlined, LockOutlined, UnlockOutlined, UserOutlined, } from "@ant-design/icons"; import dayjs from "dayjs"; import { TitleSection } from "./PostHeader/TitleSection"; import { AuthorBadge, DateBadge, TermBadge, UpdatedBadge, VisibilityBadge, } from "./PostHeader/InfoBadge"; import { StatsSection } from "./PostHeader/StatsSection"; import { PostBadge } from "./badge/PostBadge"; const { Title, Paragraph, Text } = Typography; export default function PostHeader() { const { post, user } = useContext(PostDetailContext); const { like, unLike } = useVisitor(); function likeThisPost() { if (!post?.liked) { post.likes += 1; post.liked = true; like.mutateAsync({ data: { visitorId: user?.id || null, postId: post.id, type: VisitType.LIKE, }, }); } else { post.likes -= 1; post.liked = false; unLike.mutateAsync({ where: { visitorId: user?.id || null, postId: post.id, type: VisitType.LIKE, }, }); } } return ( {/* Corner Decorations */}
{/* Title Section */}
{/* 收件人信息行 */} 收件人: {post?.receivers?.map((receiver) => receiver?.showname)} {/* First Row - Basic Info */}
{/* Author Info Badge */} 发件人: {post?.author?.showname || "匿名用户"} | {/* Date Info Badge */} 创建于: {dayjs(post?.createdAt).format("YYYY-MM-DD")} | {/* Last Updated Badge */} 更新于: {dayjs(post?.updatedAt).format("YYYY-MM-DD")} | {/* Visibility Status Badge */} {post?.isPublic ? ( ) : ( )} {post?.isPublic ? "公开" : "私信"}
{/* Second Row - Term and Tags */}
{/* Tags Badges */} {post?.meta?.tags && post.meta.tags.length > 0 && post.meta.tags.map((tag, index) => ( ))}
{/* Content Section */}
{/* Stats Section */} ); }