update
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user