Parcourir la source

文件下载时对文件名进行编码

xujunjie il y a 1 an
Parent
commit
a9e17fc6a9
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5 1
      src/components/AttachmentTable/index.js

+ 5 - 1
src/components/AttachmentTable/index.js

@@ -43,7 +43,11 @@ function AttachmentTable(props) {
     },
   ];
   const downloadFile = record => {
-    window.location.href = `${record.url}`;
+    let urls = record.url.split('/');
+    let lastIndex = urls.length - 1;
+    // 对文件名编码
+    urls[lastIndex] = encodeURIComponent(urls[lastIndex]);
+    window.location.href = urls.join('/');
   };
   const deleteFile = id => {
     Modal.confirm({