feat(results): add preview and batch download actions

This commit is contained in:
Xiaoxia AI
2026-06-24 06:57:59 +08:00
parent 8801795d1e
commit 764986f95d
2 changed files with 33 additions and 1 deletions
+3
View File
@@ -155,6 +155,9 @@ test.describe('Core generation and download flow', () => {
await page.goto(`/projects/${projectData.id}/results`);
await expect(page.getByRole('heading').getByText(generatedVideo.name, { exact: true })).toBeVisible({ timeout: 20_000 });
await expect(page.getByText('待复核')).toBeVisible({ timeout: 20_000 });
await expect(page.getByText('暂无封面,使用成片文件预览')).toBeVisible({ timeout: 20_000 });
await expect(page.getByRole('button', { name: '预览成片' })).toBeVisible();
await expect(page.getByRole('button', { name: '批量获取下载地址' })).toBeEnabled();
await page.getByRole('button', { name: '标记可发布' }).click();
await expect(page.getByText('成片复核状态已更新')).toBeVisible({ timeout: 10_000 });
await expect(page.getByText('可发布', { exact: true })).toBeVisible({ timeout: 20_000 });
@@ -40,6 +40,15 @@ const ProjectResults: React.FC = () => {
onError: () => message.error('成片复核状态更新失败'),
});
const handlePreview = async (videoId: string) => {
try {
const url = await getGeneratedVideoDownloadUrl(videoId);
window.open(url, '_blank', 'noopener,noreferrer');
} catch (error: any) {
message.error(error.response?.data?.detail || '获取预览地址失败');
}
};
const handleDownload = async (videoId: string) => {
try {
const url = await getGeneratedVideoDownloadUrl(videoId);
@@ -49,9 +58,23 @@ const ProjectResults: React.FC = () => {
}
};
const handleBatchDownload = async () => {
const videos = videosQuery.data || [];
for (const video of videos) {
await handleDownload(video.id);
}
};
return (
<div style={{ padding: 24 }}>
<Card title="项目成片中心">
<Card
title="项目成片中心"
extra={
<Button disabled={!videosQuery.data?.length} onClick={handleBatchDownload}>
批量获取下载地址
</Button>
}
>
{videosQuery.isError && (
<Alert style={{ marginBottom: 16 }} type="error" showIcon message="生成结果加载失败" />
)}
@@ -66,6 +89,9 @@ const ProjectResults: React.FC = () => {
return (
<List.Item
actions={[
<Button key="preview" type="link" onClick={() => handlePreview(item.id)}>
预览成片
</Button>,
<Button key="download" type="link" onClick={() => handleDownload(item.id)}>
获取下载地址
</Button>,
@@ -93,6 +119,9 @@ const ProjectResults: React.FC = () => {
<Typography.Text copyable ellipsis style={{ maxWidth: 720 }}>
{item.name}
</Typography.Text>
<Typography.Text type="secondary">
预览:{item.thumbnail_url ? '封面已生成' : '暂无封面,使用成片文件预览'}
</Typography.Text>
<Typography.Text type="secondary">
生成参数:素材库 {String(item.generation_params?.asset_library_id || '未记录')},标题 {String(item.generation_params?.title_id || '自动/未选择')}
</Typography.Text>