Compare commits

...

2 Commits

Author SHA1 Message Date
张 元山
b06317e581 Merge branch 'main' of https://gitea-inner.fontree.cn/scout666/fiee-official-website 2025-05-26 16:03:52 +08:00
张 元山
44d3555e06 fix file down 2025-05-26 16:03:51 +08:00
2 changed files with 24 additions and 10 deletions

View File

@ -357,7 +357,6 @@ const downloadPdf = (url) => {
fileName = fileName.split(/[?_]/)[0];
}
link.download = fileName;
link.target = "_blank";
//
const isMobile =
@ -366,12 +365,15 @@ const downloadPdf = (url) => {
);
if (isMobile) {
// 使fetchblob
// 使fetch使blob URL
fetch(url)
.then((response) => response.blob())
.then((blob) => {
const objectUrl = URL.createObjectURL(blob);
link.href = objectUrl;
// downloadtarget="_blank"
link.download = fileName;
link.target = "_self"; //
document.body.appendChild(link);
link.click();
@ -383,11 +385,16 @@ const downloadPdf = (url) => {
})
.catch((error) => {
console.error("下载文件时出错:", error);
// fetch退window.open
window.open(url, "_blank");
// fetch
link.href = url;
link.download = fileName;
link.target = "_self";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
} else {
//
//
document.body.appendChild(link);
link.click();
document.body.removeChild(link);

View File

@ -357,7 +357,6 @@ const downloadPdf = (url) => {
fileName = fileName.split(/[?_]/)[0];
}
link.download = fileName;
link.target = "_blank";
//
const isMobile =
@ -366,12 +365,15 @@ const downloadPdf = (url) => {
);
if (isMobile) {
// 使fetchblob
// 使fetch使blob URL
fetch(url)
.then((response) => response.blob())
.then((blob) => {
const objectUrl = URL.createObjectURL(blob);
link.href = objectUrl;
// downloadtarget="_blank"
link.download = fileName;
link.target = "_self"; //
document.body.appendChild(link);
link.click();
@ -383,11 +385,16 @@ const downloadPdf = (url) => {
})
.catch((error) => {
console.error("下载文件时出错:", error);
// fetch退window.open
window.open(url, "_blank");
// fetch
link.href = url;
link.download = fileName;
link.target = "_self";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
} else {
//
//
document.body.appendChild(link);
link.click();
document.body.removeChild(link);