"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 (
{type == "space" && data?.is_headed === 1 && ( )}
router.push("/profile/"+data.mid)} />
handleFollow(isFollow, data?.mid, setIsFollow)} > {data.streamer_ext?.name} {type == "post" && ( {isFollow ? "已关注" : "关注"} )}

{data.text}

{data.text?.length > 50 && (
setIsOpenText(!isOpenText)} > {isOpenText ? "收起" : "全文"}
)}
{data.media_component && } {type == "space" && !isCreator && data.c_type && ( )}
{type == "post" ? (
router.push("/profile/"+data.mid)} > {data.is_active_within_a_week ? ( <> {data.days_elapsed_since_the_last_zones_update < 7 && `空间${ data.days_elapsed_since_the_last_zones_update === 0 ? "今日" : "new" === 1 ? "昨日" : "new" === 2 ? "前天" : data.days_elapsed_since_the_last_zones_update + "天前" }有更新`} ) : ( data?.streamer_ext?.zones?.length !== 0 && (
查看TA的空间
) )}
) : (
{getDays < 3 ? `${ getDays === 0 ? "今日" : "new" === 1 ? "昨日" : "前天" }` : date.getMonth() + 1 + "月" + date.getDate() + "日"} {date.getHours() + ":" + date.getMinutes()}
)}
thumbsUp(data.id, isThumbsUp, setIsThumbsUp,type == "space")} > {isThumbsUp == 1 ? "已赞" : "点赞"}
···
{/*
*/}
); }