2025-01-24 00:19:02 +08:00
|
|
|
import { PostDto, VisitType } from "@nice/common";
|
|
|
|
import { motion } from "framer-motion";
|
|
|
|
import dayjs from "dayjs";
|
2025-01-24 17:39:41 +08:00
|
|
|
|
2025-01-24 11:39:51 +08:00
|
|
|
import { Avatar } from "antd";
|
2025-01-24 00:19:02 +08:00
|
|
|
import { useVisitor } from "@nice/client";
|
2025-01-25 22:39:22 +08:00
|
|
|
import { useContext, useEffect, useRef, useState } from "react";
|
2025-01-24 00:19:02 +08:00
|
|
|
import { PostDetailContext } from "./context/PostDetailContext";
|
2025-01-26 16:10:31 +08:00
|
|
|
import {
|
|
|
|
CheckCircleOutlined,
|
|
|
|
CheckOutlined,
|
|
|
|
LikeFilled,
|
|
|
|
LikeOutlined,
|
|
|
|
} from "@ant-design/icons";
|
2025-01-25 00:46:59 +08:00
|
|
|
import PostLikeButton from "./PostHeader/PostLikeButton";
|
|
|
|
import { CustomAvatar } from "@web/src/components/presentation/CustomAvatar";
|
2025-01-25 19:51:08 +08:00
|
|
|
import PostResources from "./PostResources";
|
2025-01-26 16:10:31 +08:00
|
|
|
import PostHateButton from "./PostHeader/PostHateButton";
|
2025-01-26 18:24:16 +08:00
|
|
|
import PostSendButton from "./PostHeader/PostSendButton";
|
2025-01-26 20:26:12 +08:00
|
|
|
import { getCompressedImageUrl } from "@nice/utils";
|
2025-01-24 00:19:02 +08:00
|
|
|
|
|
|
|
export default function PostCommentCard({
|
|
|
|
post,
|
|
|
|
index,
|
2025-01-24 17:39:41 +08:00
|
|
|
isReceiverComment,
|
2025-01-24 00:19:02 +08:00
|
|
|
}: {
|
|
|
|
post: PostDto;
|
|
|
|
index: number;
|
2025-01-24 15:06:57 +08:00
|
|
|
isReceiverComment: boolean;
|
2025-01-24 00:19:02 +08:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<motion.div
|
2025-01-26 10:49:23 +08:00
|
|
|
className={` rounded-xl border p-6 bg-slate-100 border-white ring-white hover:ring-1 transition-all duration-300 ease-in-out`}
|
2025-01-24 00:19:02 +08:00
|
|
|
layout>
|
2025-01-25 22:39:22 +08:00
|
|
|
<div className="flex items-start space-x-2 gap-2">
|
2025-01-24 00:19:02 +08:00
|
|
|
<div className="flex-shrink-0">
|
2025-05-01 19:11:49 +08:00
|
|
|
<a href={post.author?.meta?.photoUrl}>
|
2025-05-05 19:51:44 +08:00
|
|
|
{/* {post.author?.meta?.photoUrl} */}
|
2025-05-01 19:11:49 +08:00
|
|
|
</a>
|
2025-01-25 00:46:59 +08:00
|
|
|
<CustomAvatar
|
2025-01-26 19:43:26 +08:00
|
|
|
src={post.author?.meta?.photoUrl}
|
2025-01-25 22:39:22 +08:00
|
|
|
size={50}
|
2025-01-26 20:26:12 +08:00
|
|
|
name={
|
|
|
|
!post.author?.meta?.photoUrl &&
|
|
|
|
post.author?.showname
|
|
|
|
}
|
2025-01-26 19:33:45 +08:00
|
|
|
randomString={
|
|
|
|
post?.meta?.signature || post?.meta?.ip
|
|
|
|
}></CustomAvatar>
|
2025-01-24 00:19:02 +08:00
|
|
|
</div>
|
2025-01-25 22:39:22 +08:00
|
|
|
<div className="flex-1">
|
|
|
|
<div className={`flex-1 min-w-0 `}>
|
|
|
|
<div className="flex flex-1 justify-between ">
|
2025-01-26 08:26:17 +08:00
|
|
|
<div className="flex items-center space-x-2">
|
2025-01-25 22:39:22 +08:00
|
|
|
<span className="flex font-medium text-slate-900">
|
2025-01-26 19:33:45 +08:00
|
|
|
{post?.meta?.signature ||
|
|
|
|
post.author?.showname ||
|
|
|
|
"匿名用户"}
|
2025-01-25 22:39:22 +08:00
|
|
|
</span>
|
|
|
|
<span className="flex text-sm text-slate-500 ">
|
|
|
|
{dayjs(post?.createdAt).format(
|
|
|
|
"YYYY-MM-DD HH:mm"
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
{isReceiverComment && (
|
2025-01-26 10:49:23 +08:00
|
|
|
<span className=" text-sm text-primary flex gap-2 font-bold">
|
|
|
|
<CheckOutlined></CheckOutlined>
|
2025-01-26 08:26:17 +08:00
|
|
|
官方回复
|
2025-01-25 23:29:46 +08:00
|
|
|
</span>
|
2025-01-25 00:46:59 +08:00
|
|
|
)}
|
2025-01-25 22:39:22 +08:00
|
|
|
</div>
|
|
|
|
{/* 添加有帮助按钮 */}
|
|
|
|
<div>
|
|
|
|
<div className="flex justify-center items-center gap-2">
|
2025-01-26 18:24:16 +08:00
|
|
|
{isReceiverComment && (
|
|
|
|
<PostSendButton
|
|
|
|
post={post}></PostSendButton>
|
|
|
|
)}
|
2025-01-26 16:10:31 +08:00
|
|
|
<PostHateButton
|
|
|
|
post={post}></PostHateButton>
|
2025-01-26 18:32:47 +08:00
|
|
|
<PostLikeButton
|
|
|
|
post={post}></PostLikeButton>
|
2025-01-26 18:24:16 +08:00
|
|
|
<span className=" text-sm text-slate-500">{`#${index + 1}`}</span>
|
2025-01-25 19:51:08 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-01-25 00:46:59 +08:00
|
|
|
|
2025-01-25 22:39:22 +08:00
|
|
|
<div
|
2025-01-26 12:48:10 +08:00
|
|
|
className="ql-editor text-slate-800 mt-1 text-base mb-2"
|
2025-01-25 22:39:22 +08:00
|
|
|
style={{
|
|
|
|
padding: 0,
|
|
|
|
}}
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: post.content || "",
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<PostResources post={post}></PostResources>
|
|
|
|
</div>
|
2025-01-24 00:19:02 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</motion.div>
|
|
|
|
);
|
|
|
|
}
|