pull/1/head
z 2024-01-20 08:48:10 +08:00
parent 4bd0189616
commit 7166ee57d8
3 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { setVideo, setVideoRefresh } from "@/request/api.js"; import { setVideo, setVideoRefresh } from "@/request/api.js";
import { ElLoading, ElMessage } from "element-plus";
export default function useAliYunUpload({ export default function useAliYunUpload({
addFileSuccess, addFileSuccess,
@ -10,6 +11,7 @@ export default function useAliYunUpload({
onUploadTokenExpired, onUploadTokenExpired,
onUploadEnd, onUploadEnd,
}) { }) {
let loading;
const uploader = new window.AliyunUpload.Vod({ const uploader = new window.AliyunUpload.Vod({
timeout: 60000, timeout: 60000,
partSize: 1048576, partSize: 1048576,
@ -50,11 +52,18 @@ export default function useAliYunUpload({
uploadAddress, uploadAddress,
videoId videoId
); );
loading = ElLoading.service({
lock: true,
text: "加载中...",
background: "rgba(0, 0, 0, 0.5)",
});
}, },
onUploadSucceed(uploadInfo) { onUploadSucceed(uploadInfo) {
loading.close();
onUploadSucceed && onUploadSucceed(uploadInfo); onUploadSucceed && onUploadSucceed(uploadInfo);
}, },
onUploadFailed(uploadInfo, code, message) { onUploadFailed(uploadInfo, code, message) {
ElMessage.success("上传失败,请重新上传");
onUploadFailed && onUploadFailed(uploadInfo, code, message); onUploadFailed && onUploadFailed(uploadInfo, code, message);
}, },
onUploadCanceled(uploadInfo, code, message) { onUploadCanceled(uploadInfo, code, message) {

View File

@ -219,6 +219,7 @@ export function getFileSuffix(name) {
* @return {string} 文件名称 * @return {string} 文件名称
**/ **/
export function getFileName(name) { export function getFileName(name) {
if (!name) return "";
return name.substring(name.lastIndexOf("/") + 1); return name.substring(name.lastIndexOf("/") + 1);
} }

View File

@ -172,7 +172,6 @@ const fnSubmit = debounce(
}, },
onUploadFailed: () => { onUploadFailed: () => {
progressBarVisible.value = false; progressBarVisible.value = false;
ElMessage.success("上传失败,请重新上传");
}, },
onUploadProgress: (uploadInfo, totalSize, progress) => { onUploadProgress: (uploadInfo, totalSize, progress) => {
progressBar.value = Math.ceil(progress * 100); progressBar.value = Math.ceil(progress * 100);
@ -194,6 +193,7 @@ const fnSubmitForm = async (videoId = "") => {
...form.value, ...form.value,
videoId, videoId,
isEditVideo: !!form.value.file[0].raw, isEditVideo: !!form.value.file[0].raw,
trainingSection: form.value.trainingSection.join(";"),
}; };
props.type === "add" props.type === "add"
? await setVideoCoursewareAdd(params) ? await setVideoCoursewareAdd(params)