import { ArrowPath, ChevronLeft, ChevronRight } from '@/components/HeroIcons' import LazyImage from '@/components/LazyImage' import { compressImage } from '@/lib/notion/mapImage' import { Dialog, Transition } from '@headlessui/react' import Link from 'next/link' import { Fragment, useRef, useState } from 'react' import { usePlogGlobal } from '..' /** * 弹出框 */ export default function Modal(props) { const { showModal, setShowModal, modalContent, setModalContent } = usePlogGlobal() const { siteInfo, posts } = props const cancelButtonRef = useRef(null) const thumbnail = modalContent?.pageCoverThumbnail || siteInfo?.pageCoverThumbnail const bigImage = compressImage( modalContent?.pageCover || siteInfo?.pageCover, 1200, 85, 'webp' ) const imgRef = useRef(null) // 添加loading状态 const [loading, setLoading] = useState(true) // 在图片加载完成时设置loading为false function handleImageLoad() { setLoading(false) } // 关闭弹窗 function handleClose() { setShowModal(false) setLoading(true) } // 修改当前显示的遮罩内容 function prev() { setLoading(true) const index = posts?.findIndex(post => post.slug === modalContent.slug) if (index === 0) { setModalContent(posts[posts.length - 1]) } else { setModalContent(posts[index - 1]) } } // 下一个 const next = () => { setLoading(true) const index = posts.findIndex(post => post.slug === modalContent.slug) if (index === posts.length - 1) { setModalContent(posts[0]) } else { setModalContent(posts[index + 1]) } } return ( {/* 遮罩 */}
{/* 添加onLoad事件处理函数 */} {/* 添加loading状态 */} {/*
*/}
{/*
*/} <>

{modalContent?.title}

{modalContent?.summary}
{modalContent?.category && (
{modalContent?.category}
)}
{/* 卡片的阴影遮罩,为了凸显图片上的文字 */}
{/*
*/}
{/*
*/}
) }