Procházet zdrojové kódy

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

YunaiV před 4 měsíci
rodič
revize
0958a1d146
1 změnil soubory, kde provedl 10 přidání a 19 odebrání
  1. 10 19
      src/utils/download.ts

+ 10 - 19
src/utils/download.ts

@@ -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)
       }
     },