tangning 7 月之前
父节点
当前提交
93c375f08b
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      src/view/material/index.vue

+ 8 - 4
src/view/material/index.vue

@@ -246,19 +246,23 @@ const handleCommand = (command: string | number | object, item) => {
       break;
     default:
       // window.open(item.filesUrl)
-      downloadFile(item.filesUrl, item.fileName+'.'+item.fileFormat)
-      console.log("other", command);
+      console.log("other", item);
+      downloadFile(item.filesUrl, item.filesTitle)
   }
   // ElMessage(`click on item ${command}`)
 }
+function getExtension (name) {
+      return name.substring(name.lastIndexOf("."))
+}
 // 下载文件
 function downloadFile(sourceUrl, fileName,) {
-  const link = document.createElement('a');
+      console.log("other", sourceUrl, fileName);
+      const link = document.createElement('a');
   link.style.display = 'none';
   // 设置下载地址
   link.setAttribute('href', sourceUrl);
   // 设置文件名
-  link.setAttribute('download', fileName);
+  link.setAttribute('download', fileName + getExtension(sourceUrl));
   document.body.appendChild(link);
   link.click();
   document.body.removeChild(link);