diff --git a/src/assets/js/useAliYunUpload.js b/src/assets/js/useAliYunUpload.js index 381b6bb..de2991f 100644 --- a/src/assets/js/useAliYunUpload.js +++ b/src/assets/js/useAliYunUpload.js @@ -1,4 +1,5 @@ import { setVideo, setVideoRefresh } from "@/request/api.js"; +import { ElLoading, ElMessage } from "element-plus"; export default function useAliYunUpload({ addFileSuccess, @@ -10,6 +11,7 @@ export default function useAliYunUpload({ onUploadTokenExpired, onUploadEnd, }) { + let loading; const uploader = new window.AliyunUpload.Vod({ timeout: 60000, partSize: 1048576, @@ -50,11 +52,18 @@ export default function useAliYunUpload({ uploadAddress, videoId ); + loading = ElLoading.service({ + lock: true, + text: "加载中...", + background: "rgba(0, 0, 0, 0.5)", + }); }, onUploadSucceed(uploadInfo) { + loading.close(); onUploadSucceed && onUploadSucceed(uploadInfo); }, onUploadFailed(uploadInfo, code, message) { + ElMessage.success("上传失败,请重新上传"); onUploadFailed && onUploadFailed(uploadInfo, code, message); }, onUploadCanceled(uploadInfo, code, message) { diff --git a/src/assets/js/utils.js b/src/assets/js/utils.js index f0a2804..81c51b8 100644 --- a/src/assets/js/utils.js +++ b/src/assets/js/utils.js @@ -219,6 +219,7 @@ export function getFileSuffix(name) { * @return {string} 文件名称 **/ export function getFileName(name) { + if (!name) return ""; return name.substring(name.lastIndexOf("/") + 1); } diff --git a/src/views/online_learn_exam/courseware/video/components/add.vue b/src/views/online_learn_exam/courseware/video/components/add.vue index c870260..ea3a87c 100644 --- a/src/views/online_learn_exam/courseware/video/components/add.vue +++ b/src/views/online_learn_exam/courseware/video/components/add.vue @@ -172,7 +172,6 @@ const fnSubmit = debounce( }, onUploadFailed: () => { progressBarVisible.value = false; - ElMessage.success("上传失败,请重新上传"); }, onUploadProgress: (uploadInfo, totalSize, progress) => { progressBar.value = Math.ceil(progress * 100); @@ -194,6 +193,7 @@ const fnSubmitForm = async (videoId = "") => { ...form.value, videoId, isEditVideo: !!form.value.file[0].raw, + trainingSection: form.value.trainingSection.join(";"), }; props.type === "add" ? await setVideoCoursewareAdd(params)