diff --git a/src/views/videoDownload/videoDownload.vue b/src/views/videoDownload/videoDownload.vue index 0b4f7cd..47f427a 100644 --- a/src/views/videoDownload/videoDownload.vue +++ b/src/views/videoDownload/videoDownload.vue @@ -209,26 +209,27 @@ export default { xhr.send(); }); }, + // 转blob下载 async downloadFun(blobFile, fileName) { let blob = new Blob([blobFile], { type: 'video/mp4' }); // console.log(blob); - if (window.navigator.msSaveOrOpenBlob) { - navigator.msSaveBlob(blob, fileName); - } else { - const reader = new FileReader(); - reader.readAsDataURL(blob); - // reader.readAsDataURL(blobFile); - reader.onloadend = function () { - const base64Data = reader.result; - const link = document.createElement('a'); - link.href = base64Data; - link.download = fileName; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }; + // if (window.navigator.msSaveOrOpenBlob) { + // navigator.msSaveBlob(blob, fileName); + // } else { + const reader = new FileReader(); + reader.readAsDataURL(blob); + // reader.readAsDataURL(blobFile); + reader.onloadend = function () { + const base64Data = reader.result; + const link = document.createElement('a'); + link.href = base64Data; + link.download = fileName; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + // }; // const dataUrl = 'data:application/octet-stream;base64,' + blobFile // const a = document.createElement('a') // a.style.display = 'none' @@ -244,7 +245,7 @@ export default { // link.download = fileName // link.click() // window.URL.revokeObjectURL(link.href) //释放内存 - } + }; }, // 获取视频信息 async getVideoInfo() {