feat: automate CMYK PDF deployment to public folder and update download button to direct link

This commit is contained in:
Lucas Rayan committed 2026-08-23 12:32:36 -03:00
1 parent 8ad99a971d
commit afa1a6e027
2 files changed
+15 -36

No files matched your search

+1 -1
View File
@@ -72,7 +72,7 @@ export const metadata = {
}, },
}, },
icons: { icon: "/logo.png", apple: "/logo.png" }, icons: { icon: "/marca/espdocs-marca.svg", apple: "/marca/espdocs-marca.svg" },
formatDetection: { telephone: false, address: false, email: false }, formatDetection: { telephone: false, address: false, email: false },
}; };
+14 -35
View File
@@ -8,6 +8,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
<link rel="icon" type="image/svg+xml" href="../../marca/espdocs-marca.svg">
<link rel="stylesheet" href="../assets/apostila.css"> <link rel="stylesheet" href="../assets/apostila.css">
</head> </head>
<body> <body>
@@ -1980,7 +1981,7 @@ Temperatura: 26.1 C | Umidade: 62.0 %</code></pre>
</svg> </svg>
<span>Exportar PDF</span> <span>Exportar PDF</span>
</button> </button>
<button type="button" class="btn-exportar btn-exportar-cmyk" id="btnExportarCmyk" title="Exportar PDF convertido para espaço de cor CMYK (ISO Coated) para gráfica"> <button type="button" class="btn-exportar btn-exportar-cmyk" id="btnExportarCmyk" title="Exportar PDF em CMYK (ISO Coated) para gráfica">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"></circle> <circle cx="12" cy="12" r="10"></circle>
<path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"></path> <path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"></path>
@@ -2047,7 +2048,7 @@ Temperatura: 26.1 C | Umidade: 62.0 %</code></pre>
}, duracao); }, duracao);
} }
document.addEventListener("click", async (e) => { document.addEventListener("click", (e) => {
const btnRgb = e.target.closest("#btnExportarRgb"); const btnRgb = e.target.closest("#btnExportarRgb");
const btnCmyk = e.target.closest("#btnExportarCmyk"); const btnCmyk = e.target.closest("#btnExportarCmyk");
@@ -2061,44 +2062,22 @@ Temperatura: 26.1 C | Umidade: 62.0 %</code></pre>
if (btnCmyk) { if (btnCmyk) {
const textoOriginal = btnCmyk.innerHTML; const textoOriginal = btnCmyk.innerHTML;
btnCmyk.disabled = true;
btnCmyk.classList.add("carregando");
btnCmyk.innerHTML = `<span class="spinner-exportar"></span><span>Processando CMYK...</span>`;
exibirToast("Gerando PDF em CMYK (ISO Coated)... O download iniciará em instantes.", "info", 15000);
try { const iframe = document.createElement("iframe");
btnCmyk.disabled = true; iframe.style.display = "none";
btnCmyk.classList.add("carregando"); iframe.src = "/api/export-cmyk?modulo=1";
btnCmyk.innerHTML = `<span class="spinner-exportar"></span><span>Convertendo CMYK...</span>`; document.body.appendChild(iframe);
exibirToast("Gerando PDF e convertendo para CMYK (ISO Coated)... Aguarde alguns segundos.", "info", 8000);
const resposta = await fetch("/api/export-cmyk?modulo=1"); setTimeout(() => {
if (!resposta.ok) {
const erroJson = await resposta.json().catch(() => null);
throw new Error(erroJson?.error || "Serviço de conversão indisponível no momento.");
}
const blob = await resposta.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.style.display = "none";
a.href = url;
a.download = "LASER-ESP32-Modulo-1-CMYK.pdf";
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
a.remove();
exibirToast("✅ PDF em CMYK gerado e baixado com sucesso!", "sucesso", 5000);
} catch (erro) {
console.warn("Erro ao gerar CMYK via API:", erro);
exibirToast(
"💡 Dica: execute 'npm run exportar-cmyk 1' no terminal para gerar o arquivo CMYK imediatamente!",
"erro",
7000
);
} finally {
btnCmyk.disabled = false; btnCmyk.disabled = false;
btnCmyk.classList.remove("carregando"); btnCmyk.classList.remove("carregando");
btnCmyk.innerHTML = textoOriginal; btnCmyk.innerHTML = textoOriginal;
} setTimeout(() => iframe.remove(), 60000);
}, 8000);
} }
}); });
</script> </script>