fix download manual

This commit is contained in:
Warunee Tamkoo 2025-12-26 15:49:58 +07:00
parent 4176c97cba
commit cb999562bb

View file

@ -81,12 +81,13 @@ onMounted(async () => {
}); });
const downloadManual = () => { const downloadManual = () => {
const fileName = route.fullPath.split("/").pop(); const fileName = route.fullPath.split("/").pop(); // example: chapter-1-1
const origin = window.location.origin; const origin = window.location.origin; // example: http://localhost:8080
const pathname = window.location.pathname; const pathname = window.location.pathname; // example: /manual/chapter-1-1
const url = ref<string>(""); const url = ref<string>("");
if (pathname.includes("manual")) { if (pathname.includes("manual")) {
const pdfUrl = origin + pathname.replace("manual", "documents") + ".pdf"; // const pdfUrl = origin + pathname.replace("manual", "documents") + ".pdf";
const pdfUrl = origin + "/manual/documents/" + fileName + ".pdf";
url.value = pdfUrl; url.value = pdfUrl;
} else { } else {
const pdfUrl = origin + "/documents" + pathname + ".pdf"; const pdfUrl = origin + "/documents" + pathname + ".pdf";
@ -101,9 +102,10 @@ const downloadManual = () => {
document.body.removeChild(link); document.body.removeChild(link);
}; };
const downloadManualAll = (title:string) => { const downloadManualAll = (title: string) => {
const fileName = `manual-${title}.pdf`; const fileName = `manual-${title}.pdf`;
const pdfUrl = window.location.origin + `/documents/manual-${title}.pdf`; const pdfUrl =
window.location.origin + `/manual/documents/manual-${title}.pdf`;
const link = document.createElement("a"); const link = document.createElement("a");
link.href = pdfUrl; link.href = pdfUrl;
link.download = `${fileName}`; // link.download = `${fileName}`; //