"use client"; import React, { useEffect, useRef, useState } from "react"; import { Image, ImageViewer, Dialog } 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({ 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]; setPhotos(arr); if (arr.length > 9) { newPhotos = newPhotos.slice(0, 9); } 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: (