fix
This commit is contained in:
parent
988b4d10c8
commit
398c853b80
|
|
@ -44,6 +44,7 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
|
||||||
const generateSingleVideo = useAIVideoStore(state => state.generateSingleVideo)
|
const generateSingleVideo = useAIVideoStore(state => state.generateSingleVideo)
|
||||||
const batchGenerateVideos = useAIVideoStore(state => state.batchGenerateVideos)
|
const batchGenerateVideos = useAIVideoStore(state => state.batchGenerateVideos)
|
||||||
const clearCompletedJobs = useAIVideoStore(state => state.clearCompletedJobs)
|
const clearCompletedJobs = useAIVideoStore(state => state.clearCompletedJobs)
|
||||||
|
const removeJob = useAIVideoStore(state => state.removeJob)
|
||||||
|
|
||||||
// Initialize settings
|
// Initialize settings
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
@ -72,8 +73,21 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
|
||||||
|
|
||||||
// Delete job function
|
// Delete job function
|
||||||
const deleteJob = (jobId: string) => {
|
const deleteJob = (jobId: string) => {
|
||||||
console.log('Delete job:', jobId)
|
removeJob(jobId)
|
||||||
// This would be implemented in the store
|
}
|
||||||
|
|
||||||
|
// 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
|
// Handle generation
|
||||||
|
|
@ -189,6 +203,7 @@ const AIVideoGenerator: React.FC<AIVideoGeneratorProps> = ({ className = '' }) =
|
||||||
jobs={jobs}
|
jobs={jobs}
|
||||||
onPreview={openPreview}
|
onPreview={openPreview}
|
||||||
onDelete={deleteJob}
|
onDelete={deleteJob}
|
||||||
|
onRetry={handleRetryJob}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { Play, Trash2, Copy, Check } from 'lucide-react'
|
import { Play, Trash2, Copy, Check, RotateCcw } from 'lucide-react'
|
||||||
|
|
||||||
interface VideoJob {
|
interface VideoJob {
|
||||||
id: string
|
id: string
|
||||||
|
|
@ -19,9 +19,10 @@ interface VideoJobListProps {
|
||||||
jobs: VideoJob[]
|
jobs: VideoJob[]
|
||||||
onPreview: (job: VideoJob) => void
|
onPreview: (job: VideoJob) => void
|
||||||
onDelete: (jobId: string) => 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 [copiedJobId, setCopiedJobId] = useState<string | null>(null)
|
||||||
|
|
||||||
const formatTime = (timestamp: number): string => {
|
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="text-sm text-red-600 bg-red-50 p-3 rounded">
|
||||||
<div className="flex items-center justify-between mb-2">
|
<div className="flex items-center justify-between mb-2">
|
||||||
<div className="font-medium">❌ 生成失败</div>
|
<div className="font-medium">❌ 生成失败</div>
|
||||||
<button
|
<div className="flex items-center gap-2">
|
||||||
onClick={() => copyErrorToClipboard(job)}
|
<button
|
||||||
className="flex items-center gap-1 px-2 py-1 bg-red-600 text-white text-xs rounded hover:bg-red-700 transition-colors"
|
onClick={() => onRetry(job)}
|
||||||
title="复制错误信息"
|
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="重试任务"
|
||||||
{copiedJobId === job.id ? (
|
>
|
||||||
<>
|
<RotateCcw size={12} />
|
||||||
<Check 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"
|
||||||
<Copy size={12} />
|
title="复制错误信息"
|
||||||
复制
|
>
|
||||||
</>
|
{copiedJobId === job.id ? (
|
||||||
)}
|
<>
|
||||||
</button>
|
<Check size={12} />
|
||||||
|
已复制
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Copy size={12} />
|
||||||
|
复制
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-red-700 mb-2">
|
<div className="text-xs text-red-700 mb-2">
|
||||||
错误信息: {job.error}
|
错误信息: {job.error}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue