| @@ -209,26 +209,27 @@ export default { | |||||
| xhr.send(); | xhr.send(); | ||||
| }); | }); | ||||
| }, | }, | ||||
| // 转blob下载 | |||||
| async downloadFun(blobFile, fileName) { | async downloadFun(blobFile, fileName) { | ||||
| let blob = new Blob([blobFile], { | let blob = new Blob([blobFile], { | ||||
| type: 'video/mp4' | type: 'video/mp4' | ||||
| }); | }); | ||||
| // console.log(blob); | // 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 dataUrl = 'data:application/octet-stream;base64,' + blobFile | ||||
| // const a = document.createElement('a') | // const a = document.createElement('a') | ||||
| // a.style.display = 'none' | // a.style.display = 'none' | ||||
| @@ -244,7 +245,7 @@ export default { | |||||
| // link.download = fileName | // link.download = fileName | ||||
| // link.click() | // link.click() | ||||
| // window.URL.revokeObjectURL(link.href) //释放内存 | // window.URL.revokeObjectURL(link.href) //释放内存 | ||||
| } | |||||
| }; | |||||
| }, | }, | ||||
| // 获取视频信息 | // 获取视频信息 | ||||
| async getVideoInfo() { | async getVideoInfo() { | ||||