"use client"; import React, { useEffect, useState, useMemo } from "react"; import Photos from "../Photos"; import { useRouter } from "next/navigation"; import PaySpacePost from "../PaySpacePost"; import { Image } from "antd-mobile"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons"; import { handleFollow, thumbsUp } from "@/api/public"; import {get} from "@/utils/storeInfo" export default function PostItem({ type, follow, date = new Date(), data = {}, }) { const router = useRouter(); const [isOpenText, setIsOpenText] = useState(false); const [isFollow, setIsFollow] = useState(data.is_followed); const [isThumbsUp, setIsThumbsUp] = useState(data?.is_thumbed_up || data?.is_zone_moment_thumbed_up); //判断是否是发帖人 const [isCreator, setIsCreator] = useState(false); useEffect(() => { const account = get("account"); if (account.mid === data.mid) setIsCreator(true); return () => { router.prefetch("/profile/"+data.mid); }; }, []); const getDays = useMemo(() => { const today = new Date(); const days = Math.floor((today - data.ct) / (1000 * 60 * 60 * 24)); return days; }, []); return (
{data.text}
{data.text?.length > 50 && (