更改下载图片名字
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user