From d68fa31ed517bc7d90cd8c979708df03de8a4968 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 30 Jun 2025 17:36:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AliVideoUpload/index.tsx | 32 +++++++++++++------------ src/pages/TrainingClasses/detail.tsx | 17 ++++++++++++- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/components/AliVideoUpload/index.tsx b/src/components/AliVideoUpload/index.tsx index f320b51..5c089fd 100644 --- a/src/components/AliVideoUpload/index.tsx +++ b/src/components/AliVideoUpload/index.tsx @@ -117,21 +117,23 @@ const AliVideoUpload: React.FC = ({ // 文件上传成功 onUploadSucceed: (uploadInfo: any) => { console.log('上传成功:', uploadInfo); - getVideoAuthByVideoIdUsingGet({ id: uploadInfo.videoId }).then(res => { - if (res.retcode) { - resolve({ - videoId: uploadInfo.videoId, - playAuth: res.data?.playAuth, // 需要单独获取播放凭证 - duration: res.data?.videoMeta?.duration, - }); - } else { - message.error(res.retmsg); - reject(new Error(res.retmsg)); - } - }).catch(error => { - message.error(error); - reject(new Error(error)); - }) + setTimeout(() => { + getVideoAuthByVideoIdUsingGet({ id: uploadInfo.videoId }).then(res => { + if (res.retcode) { + resolve({ + videoId: uploadInfo.videoId, + playAuth: res.data?.playAuth, // 需要单独获取播放凭证 + duration: res.data?.videoMeta?.duration, + }); + } else { + message.error(res.retmsg); + reject(new Error(res.retmsg)); + } + }).catch(error => { + message.error(error); + reject(new Error(error)); + }) + }, 1000); }, // 文件上传失败 onUploadFailed: (uploadInfo: any, code: string, message: string) => { diff --git a/src/pages/TrainingClasses/detail.tsx b/src/pages/TrainingClasses/detail.tsx index 29dd417..463b604 100644 --- a/src/pages/TrainingClasses/detail.tsx +++ b/src/pages/TrainingClasses/detail.tsx @@ -23,6 +23,7 @@ import { addOrUpdateChapterUsingPost, removeChapterUsingGet } from '@/services/p import { addOrUpdateVideoUsingPost, getVideoAuthByIdUsingGet, removeVideoUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesVideoController'; import AliPlayer from '@/components/AliPlayer'; import AliVideoUpload from '@/components/AliVideoUpload'; +import { getVideoAuthByVideoIdUsingGet } from '@/services/pop-b2b2c/pbcVodController'; /** * 删除节点 @@ -274,6 +275,14 @@ const Detail: React.FC = () => { ); }; + const getVideoDuration = async (videoId: string) => { + const res = await getVideoAuthByVideoIdUsingGet({ id: videoId }) + if (res.retcode) { + return res.data?.videoMeta?.duration ? res.data?.videoMeta?.duration.toString() : '' + } + return '' + } + return ( = () => { if (value.pbcVideoAddress[0].uid === '-1') { pbcVideoAddress = value.pbcVideoAddress[0].url || ''; pbcVideoDuration = stepFormValues1.pbcVideoDuration || '' + if (!stepFormValues1.pbcVideoDuration) { + pbcVideoDuration = await getVideoDuration(value.pbcVideoAddress[0].url) + } } if ( value.pbcVideoAddress[0].response && @@ -526,7 +538,10 @@ const Detail: React.FC = () => { if (fileType === '1') { // 客户端上传的视频数据 pbcVideoAddress = value.pbcVideoAddress[0].response.data.videoId; - pbcVideoDuration = value.pbcVideoAddress[0].response.data.duration || ''; + pbcVideoDuration = value.pbcVideoAddress[0].response.data.duration; + if (!value.pbcVideoAddress[0].response.data.duration) { + pbcVideoDuration = await getVideoDuration(value.pbcVideoAddress[0].response.data.videoId) + } } else { // 服务端上传的文件数据 pbcVideoAddress = value.pbcVideoAddress[0].response.data;