"use client"; import React, { useEffect, useRef, useState } from "react"; import { Image, ImageViewer, Dialog, Swiper } from "antd-mobile"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleUp, faClose, faSave } from "@fortawesome/free-solid-svg-icons"; const tabItems = [ { key: "commend", title: "推荐" }, { key: "follow", title: "关注" }, ]; export default function Photos({ isUnlocked, mediaAmount, media }) { const [seeAllPhotos, setSeeAllPhotos] = useState(false); const [currentPhotos, setCurrentPhotos] = useState([]); const [photos, setPhotos] = useState([]); useEffect(() => { if (media) { let imgArr = media.images.map((item) => ({ type: "img", url: item.urls?.[0], })); let videoArr = media.videos.map((item) => ({ type: "video", url: item.cover_urls?.[0], mp4: item.urls?.[0], })); let arr = [...imgArr, ...videoArr]; let newPhotos = [...arr]; if (mediaAmount && !isUnlocked) { newPhotos = Array(mediaAmount) .fill(null) .map((item, index) => { return newPhotos[index] ? newPhotos[index] : { url: newPhotos[0]?.url, type: "hid" }; }); } setPhotos(newPhotos); if (newPhotos.length > 9) { newPhotos = newPhotos.slice(0, 9); } console.log("newPhotos", newPhotos); setCurrentPhotos(newPhotos); } }, [media]); const showPhotos = (photos, index) => { ImageViewer.Multi.show({ images: photos.map((item) => item?.url), defaultIndex: index, }); }; const handleShowVideo = (video) => { Dialog.className = "videoMask"; Dialog.show({ title: "", content: (