This commit is contained in:
2025-05-06 11:36:14 +08:00
parent ef99f9377c
commit 5325281fb4
7 changed files with 97 additions and 16 deletions

View File

@@ -45,16 +45,39 @@ export const copy = (context) => {
}
export const download = (urls) => {
const promises = urls.map((url, index) => new Promise((resolve, reject) => {
// #ifndef APP-PLUS
const promises1 = urls.map(url => new Promise((resolve, reject) => {
const iframe = document.createElement('iframe');
iframe.src = url;
iframe.style.display = 'none';
document.body.appendChild(iframe);
resolve(true);
}));
Promise.all(promises).then(res => {
console.log(res);
}).catch(err => {
console.log(err);
Promise.all(promises1).then(() => {
showToast('保存成功');
}).catch(() => {
showToast('保存失败');
});
// #endif
// #ifdef APP-PLUS
const promises2 = urls.map(v => new Promise((resolve, reject) => {
urls.forEach(v => {
uni.downloadFile({
url: v,
success: () => {
resolve(true);
},
fail: () => {
reject(false);
}
})
})
}));
Promise.all(promises2).then(() => {
showToast('保存成功');
}).catch(() => {
showToast('保存失败');
});
// #endif
}