fix(web): use signed URLs for generated video downloads
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useLocation, useParams } from 'react-router-dom';
|
||||
import { Alert, Button, Card, Form, Input, Select, Space, Typography, message } from 'antd';
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
import { createGenerationTask, getGenerationResults, getGenerationTask } from '@/api/generation';
|
||||
import { createGenerationTask, getGeneratedVideoDownloadUrl, getGenerationResults, getGenerationTask } from '@/api/generation';
|
||||
import { getAssetLibraries } from '@/api/assets';
|
||||
import { getProject } from '@/api/projects';
|
||||
import { useAuthStore } from '@/store/authStore';
|
||||
@@ -124,6 +124,15 @@ const ProjectGeneration: React.FC = () => {
|
||||
? humanizeGenerationError(taskQuery.data.error_message)
|
||||
: '';
|
||||
|
||||
const openSignedDownload = async (videoId: string) => {
|
||||
try {
|
||||
const url = await getGeneratedVideoDownloadUrl(videoId);
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
} catch (error: any) {
|
||||
message.error(error.response?.data?.detail || '获取下载地址失败');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<Card title="项目生成任务">
|
||||
@@ -196,7 +205,7 @@ const ProjectGeneration: React.FC = () => {
|
||||
{resultsQuery.data.map((item) => (
|
||||
<Space key={item.id}>
|
||||
<Typography.Text>{item.name}</Typography.Text>
|
||||
<Button type="link" href={item.file_url} target="_blank" rel="noreferrer">
|
||||
<Button type="link" onClick={() => openSignedDownload(item.id)}>
|
||||
下载/查看
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
@@ -62,14 +62,9 @@ const ProjectResults: React.FC = () => {
|
||||
</Space>
|
||||
}
|
||||
description={
|
||||
<Space direction="vertical" size={4}>
|
||||
<Typography.Text copyable ellipsis style={{ maxWidth: 720 }}>
|
||||
{item.file_url}
|
||||
</Typography.Text>
|
||||
<Button type="link" href={item.file_url} target="_blank" rel="noreferrer" style={{ padding: 0 }}>
|
||||
直接查看公开文件
|
||||
</Button>
|
||||
</Space>
|
||||
<Typography.Text copyable ellipsis style={{ maxWidth: 720 }}>
|
||||
{item.name}
|
||||
</Typography.Text>
|
||||
}
|
||||
/>
|
||||
</List.Item>
|
||||
|
||||
Reference in New Issue
Block a user