From 4e94f642c4435506a07958cc91ea830c3c19f51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 5 Jul 2023 11:57:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/upload-video-button/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compenents/upload-video-button/index.tsx b/src/compenents/upload-video-button/index.tsx index ffbcc27..0cde025 100644 --- a/src/compenents/upload-video-button/index.tsx +++ b/src/compenents/upload-video-button/index.tsx @@ -42,9 +42,9 @@ interface FileItem { export const UploadVideoButton = (props: PropsInterface) => { const [showModal, setShowModal] = useState(false); - const [loading, setLoading] = useState(false); const localFileList = useRef([]); const [fileList, setFileList] = useState([]); + const upRef = useRef(0); const getMinioUploadId = async () => { let resp: any = await minioUploadId("mp4"); @@ -55,7 +55,7 @@ export const UploadVideoButton = (props: PropsInterface) => { multiple: true, beforeUpload: async (file: File) => { if (file.type === "video/mp4") { - setLoading(true); + upRef.current++; // 视频封面解析 || 视频时长解析 let videoInfo = await parseVideo(file); // 添加到本地待上传 @@ -93,7 +93,7 @@ export const UploadVideoButton = (props: PropsInterface) => { item.isSuc = true; setFileList([...localFileList.current]); message.success(`${item.file.name} 上传成功`); - setLoading(false); + upRef.current--; }); }); item.run.on("retry", () => { @@ -109,7 +109,7 @@ export const UploadVideoButton = (props: PropsInterface) => { item.isErr = true; item.errMsg = msg; setFileList([...localFileList.current]); - setLoading(false); + upRef.current--; }); setTimeout(() => { item.run.start(); @@ -124,7 +124,7 @@ export const UploadVideoButton = (props: PropsInterface) => { }; const closeWin = () => { - if (loading) { + if (upRef.current > 0) { message.error(`等待上传成功后才能关闭`); return; } From d39c11ad98a0ffaa993944fde6f04f2742c72c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 5 Jul 2023 12:18:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/upload-video-button/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compenents/upload-video-button/index.tsx b/src/compenents/upload-video-button/index.tsx index 0cde025..9174393 100644 --- a/src/compenents/upload-video-button/index.tsx +++ b/src/compenents/upload-video-button/index.tsx @@ -130,6 +130,7 @@ export const UploadVideoButton = (props: PropsInterface) => { } setShowModal(false); setFileList([]); + localFileList.current = []; props.onUpdate(); };