调整画布保存机制,把保存画布接口放到状态管理中,完善toRealStyle提示词
This commit is contained in:
@@ -19,10 +19,11 @@ export const downloadImage = (url: string, name: string) => {
|
||||
}
|
||||
|
||||
/** 批量下载图片 */
|
||||
export const downImgListToZip = async (imagesParams) => {
|
||||
export const downImgListToZip = async (imagesParams,callback) => {
|
||||
const zip = new JSZip()
|
||||
const promises = []
|
||||
// 遍历下载每个图片
|
||||
let progress = 0
|
||||
imagesParams.forEach((img, index) => {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest()
|
||||
@@ -32,18 +33,17 @@ export const downImgListToZip = async (imagesParams) => {
|
||||
if (xhr.status === 200) {
|
||||
const fileName = img.name
|
||||
zip.file(fileName, xhr.response)
|
||||
progress++
|
||||
callback(progress)
|
||||
resolve('')
|
||||
} else {
|
||||
reject(new Error(`下载失败: ${img.url}`))
|
||||
}
|
||||
}
|
||||
|
||||
xhr.onerror = () => reject(new Error(`网络错误: ${img.url}`))
|
||||
xhr.send()
|
||||
})
|
||||
|
||||
promises.push(promise)
|
||||
console.log(promises,zip)
|
||||
})
|
||||
|
||||
// 等待所有图片下载完成
|
||||
@@ -56,7 +56,7 @@ export const downImgListToZip = async (imagesParams) => {
|
||||
link.href = URL.createObjectURL(content)
|
||||
link.download = 'DesignFiles'
|
||||
link.click()
|
||||
URL.revokeObjectURL(link.href)
|
||||
// URL.revokeObjectURL(link.href)
|
||||
})
|
||||
.catch((error) => console.error('下载失败:', error))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user