From 559f22ba1a377972f6d3993f7caf1347271ba185 Mon Sep 17 00:00:00 2001 From: congzc Date: Fri, 5 May 2023 17:47:36 +0800 Subject: [PATCH] 4 --- src/views/videoDownload/videoDownload.vue | 43 ++++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/views/videoDownload/videoDownload.vue b/src/views/videoDownload/videoDownload.vue index f5f884e..bd249ee 100644 --- a/src/views/videoDownload/videoDownload.vue +++ b/src/views/videoDownload/videoDownload.vue @@ -145,23 +145,24 @@ export default { } if (!isAndroid) { console.log('ios'); - // let videoData = await exportVideoApi(this.id); - const AccessToken = localStorage.getItem('AccessToken'); - that - .$axios({ - method: 'get', - url: process.env.VUE_APP_API_ROOT + `/api/userVideo/exportVideo?id=${that.id}`, - headers: { - 'content-type': 'application/octet-stream;charset=UTF-8', - token: AccessToken, - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Credentials': 'true' - } - }) - .then(async res => { - console.log(res, 'AccessTokenAccessToken'); - await that.downloadFun(res, that.title); - }); + let videoData = await exportVideoApi(this.id); + that.downloadFun(videoData, that.title); + // const AccessToken = localStorage.getItem('AccessToken'); + // that + // .$axios({ + // method: 'get', + // url: process.env.VUE_APP_API_ROOT + `/api/userVideo/exportVideo?id=${that.id}`, + // headers: { + // 'content-type': 'application/octet-stream;charset=UTF-8', + // token: AccessToken, + // 'Access-Control-Allow-Origin': '*', + // 'Access-Control-Allow-Credentials': 'true' + // } + // }) + // .then(async res => { + // console.log(res, 'AccessTokenAccessToken'); + // that.downloadFun(res, that.title); + // }); // console.log(videoData); // await this.downloadFun(this.id); @@ -211,17 +212,17 @@ export default { }, // 转blob下载 async downloadFun(blobFile, fileName) { - let blob = await new Blob([blobFile], { + let blob = new Blob([blobFile], { type: 'video/mp4' }); // console.log(blob); // if (window.navigator.msSaveOrOpenBlob) { // navigator.msSaveBlob(blob, fileName); // } else { - const reader = await new FileReader(); - await reader.readAsDataURL(blob); + const reader = new FileReader(); + reader.readAsDataURL(blob); // reader.readAsDataURL(blobFile); - reader.onloadend = await function () { + reader.onloadend = function () { const base64Data = reader.result; const link = document.createElement('a'); link.href = base64Data;