Quellcode durchsuchen

新增下载弹框

nirvana vor 2 Monaten
Ursprung
Commit
8a37b506ad
1 geänderte Dateien mit 13 neuen und 1 gelöschten Zeilen
  1. 13 1
      src/views/systemSetting/file/EditDialog.vue

+ 13 - 1
src/views/systemSetting/file/EditDialog.vue

@@ -119,8 +119,20 @@ export default {
         this.$message.error('文件上传失败: ' + response.message)
       }
     },
+    isValidFileUrl (url) {
+      const value = typeof url === 'string' ? url.trim() : ''
+      if (!value) return false
+      const invalidValues = ['null', 'undefined', '-']
+      if (invalidValues.includes(value.toLowerCase())) return false
+      return /^https?:\/\/[^\s]+$/i.test(value) || /^\/[^\s]*$/.test(value)
+    },
     copyFileUrl () {
-      this.copyTextToClipboard(this.form.fileUrl)
+      const fileUrl = typeof this.form.fileUrl === 'string' ? this.form.fileUrl.trim() : ''
+      if (!this.isValidFileUrl(fileUrl)) {
+        this.$message.error('获取失败,无法获取下载地址')
+        return
+      }
+      this.copyTextToClipboard(fileUrl)
     },
     applyAccountItem (accountItem) {
       if (!accountItem || !accountItem.id) return