|
@@ -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);
|