diff --git a/apps/web/src/pages/workspace/ProjectResults.tsx b/apps/web/src/pages/workspace/ProjectResults.tsx index 90138bed3..a47733360 100644 --- a/apps/web/src/pages/workspace/ProjectResults.tsx +++ b/apps/web/src/pages/workspace/ProjectResults.tsx @@ -1,12 +1,20 @@ -import React from 'react'; -import { useParams } from 'react-router-dom'; -import { Button, Card, Empty, List, Space, Tag, Typography, message } from 'antd'; +import React, { useEffect } from 'react'; +import { useLocation, useParams } from 'react-router-dom'; +import { Alert, Button, Card, Empty, List, Space, Spin, Tag, Typography, message } from 'antd'; import { useQuery } from '@tanstack/react-query'; import { getGeneratedVideoDownloadUrl, getGeneratedVideos } from '@/api/generation'; const ProjectResults: React.FC = () => { const { id } = useParams<{ id: string }>(); + const location = useLocation(); const projectId = id || ''; + const routedWorkspaceId = (location.state as { workspaceId?: string } | null)?.workspaceId || ''; + + useEffect(() => { + if (projectId && routedWorkspaceId) { + sessionStorage.setItem(`project-workspace:${projectId}`, routedWorkspaceId); + } + }, [projectId, routedWorkspaceId]); const videosQuery = useQuery({ queryKey: ['generated-videos', projectId], @@ -19,28 +27,50 @@ const ProjectResults: React.FC = () => { try { const url = await getGeneratedVideoDownloadUrl(videoId); window.open(url, '_blank', 'noopener,noreferrer'); - } catch { - message.error('获取下载地址失败'); + } catch (error: any) { + message.error(error.response?.data?.detail || '获取下载地址失败'); } }; return (
- {videosQuery.data?.length ? ( + {videosQuery.isError && ( + + )} + + {videosQuery.isLoading ? ( + + ) : videosQuery.data?.length ? ( ( handleDownload(item.id)}> - 下载 + 获取下载地址 , ]} > {item.name}{item.width}x{item.height}{item.duration}s} - description={item.file_url} + title={ + + {item.name} + {item.width}x{item.height} + {item.duration}s + {Math.round(item.file_size / 1024)} KB + + } + description={ + + + {item.file_url} + + + + } /> )}