更改下载图片名字

This commit is contained in:
李志鹏
2025-10-30 17:12:52 +08:00
parent 16b7b56932
commit a1a56050ce
3 changed files with 7 additions and 15 deletions

View File

@@ -108,7 +108,7 @@ export function FormatDate(value: Date | number | string, format: string = 'yyyy
* @param onError 下载错误回调
* @param onSuccess 下载成功回调
*/
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) {
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;
let count = 0;
let successCount = 0;
@@ -124,7 +124,7 @@ export async function DownloadImages(list: Array<{ url: string, name: string }>,
const blob = this.response;
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = list[i].name || list[i].url;
a.download = list[i].name || list[i].url.split('/').pop().split('?').shift();
a.click();
successCount++;
typeof onProgress === "function" && onProgress(count, total, list[i]);