"use client"; import Image from "next/image"; import { useState } from "react"; import { LucideIcon } from "lucide-react"; interface ScreenshotDisplayProps { imageName: string; // 图片文件名,如 "dashboard.png" placeholderIcon: LucideIcon; placeholderText: string; alt: string; } /** * 截图显示组件 * 如果图片存在则显示图片,否则显示占位符 */ export function ScreenshotDisplay({ imageName, placeholderIcon: PlaceholderIcon, placeholderText, alt, }: ScreenshotDisplayProps) { const [imageError, setImageError] = useState(false); const [imageLoaded, setImageLoaded] = useState(false); const imagePath = `/images/screenshots/${imageName}`; // 如果图片加载失败,显示占位符 if (imageError) { return (

{placeholderText}

); } return (
{alt} setImageError(true)} onLoad={() => setImageLoaded(true)} sizes="(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 1200px" priority={false} // 营销截图常替换;走 /_next/image 会强缓存优化结果,本地改 public 后仍像旧图 unoptimized /> {!imageLoaded && !imageError && (

加载中...

)}
); }