fix:download 使用 wot-toast 之后,微信小程序无法打开的问题

This commit is contained in:
YunaiV
2025-12-17 22:45:06 +08:00
parent d6a50762bd
commit 0958a1d146

View File

@@ -3,9 +3,6 @@
*/
import { isH5, isMpWeixin } from '@uni-helper/uni-env'
import { useToast } from 'wot-design-uni'
const toast = useToast()
/** 保存图片到相册 */
export async function saveImageToAlbum(url: string, fileName?: string): Promise<void> {
@@ -23,16 +20,12 @@ export async function saveImageToAlbum(url: string, fileName?: string): Promise<
if (downloadResult.statusCode === 200) {
saveToAlbum(downloadResult.tempFilePath, resolve, reject)
} else {
// 注释 by 芋艿:使用 wd-toast 替代
// uni.showToast({ icon: 'none', title: '下载失败' })
toast.show('下载失败')
uni.showToast({ icon: 'none', title: '下载失败' })
reject(new Error('Download failed'))
}
},
fail: (err) => {
// 注释 by 芋艿:使用 wd-toast 替代
// uni.showToast({ icon: 'none', title: '下载失败' })
toast.show('下载失败')
uni.showToast({ icon: 'none', title: '下载失败' })
reject(err)
},
})
@@ -52,11 +45,10 @@ function saveToAlbum(
uni.saveImageToPhotosAlbum({
filePath,
success: () => {
// uni.showToast({
// icon: 'success',
// title: '已保存到相册',
// })
toast.success('已保存到相册')
uni.showToast({
icon: 'success',
title: '已保存到相册',
})
resolve()
},
fail: (err) => {
@@ -83,11 +75,10 @@ function saveToAlbum(
},
})
} else {
// uni.showToast({
// icon: 'none',
// title: '保存失败',
// })
toast.show('保存失败')
uni.showToast({
icon: 'none',
title: '保存失败',
})
reject(err)
}
},