From fb6fb889fa31e7ba3e28683e53641cd9a4d480f6 Mon Sep 17 00:00:00 2001 From: odc.xiaohui <xiaohui@Q1> Date: 星期一, 06 十一月 2023 18:02:33 +0800 Subject: [PATCH] 修改视频专网 --- src/plugins/download.ts | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/src/plugins/download.ts b/src/plugins/download.ts index ef66b3a..2cdfa50 100644 --- a/src/plugins/download.ts +++ b/src/plugins/download.ts @@ -61,5 +61,29 @@ const rspObj = JSON.parse(resText); const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']; ElMessage.error(errMsg); - } + }, + async ossDown(ossId: string | number,pawd:string) { + const url = baseURL + '/resource/oss/download/' + ossId +'/' + pawd; + downloadLoadingInstance = ElLoading.service({ text: '姝e湪涓嬭浇鏁版嵁锛岃绋嶅��', background: 'rgba(0, 0, 0, 0.7)' }); + try { + const res = await axios({ + method: 'get', + url: url, + responseType: 'blob', + headers: globalHeaders() + }); + const isBlob = blobValidate(res.data); + if (isBlob) { + const blob = new Blob([res.data], { type: 'application/octet-stream' }); + FileSaver.saveAs(blob, decodeURIComponent(res.headers['download-filename'] as string)); + } else { + this.printErrMsg(res.data); + } + downloadLoadingInstance.close(); + } catch (r) { + console.error(r); + ElMessage.error('涓嬭浇鏂囦欢鍑虹幇閿欒锛岃鑱旂郴绠$悊鍛橈紒'); + downloadLoadingInstance.close(); + } + }, }; -- Gitblit v1.8.0