"use client" import React, { useState } from 'react' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { FileUpload } from '@/components/ui/file-upload' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Image, Play, Music, Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' import type { UploadResponse } from '@/lib/api/upload' interface FoodMediaUploadProps { /** 当前图片URL */ imageUrl?: string /** 当前动画URL */ animationUrl?: string /** 当前音频URL */ audioUrl?: string /** 图片上传成功回调 */ onImageUpload?: (url: string) => void /** 动画上传成功回调 */ onAnimationUpload?: (url: string) => void /** 音频上传成功回调 */ onAudioUpload?: (url: string) => void /** 文件移除回调 */ onRemove?: (type: 'image' | 'animation' | 'audio') => void /** 是否禁用 */ disabled?: boolean } export function FoodMediaUpload({ imageUrl, animationUrl, audioUrl, onImageUpload, onAnimationUpload, onAudioUpload, onRemove, disabled = false, }: FoodMediaUploadProps) { const [activeTab, setActiveTab] = useState('image') // 准备默认文件列表 const getDefaultFiles = (url?: string, type: string = 'image'): UploadResponse[] => { if (!url) return [] return [{ url, filename: `当前${type === 'image' ? '图片' : type === 'animation' ? '动画' : '音频'}`, size: 0, mimeType: type === 'image' ? 'image/jpeg' : type === 'animation' ? 'video/mp4' : 'audio/mp3' }] } return (