"use client"; import React, { useEffect, 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"; import { saveFile } from "@/utils/tools/handleFuns"; import { useRouter } from "next/navigation"; import baseRequest from "@/utils/baseRequest"; export default function Photos({ isUnlocked, mediaAmount, media, type }) { const [seeAllPhotos, setSeeAllPhotos] = useState(false); const [currentPhotos, setCurrentPhotos] = useState([]); const [photos, setPhotos] = useState([]); const router = useRouter(); const base = baseRequest(); 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) => { const mediaDom = document.createElement("div"); document.body.appendChild(mediaDom); mediaDom.className = `${ photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom" }`; ImageViewer.Multi.show({ images: photos.map((item) => item?.url), defaultIndex: index, renderFooter: (image, index) => renderFooter(photos[index]?.type == "hid", mediaDom), getContainer: mediaDom, onIndexChange: (index) => { mediaDom.className = `${ photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom" }`; }, afterClose: () => { mediaDom.remove(); }, classNames: { body: "photos-bodyBox" }, }); }; const handleShowVideo = (video) => { Dialog.className = "videoMask"; Dialog.show({ title: "", content: (