feat: ✨️ 新增MP4视频下载支持
- 优化视频列表项下载逻辑及状态判断
This commit is contained in:
parent
fdb125c7ba
commit
be34a8bc9b
@ -22,7 +22,7 @@ type Props = {
|
||||
additionOperationBefore?: React.ReactNode;
|
||||
additionOperationAfter?: React.ReactNode;
|
||||
editable?: boolean;
|
||||
downloadVisible?: boolean;
|
||||
downloadUrl?: string;
|
||||
sortable?: boolean;
|
||||
index?: number;
|
||||
checked?: boolean;
|
||||
@ -44,7 +44,7 @@ type Props = {
|
||||
export const VideoListItem = (
|
||||
{
|
||||
id, video, onRemove,removeIcon, checked,playing,
|
||||
onCheckedChange, onEdit, active, editable,downloadVisible,
|
||||
onCheckedChange, onEdit, active, editable,downloadUrl,
|
||||
className, sortable, type, index,onItemClick,
|
||||
additionOperationAfter,additionOperationBefore,onRegenerate,hideCheckBox
|
||||
}: Props) => {
|
||||
@ -62,9 +62,9 @@ export const VideoListItem = (
|
||||
const generating = (type == 'create' && video.status == VideoStatus.Generating)
|
||||
const failed = (type == 'create' && (video.status != VideoStatus.Generating && video.status != VideoStatus.Generated) )
|
||||
const handleDownloadVideo = ()=>{
|
||||
if(video.oss_video_url){
|
||||
const ext = video.oss_video_url.substring(video.oss_video_url.lastIndexOf('.'))
|
||||
saveAs(video.oss_video_url,`${video.title || video.video_title}${ext}`)
|
||||
if(downloadUrl && video.status == VideoStatus.Generated){
|
||||
const ext = downloadUrl.substring(downloadUrl.lastIndexOf('.'))
|
||||
saveAs(downloadUrl,`${video.title || video.video_title}${ext}`)
|
||||
}
|
||||
}
|
||||
return <div
|
||||
@ -125,7 +125,7 @@ export const VideoListItem = (
|
||||
{/* <MenuOutlined/>*/}
|
||||
{/* </button> : <button disabled className="cursor-not-allowed"><MenuOutlined/></button>)}*/}
|
||||
<div className={"flex items-center justify-start gap-6"}>
|
||||
{downloadVisible &&
|
||||
{downloadUrl && video.status == VideoStatus.Generated &&
|
||||
<button className="hover:text-blue-500" onClick={e=>{
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
@ -139,7 +139,7 @@ export default function LiveIndex() {
|
||||
});
|
||||
}
|
||||
|
||||
// useEffect(initPlayingState, [videoData])
|
||||
useEffect(initPlayingState, [videoData])
|
||||
useEffect(() => {
|
||||
loadList()
|
||||
return ()=>{
|
||||
|
@ -264,7 +264,7 @@ export default function VideoIndex() {
|
||||
onRegenerate={v.status != VideoStatus.Generating && v.status != VideoStatus.Generated?()=>{
|
||||
processGenerateVideo(v)
|
||||
}:undefined}
|
||||
downloadVisible={v.status == VideoStatus.Generated && !!v.oss_video_url}
|
||||
downloadUrl={v.oss_video_mp4_url}
|
||||
hideCheckBox={v.status != VideoStatus.Generating && v.status != VideoStatus.Generated}
|
||||
editable={v.status != VideoStatus.Generating}
|
||||
sortable={v.status == VideoStatus.Generated}
|
||||
|
1
src/types/api.d.ts
vendored
1
src/types/api.d.ts
vendored
@ -97,6 +97,7 @@ declare interface VideoInfo {
|
||||
title: string;
|
||||
cover: string;
|
||||
oss_video_url: string;
|
||||
oss_video_mp4_url?: string;
|
||||
duration: number;
|
||||
article_id: number;
|
||||
status: number;
|
||||
|
Loading…
x
Reference in New Issue
Block a user