This commit is contained in:
root 2025-07-10 16:43:29 +08:00
parent 988b4d10c8
commit 398c853b80
2 changed files with 47 additions and 21 deletions

View File

@ -44,6 +44,7 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
const generateSingleVideo = useAIVideoStore(state => state.generateSingleVideo)
const batchGenerateVideos = useAIVideoStore(state => state.batchGenerateVideos)
const clearCompletedJobs = useAIVideoStore(state => state.clearCompletedJobs)
const removeJob = useAIVideoStore(state => state.removeJob)
// Initialize settings
React.useEffect(() => {
@ -72,8 +73,21 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
// Delete job function
const deleteJob = (jobId: string) => {
console.log('Delete job:', jobId)
// This would be implemented in the store
removeJob(jobId)
}
// Retry job function
const handleRetryJob = async (job: any) => {
try {
if (job.type === 'single') {
await generateSingleVideo(job.request)
} else if (job.type === 'batch') {
await batchGenerateVideos(job.request)
}
} catch (error) {
console.error('Retry failed:', error)
alert(`重试失败: ${error instanceof Error ? error.message : '未知错误'}`)
}
}
// Handle generation
@ -189,6 +203,7 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
jobs={jobs}
onPreview={openPreview}
onDelete={deleteJob}
onRetry={handleRetryJob}
/>
</div>

View File

@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { Play, Trash2, Copy, Check } from 'lucide-react'
import { Play, Trash2, Copy, Check, RotateCcw } from 'lucide-react'
interface VideoJob {
id: string
@ -19,9 +19,10 @@ interface VideoJobListProps {
jobs: VideoJob[]
onPreview: (job: VideoJob) => void
onDelete: (jobId: string) => void
onRetry: (job: VideoJob) => void
}
const VideoJobList: React.FC<VideoJobListProps> = ({ jobs, onPreview, onDelete }) => {
const VideoJobList: React.FC<VideoJobListProps> = ({ jobs, onPreview, onDelete, onRetry }) => {
const [copiedJobId, setCopiedJobId] = useState<string | null>(null)
const formatTime = (timestamp: number): string => {
@ -163,23 +164,33 @@ const VideoJobList: React.FC<VideoJobListProps> = ({ jobs, onPreview, onDelete }
<div className="text-sm text-red-600 bg-red-50 p-3 rounded">
<div className="flex items-center justify-between mb-2">
<div className="font-medium"> </div>
<button
onClick={() => copyErrorToClipboard(job)}
className="flex items-center gap-1 px-2 py-1 bg-red-600 text-white text-xs rounded hover:bg-red-700 transition-colors"
title="复制错误信息"
>
{copiedJobId === job.id ? (
<>
<Check size={12} />
</>
) : (
<>
<Copy size={12} />
</>
)}
</button>
<div className="flex items-center gap-2">
<button
onClick={() => onRetry(job)}
className="flex items-center gap-1 px-2 py-1 bg-blue-600 text-white text-xs rounded hover:bg-blue-700 transition-colors"
title="重试任务"
>
<RotateCcw size={12} />
</button>
<button
onClick={() => copyErrorToClipboard(job)}
className="flex items-center gap-1 px-2 py-1 bg-red-600 text-white text-xs rounded hover:bg-red-700 transition-colors"
title="复制错误信息"
>
{copiedJobId === job.id ? (
<>
<Check size={12} />
</>
) : (
<>
<Copy size={12} />
</>
)}
</button>
</div>
</div>
<div className="text-xs text-red-700 mb-2">
: {job.error}