Blindagem total da geracao de quadrinhos com retries em segundo plano (Alt+Tab), imagem de fallback SVG e preservacao dos quadros gerados
This commit is contained in:
@@ -743,7 +743,19 @@ app.post('/api/comics/generate-frame', requireAuth, async (req, res) => {
|
||||
}
|
||||
|
||||
if (!imageBuffer) {
|
||||
return res.status(500).json({ error: 'Não foi possível gerar a ilustração do quadro no momento. Por favor, tente novamente.' });
|
||||
console.warn('[Comics Frame] Todas as IAs de imagem falharam temporariamente para o prompt. Gerando placeholder de fallback resiliente.');
|
||||
const is169 = proporcao === '16:9' || (prompt && prompt.includes('16:9'));
|
||||
const w = is169 ? 1280 : 1024;
|
||||
const h = is169 ? 720 : 768;
|
||||
|
||||
const svgFallback = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">
|
||||
<rect width="100%" height="100%" fill="#1e293b"/>
|
||||
<rect x="20" y="20" width="${w-40}" height="${h-40}" rx="16" fill="none" stroke="#db2777" stroke-width="4" stroke-dasharray="8 8"/>
|
||||
<text x="50%" y="45%" dominant-baseline="middle" text-anchor="middle" fill="#f8fafc" font-family="sans-serif" font-size="28" font-weight="bold">🎨 Quadro Pronto para Ilustrar</text>
|
||||
<text x="50%" y="55%" dominant-baseline="middle" text-anchor="middle" fill="#94a3b8" font-family="sans-serif" font-size="20">Clique no botão 🔄 para gerar a imagem deste quadrinho</text>
|
||||
</svg>`;
|
||||
imageBuffer = Buffer.from(svgFallback, 'utf-8');
|
||||
providerUsed = 'fallback-placeholder';
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -756,7 +768,8 @@ app.post('/api/comics/generate-frame', requireAuth, async (req, res) => {
|
||||
|
||||
res.json({
|
||||
imageUrl: `/generated-media/${fileName}`,
|
||||
provider: providerUsed
|
||||
provider: providerUsed,
|
||||
needsRegeneration: providerUsed === 'fallback-placeholder'
|
||||
});
|
||||
} catch (saveErr) {
|
||||
console.error('Erro ao salvar imagem localmente:', saveErr);
|
||||
|
||||
Reference in New Issue
Block a user