'use client' import React from 'react' import MaterialCard, { Material } from './MaterialCard' // 用户会话类型 interface UserSession { id: string role: string } interface MaterialGridProps { materials: Material[] displayedCount: number session: { user: UserSession } | null loading: boolean isTransitionLoading: boolean // 音频播放状态 playingAudioId: string | null audioElement: HTMLAudioElement | null audioProgress: number audioCurrentTime: number audioDuration: number audioRef: React.RefObject // 下载状态 downloadingId: string | null downloadProgress: number // 主题色 themeColor: string // 筛选状态(用于空状态提示) hasFilters: boolean // 搜索关键词(用于高亮) searchKeyword?: string // 事件处理 onAudioPlay: (materialId: string, audioUrl: string) => void onDownload: (id: string) => void onLike: (id: string) => void onFavorite: (id: string) => void onShare: (id: string) => void onEdit: (material: Material) => void onDelete: (id: string) => void onMaterialClick: (material: Material) => void onRetryTranscode: (materialId: string) => void showToast: (message: string, options?: { variant?: 'success' | 'error' }) => void } function MaterialGridSkeleton() { return (
加载中... {Array.from({ length: 8 }, (_, index) => (
))}
) } export default function MaterialGrid({ materials, displayedCount, session, loading, isTransitionLoading, playingAudioId, audioElement, audioProgress, audioCurrentTime, audioDuration, audioRef, downloadingId, downloadProgress, themeColor, hasFilters, searchKeyword, onAudioPlay, onDownload, onLike, onFavorite, onShare, onEdit, onDelete, onMaterialClick, onRetryTranscode, showToast, }: MaterialGridProps) { return (
{/* 过渡加载遮罩 */} {isTransitionLoading && (
)} {loading ? ( ) : materials.length === 0 ? (

{hasFilters ? '没有找到匹配的素材' : '还没有素材,快来上传第一个吧!'}

) : (
{materials.slice(0, displayedCount).map((material) => ( ))}
)}
) } export type { Material }