This commit is contained in:
李志鹏
2025-10-21 13:42:45 +08:00
parent b2003d8a85
commit 9b4458dfff

View File

@@ -57,18 +57,18 @@ export {
*/
export async function DownloadImages(list:Array<{url:string,name:string}>, onProgress?:(count:number,total:number,item:any)=>void, onError?:(count:number,total:number,item:any)=>void, onSuccess?:(successCount:number,errCount:number)=>void) {
const total = list.length;
var count = 0;
var successCount = 0;
var errCount = 0;
let count = 0;
let successCount = 0;
let errCount = 0;
for (let i = 0; i < list.length; i++) {
await new Promise((resolve) => {
let xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.open("GET", list[i].url);
xhr.responseType = "blob"
xhr.onload = function () {
count++;
if (this.status === 200) {
let blob = this.response;
const blob = this.response;
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = list[i].name || list[i].url;