"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}
加载中...