'use client'; import { useState, useEffect } from 'react'; interface Product { name: string; desc: string; price: string; features: string[]; badge?: string; popular?: boolean; } interface ProductModalProps { product: Product | null; isOpen: boolean; onClose: () => void; contactText: string; locale: string; } export default function ProductModal({ product, isOpen, onClose, contactText, locale }: ProductModalProps) { const [isVisible, setIsVisible] = useState(false); useEffect(() => { if (isOpen) { setIsVisible(true); // 保存原始的overflow值 const originalOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { // 恢复原始的overflow值 document.body.style.overflow = originalOverflow || 'unset'; }; } else { // 延迟恢复overflow,允许动画完成 const timer = setTimeout(() => { document.body.style.overflow = 'unset'; }, 300); return () => { clearTimeout(timer); }; } }, [isOpen]); const handleClose = () => { setIsVisible(false); setTimeout(() => { onClose(); }, 300); }; if (!isOpen || !product) return null; return (
{/* 背景遮罩 */}
{/* 模态框内容 */}
{/* 关闭按钮 */} {/* 产品标签 */}
{product.badge && ( {product.badge} )} {product.popular && ( 🔥 热门 )}
{/* 产品标题和价格 */}

{product.name}

{product.price} {product.price.includes('/月') && ( 按月计费 )}
{/* 产品描述 */}

产品介绍

{product.desc}

{/* 功能特性 */}

功能特性

{product.features.map((feature, index) => (
{feature}
))}
{/* 适用场景 */}

适用场景

{getUseCases(product.name)}

{/* 操作按钮 */}
{contactText}
); } function getUseCases(productName: string): string { const useCases: { [key: string]: string } = { '轻量云服务器': '个人博客、小型企业官网、开发测试环境、学习实验、小型应用部署', 'EC2通用型服务器': 'Web应用、企业级应用、微服务架构、API服务、中等规模网站', 'EC2计算优化型': '科学计算、机器学习训练、高性能Web服务、数据分析、视频处理', '站群服务器': 'SEO优化、多站点管理、内容分发、营销推广、大规模网站集群', '高防服务器': '游戏服务器、金融应用、电商平台、直播平台、高价值业务系统', 'WAF Web防火墙': 'Web应用保护、API安全、电商网站、企业门户、在线服务平台', 'SSL证书服务': '网站HTTPS加密、API接口安全、移动应用、电商交易、数据传输保护', 'S3对象存储': '网站静态资源、数据备份归档、大数据分析、内容分发、移动应用存储', 'EBS块存储': '数据库存储、文件系统、企业应用、高IOPS应用、关键业务数据', 'EFS文件存储': '内容管理系统、Web服务、大数据分析、媒体处理、共享文件存储', 'RDS关系型数据库': '企业应用、电商系统、CRM系统、ERP系统、数据仓库', 'Redis缓存服务': '会话存储、实时排行榜、消息队列、计数器、高并发缓存', 'MongoDB文档数据库': '内容管理、物联网数据、实时分析、移动应用、社交平台', 'CDN内容分发': '网站加速、视频点播、游戏更新、软件下载、全球内容分发', '负载均衡器': '高可用架构、流量分发、故障转移、弹性扩容、微服务架构', 'VPN专线服务': '企业组网、远程办公、数据中心互联、混合云架构、安全连接', '机器学习平台': '模型训练、数据挖掘、预测分析、推荐系统、智能决策', '图像识别API': '人脸识别、内容审核、智能相册、安防监控、医疗影像', '语音识别API': '智能客服、语音助手、会议记录、语音翻译、语音控制' }; return useCases[productName] || '适用于各种业务场景,具体请咨询我们的技术专家'; }