import React, { useState, useEffect, useCallback } from 'react' import CertificateCard, { certificates } from './CertificateCard' export default function CertificateCarousel() { const [active, setActive] = useState(2) // 从中间开始 (ISO 45001) const [isMobile, setIsMobile] = useState(false) // 检测是否为移动端 useEffect(() => { const check = () => setIsMobile(window.innerWidth < 768) check() window.addEventListener('resize', check) return () => window.removeEventListener('resize', check) }, []) const next = useCallback(() => { setActive(prev => (prev + 1) % certificates.length) }, []) // 自动轮播 useEffect(() => { const timer = setInterval(next, 3000) return () => clearInterval(timer) }, [next]) const goTo = (index) => setActive(index) // 响应式参数 const containerHeight = isMobile ? 'h-[360px]' : 'h-[600px]' const translateXBase = isMobile ? 140 : 260 const scaleCenter = 1.0 const scaleNear = isMobile ? 0.8 : 0.7 const scaleFar = isMobile ? 0.5 : 0.4 return (