ali 3 سال پیش
والد
کامیت
8fc374aa9f
1فایلهای تغییر یافته به همراه18 افزوده شده و 15 حذف شده
  1. 18 15
      src/components/FormBuilderCustumComponents/ContentMedias/ContentMedias.vue

+ 18 - 15
src/components/FormBuilderCustumComponents/ContentMedias/ContentMedias.vue

@@ -159,22 +159,25 @@ export default {
         return
       }
       if (this.showDownloadLink) {
-        if (media.file) {
-          const fileName = (media.file.match(/(?<=\/)[^/?#]+(?=[^/]*$)/gm) || [media.title])[0]
-          this.fetchLoading = true
-          fetch(media.file)
-            .then(response => response.blob())
-            .then(blob => {
-              const link = document.createElement('a')
-              link.href = URL.createObjectURL(blob)
-              link.download = fileName
-              link.click()
-              this.fetchLoading = false
-            })
-            .catch(() => {
-              this.fetchLoading = false
-            })
+        const source = media.file || media.url
+        if (!source) {
+          return
         }
+
+        const fileName = (source.match(/(?<=\/)[^/?#]+(?=[^/]*$)/gm) || [media.title])[0]
+        this.fetchLoading = true
+        fetch(source)
+          .then(response => response.blob())
+          .then(blob => {
+            const link = document.createElement('a')
+            link.href = URL.createObjectURL(blob)
+            link.download = fileName
+            link.click()
+            this.fetchLoading = false
+          })
+          .catch(() => {
+            this.fetchLoading = false
+          })
       }
     },
     onDelete (media) {