Compare commits

..

No commits in common. "b06317e5819a258a19ceb5d212d6d34917343987" and "97fc7d966bd98ae37c89253da3d8356957bd53d5" have entirely different histories.

2 changed files with 10 additions and 24 deletions

View File

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

View File

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