mirror of
https://github.com/PlayEdu/backend
synced 2025-06-08 06:50:04 +08:00
上传视频逻辑优化
This commit is contained in:
parent
1046bb70b8
commit
4e94f642c4
@ -42,9 +42,9 @@ interface FileItem {
|
|||||||
|
|
||||||
export const UploadVideoButton = (props: PropsInterface) => {
|
export const UploadVideoButton = (props: PropsInterface) => {
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const localFileList = useRef<FileItem[]>([]);
|
const localFileList = useRef<FileItem[]>([]);
|
||||||
const [fileList, setFileList] = useState<FileItem[]>([]);
|
const [fileList, setFileList] = useState<FileItem[]>([]);
|
||||||
|
const upRef = useRef(0);
|
||||||
|
|
||||||
const getMinioUploadId = async () => {
|
const getMinioUploadId = async () => {
|
||||||
let resp: any = await minioUploadId("mp4");
|
let resp: any = await minioUploadId("mp4");
|
||||||
@ -55,7 +55,7 @@ export const UploadVideoButton = (props: PropsInterface) => {
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
beforeUpload: async (file: File) => {
|
beforeUpload: async (file: File) => {
|
||||||
if (file.type === "video/mp4") {
|
if (file.type === "video/mp4") {
|
||||||
setLoading(true);
|
upRef.current++;
|
||||||
// 视频封面解析 || 视频时长解析
|
// 视频封面解析 || 视频时长解析
|
||||||
let videoInfo = await parseVideo(file);
|
let videoInfo = await parseVideo(file);
|
||||||
// 添加到本地待上传
|
// 添加到本地待上传
|
||||||
@ -93,7 +93,7 @@ export const UploadVideoButton = (props: PropsInterface) => {
|
|||||||
item.isSuc = true;
|
item.isSuc = true;
|
||||||
setFileList([...localFileList.current]);
|
setFileList([...localFileList.current]);
|
||||||
message.success(`${item.file.name} 上传成功`);
|
message.success(`${item.file.name} 上传成功`);
|
||||||
setLoading(false);
|
upRef.current--;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
item.run.on("retry", () => {
|
item.run.on("retry", () => {
|
||||||
@ -109,7 +109,7 @@ export const UploadVideoButton = (props: PropsInterface) => {
|
|||||||
item.isErr = true;
|
item.isErr = true;
|
||||||
item.errMsg = msg;
|
item.errMsg = msg;
|
||||||
setFileList([...localFileList.current]);
|
setFileList([...localFileList.current]);
|
||||||
setLoading(false);
|
upRef.current--;
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
item.run.start();
|
item.run.start();
|
||||||
@ -124,7 +124,7 @@ export const UploadVideoButton = (props: PropsInterface) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const closeWin = () => {
|
const closeWin = () => {
|
||||||
if (loading) {
|
if (upRef.current > 0) {
|
||||||
message.error(`等待上传成功后才能关闭`);
|
message.error(`等待上传成功后才能关闭`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user