xianniu-ui 0.5.2-beta.3 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xianniu-ui",
3
- "version": "0.5.2-beta.3",
3
+ "version": "0.5.3",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -297,15 +297,24 @@ export default {
297
297
  this.imageView = file.url;
298
298
  });
299
299
  },
300
- async handleDownload({ url }) {
301
- const elt = document.createElement("a");
302
- elt.setAttribute("href", url);
303
- elt.setAttribute("download", "下载文件");
304
- elt.style.display = "none";
305
- elt.target = "_blank";
306
- document.body.appendChild(elt);
307
- elt.click();
308
- document.body.removeChild(elt);
300
+ async handleDownload(file) {
301
+ const {url,name} = file
302
+ const x= new XMLHttpRequest()
303
+ x.open('GET',url,true)
304
+ x.responseType = 'blob'
305
+ x.onload = function(){
306
+ const _url = window.URL.createObjectURL(x.response)
307
+ const elt = document.createElement("a");
308
+ elt.setAttribute("href", _url);
309
+ elt.setAttribute("download", name);
310
+ elt.style.display = "none";
311
+ elt.target = "_blank";
312
+ document.body.appendChild(elt);
313
+ elt.click();
314
+ document.body.removeChild(elt);
315
+ }
316
+ x.send()
317
+
309
318
  },
310
319
  handleRemove(file, fileList) {
311
320
  fileList.forEach((item, idx) => {