'use client' import Image from 'next/image' import { PREVIEW_OPTIONAL_TYPES } from './upload-constants' import { dropZoneActiveClass, dropZoneIdleClass, fieldHintClass, fieldLabelClass, } from './upload-field-styles' import VideoPreviewImageUpload from './VideoPreviewImageUpload' import { isVideoMaterialType } from '@/lib/video-material-types' interface PreviewImageUploadProps { materialType: string previewImages: File[] previewUrls: string[] isPreviewDragging: boolean previewInputRef: React.RefObject previewDropZoneRef: React.RefObject disabled?: boolean onPreviewChange: (e: React.ChangeEvent) => void onPreviewDragEnter: (e: React.DragEvent) => void onPreviewDragLeave: (e: React.DragEvent) => void onPreviewDragOver: (e: React.DragEvent) => void onPreviewDrop: (e: React.DragEvent) => void onRemovePreviewImage: (index: number) => void onVideoPreviewSelect: (file: File) => void | Promise onValidationError: (message: string) => void onVideoPreviewProcessingChange?: (processing: boolean) => void } export default function PreviewImageUpload({ materialType, previewImages, previewUrls, isPreviewDragging, previewInputRef, previewDropZoneRef, disabled = false, onPreviewChange, onPreviewDragEnter, onPreviewDragLeave, onPreviewDragOver, onPreviewDrop, onRemovePreviewImage, onVideoPreviewSelect, onValidationError, onVideoPreviewProcessingChange, }: PreviewImageUploadProps) { if (isVideoMaterialType(materialType)) { return ( onRemovePreviewImage(0)} onValidationError={onValidationError} onProcessingChange={onVideoPreviewProcessingChange} /> ) } return (
{previewUrls.map((url, index) => (
{`预览图 {index === 0 && (
主预览图
)}
))}

支持 JPG、PNG、WebP,可一次选多张或拖进来。

第一张图会作为主预览图。

) }