import { notFound } from 'next/navigation' import { prisma } from '@/lib/prisma' import { AddToCartButton } from '@/components/AddToCartButton' import { ArrowLeft, Package, Star, Shield, Truck, RotateCcw } from 'lucide-react' import Link from 'next/link' interface ComponentDetailPageProps { params: Promise<{ id: string }> } export default async function ComponentDetailPage({ params }: ComponentDetailPageProps) { const component = await prisma.component.findUnique({ where: { id: (await params).id }, include: { componentType: true } }) if (!component) { notFound() } const specifications = component.specifications ? JSON.parse(component.specifications) : {} // 获取同类型的其他产品推荐 const relatedComponents = await prisma.component.findMany({ where: { componentTypeId: component.componentTypeId, id: { not: component.id } }, take: 4, orderBy: { createdAt: 'desc' } }) return (
{/* Breadcrumb */} {/* Back Button */} 返回商品列表
{/* Product Image */}
{component.imageUrl ? ( {component.name} ) : (

暂无商品图片

)}
{/* Product Info */}
{component.componentType.name} {component.brand}

{component.name}

{[...Array(5)].map((_, i) => ( ))} (128 评价)
{/* Price */}
¥{component.price} ¥{Math.round(component.price * 1.2)} 8折

价格含税,全国包邮

{/* Stock Status */}
库存状态: {component.stock > 0 ? ( 有货 ({component.stock} 件) ) : ( 缺货 )}
{/* Add to Cart */}
{/* Service Promises */}

全国包邮

正品保障

7天无理由退换

{/* Product Details */}
{/* Description */}

商品详情

产品描述

{component.description || '暂无详细描述'}

{Object.keys(specifications).length > 0 && ( <>

技术规格

{Object.entries(specifications).map(([key, value]) => (
{key}: {String(value)}
))}
)}
{/* Product Info */}

产品信息

品牌: {component.brand}
型号: {component.model}
分类: {component.componentType.name}
库存: {component.stock} 件
{/* Related Products */} {relatedComponents.length > 0 && (

相关推荐

{relatedComponents.map((item) => (
{item.imageUrl ? ( {item.name} ) : ( )}

{item.name}

¥{item.price}

))}
)}
) }