fix file down
This commit is contained in:
parent
a318455eda
commit
9e2833cdee
@ -109,7 +109,14 @@ const handleDownload = (url) => {
|
|||||||
// 创建一个隐藏的a元素
|
// 创建一个隐藏的a元素
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.download = url.split("/").pop(); // 从URL提取文件名
|
|
||||||
|
// 修复文件名提取逻辑
|
||||||
|
let fileName = url.split("/").pop();
|
||||||
|
// 移除可能存在的查询参数
|
||||||
|
if (fileName.includes("?") || fileName.includes("_t=")) {
|
||||||
|
fileName = fileName.split(/[?_]/)[0];
|
||||||
|
}
|
||||||
|
link.download = fileName;
|
||||||
link.target = "_blank";
|
link.target = "_blank";
|
||||||
|
|
||||||
// 对于移动设备,我们需要特殊处理
|
// 对于移动设备,我们需要特殊处理
|
||||||
|
Loading…
Reference in New Issue
Block a user