瀏覽代碼

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

xujunjie 1 年之前
父節點
當前提交
a9e17fc6a9
共有 1 個文件被更改,包括 5 次插入1 次删除
  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({