refactor: downloadBlobFile with direct blob download logic

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-05-29 13:55:05 +07:00
parent 650de029f3
commit a0f0443a55

View file

@ -2,7 +2,6 @@ import axios from "axios";
import config from "@/app.config"; import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { downloadBlobFile } from "@/modules/10_registry/utils/downloadFile";
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { showLoader, hideLoader } = mixin; const { showLoader, hideLoader } = mixin;
@ -32,11 +31,16 @@ async function genReport(data: any, fileName: string, type: string = "docx") {
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);
const baseName = fileName.trim(); const baseName = fileName.trim();
// const extension = type === "docx" ? "docx" : "pdf"; const extension = type === "docx" ? "docx" : "pdf";
await downloadBlobFile({ const link = document.createElement("a");
downloadUrl: url, link.href = url;
fileName: baseName, link.download = `${baseName}.${extension}`;
}); document.body.appendChild(link);
link.click();
setTimeout(() => {
document.body.removeChild(link);
URL.revokeObjectURL(url);
}, 100);
} }
}) })
.catch((err) => { .catch((err) => {