From 3aac9a84ad34fa765d3bb2322ba35f0e9ca53b72 Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期四, 21 十二月 2023 17:05:44 +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