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