Commit a5497246 authored by 黄奎's avatar 黄奎

文件下载调整

parent ddabee40
...@@ -1138,7 +1138,6 @@ export default { ...@@ -1138,7 +1138,6 @@ export default {
}; };
try { try {
let url = oss.signatureUrl(objectKey); let url = oss.signatureUrl(objectKey);
console.log("url", url);
let getBlob = new Promise(resolve => { let getBlob = new Promise(resolve => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('GET', url, true); xhr.open('GET', url, true);
...@@ -1156,9 +1155,17 @@ export default { ...@@ -1156,9 +1155,17 @@ export default {
xhr.send(); xhr.send();
}); });
getBlob.then(blob => { getBlob.then(blob => {
if (window.navigator.msSaveOrOpenBlob) { if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, filename); navigator.msSaveBlob(blob, filename);
} else { resultJson.resultCode = 1;
if (callBack) {
callBack(resultJson)
}
} else {
resultJson.resultCode = 1;
if (callBack) {
callBack(resultJson)
}
const link = document.createElement('a'); const link = document.createElement('a');
const body = document.querySelector('body'); const body = document.querySelector('body');
link.href = window.URL.createObjectURL(blob); link.href = window.URL.createObjectURL(blob);
...@@ -1168,10 +1175,6 @@ export default { ...@@ -1168,10 +1175,6 @@ export default {
link.click(); link.click();
body.removeChild(link); body.removeChild(link);
window.URL.revokeObjectURL(link.href); window.URL.revokeObjectURL(link.href);
resultJson.resultCode = 1;
if (callBack) {
callBack(resultJson)
}
} }
}); });
} catch (err) { } catch (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment