Corrige prompt cinematografico de quadros, remove rate limit na geracao de 10 quadros e blinda modais contra clique fora
This commit is contained in:
+10
-105
@@ -2843,13 +2843,6 @@ const initApp = () => {
|
||||
btnExitRecord.addEventListener('click', closeRecordModal);
|
||||
}
|
||||
|
||||
// Fechar clicando fora
|
||||
if (recordModal) {
|
||||
recordModal.addEventListener('click', (e) => {
|
||||
if (e.target === recordModal) closeRecordModal();
|
||||
});
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// MODAL: MINHAS OBSERVAÇÕES
|
||||
// ============================================================
|
||||
@@ -2914,11 +2907,6 @@ const initApp = () => {
|
||||
obsModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
if (obsModal) {
|
||||
obsModal.addEventListener('click', (e) => {
|
||||
if (e.target === obsModal) obsModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Filtros
|
||||
if (obsFilterMes) obsFilterMes.addEventListener('change', renderObsList);
|
||||
@@ -3317,11 +3305,6 @@ const initApp = () => {
|
||||
}
|
||||
|
||||
if (btnCloseMinhaTurmaModal) btnCloseMinhaTurmaModal.addEventListener('click', () => minhaTurmaModal.style.display = 'none');
|
||||
if (minhaTurmaModal) {
|
||||
minhaTurmaModal.addEventListener('click', (e) => {
|
||||
if (e.target === minhaTurmaModal) minhaTurmaModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
if (btnCreateChild) btnCreateChild.addEventListener('click', clearChildForm);
|
||||
if (btnCancelChild) btnCancelChild.addEventListener('click', clearChildForm);
|
||||
@@ -3507,11 +3490,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
modelosRelatorioModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
if (modelosRelatorioModal) {
|
||||
modelosRelatorioModal.addEventListener('click', (e) => {
|
||||
if (e.target === modelosRelatorioModal) modelosRelatorioModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Buscar modelos do backend
|
||||
async function fetchTemplates() {
|
||||
@@ -3737,11 +3715,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
emitirRelatorioModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
if (emitirRelatorioModal) {
|
||||
emitirRelatorioModal.addEventListener('click', (e) => {
|
||||
if (e.target === emitirRelatorioModal) emitirRelatorioModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Buscar crianças com base nos filtros de Ano e Turma selecionados
|
||||
async function loadChildrenList() {
|
||||
@@ -4152,14 +4125,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
});
|
||||
}
|
||||
|
||||
// Fechar modal clicando fora
|
||||
window.addEventListener('click', (e) => {
|
||||
if (e.target === estudioMusicalModal) {
|
||||
estudioMusicalModal.style.display = 'none';
|
||||
musicStudioAudioPlayer.pause();
|
||||
}
|
||||
});
|
||||
|
||||
// Ação de gerar música no estúdio
|
||||
if (btnGenerateStudioMusic) {
|
||||
btnGenerateStudioMusic.addEventListener('click', async () => {
|
||||
@@ -5069,11 +5034,7 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
let completedCount = 0;
|
||||
|
||||
const generateSinglePanel = async (panel) => {
|
||||
let anchorPart = '';
|
||||
if (currentComicsCharDescEnglish) {
|
||||
anchorPart = `CHARACTER ANCHOR: [${currentComicsCharDescEnglish}]. `;
|
||||
}
|
||||
const fullPrompt = `${anchorPart}${panel.image_prompt}, high resolution children book illustration, cute Pixar style, ${selectedComicsRatio === '16:9' ? '16:9 aspect ratio' : '4:3 aspect ratio'}`;
|
||||
const fullPrompt = `${panel.image_prompt}, 3D Pixar Disney style, digital children book illustration, vibrant colors, masterpiece, cinematic lighting, ${selectedComicsRatio === '16:9' ? '16:9 aspect ratio' : '4:3 aspect ratio'}`;
|
||||
|
||||
let attempts = 0;
|
||||
let frameData = null;
|
||||
@@ -5091,11 +5052,11 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
frameData = await frameResp.json();
|
||||
} else {
|
||||
console.warn(`[Retry Comics] Tentativa ${attempts} para quadro ${panel.panel_number} respondeu ${frameResp.status}`);
|
||||
if (attempts < 3) await new Promise(r => setTimeout(r, 1200 * attempts));
|
||||
if (attempts < 3) await new Promise(r => setTimeout(r, 1500 * attempts));
|
||||
}
|
||||
} catch (netErr) {
|
||||
console.warn(`[Retry Comics] Tentativa ${attempts} erro de rede no quadro ${panel.panel_number}:`, netErr.message);
|
||||
if (attempts < 3) await new Promise(r => setTimeout(r, 1200 * attempts));
|
||||
if (attempts < 3) await new Promise(r => setTimeout(r, 1500 * attempts));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5104,6 +5065,9 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
if (comicsLoaderProgress) comicsLoaderProgress.style.width = `${progressPercent}%`;
|
||||
if (comicsLoaderText) comicsLoaderText.textContent = `🎨 Ilustrando quadrinhos: ${completedCount}/${totalPanels} quadros concluídos...`;
|
||||
|
||||
// Pequeno respiro entre gerações para respeitar a taxa da API
|
||||
await new Promise(r => setTimeout(r, 600));
|
||||
|
||||
if (frameData && frameData.imageUrl) {
|
||||
return {
|
||||
panel_number: panel.panel_number,
|
||||
@@ -5113,7 +5077,7 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
needsRegeneration: !!frameData.needsRegeneration
|
||||
};
|
||||
} else {
|
||||
console.warn(`[Comics Resiliencia] Quadro ${panel.panel_number} não pôde ser gerado após 3 tentativas. Preservando a história e liberando botão de regenerar.`);
|
||||
console.warn(`[Comics Resiliencia] Quadro ${panel.panel_number} em espera. Preservando a história.`);
|
||||
return {
|
||||
panel_number: panel.panel_number,
|
||||
imageUrl: '/assets/img/placeholder_comic.png',
|
||||
@@ -5124,8 +5088,8 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
}
|
||||
};
|
||||
|
||||
// Executa com no máximo 2 quadros em paralelo para estabilidade máxima e resposta fluida
|
||||
const newPanels = await mapConcurrent(scriptData.panels, 2, generateSinglePanel);
|
||||
// Executa com 1 quadro por vez sequencial para estabilidade absoluta e sem estourar rate limit
|
||||
const newPanels = await mapConcurrent(scriptData.panels, 1, generateSinglePanel);
|
||||
|
||||
// Ordena por panel_number para garantir a sequência correta
|
||||
newPanels.sort((a, b) => a.panel_number - b.panel_number);
|
||||
@@ -5343,12 +5307,7 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
}
|
||||
}
|
||||
|
||||
// Monta o prompt reforçado com a Âncora Visual Física de Personagens e Estilo 3D Pixar
|
||||
let anchorPart = '';
|
||||
if (currentComicsCharDescEnglish) {
|
||||
anchorPart = `CHARACTER ANCHOR: [${currentComicsCharDescEnglish}]. `;
|
||||
}
|
||||
const fullPrompt = `${anchorPart}${promptToUse}, high resolution children book illustration, cute Pixar style, ${selectedComicsRatio === '16:9' ? '16:9 aspect ratio' : '4:3 aspect ratio'}`;
|
||||
const fullPrompt = `${promptToUse}, 3D Pixar Disney style, digital children book illustration, vibrant colors, masterpiece, cinematic lighting, ${selectedComicsRatio === '16:9' ? '16:9 aspect ratio' : '4:3 aspect ratio'}`;
|
||||
|
||||
const resp = await fetch('/api/comics/generate-frame', {
|
||||
method: 'POST',
|
||||
@@ -5844,12 +5803,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('click', (e) => {
|
||||
if (e.target === videoMindModal) {
|
||||
videoMindModal.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Ação de analisar vídeo
|
||||
if (btnGenerateVideoMind) {
|
||||
btnGenerateVideoMind.addEventListener('click', async () => {
|
||||
@@ -6096,12 +6049,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('click', (e) => {
|
||||
if (e.target === garatujasModal) {
|
||||
garatujasModal.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Upload trigger
|
||||
if (btnUploadGaratuja) {
|
||||
btnUploadGaratuja.addEventListener('click', () => {
|
||||
@@ -6534,13 +6481,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
});
|
||||
}
|
||||
|
||||
poesiaModal.addEventListener('click', (e) => {
|
||||
if (e.target === poesiaModal) {
|
||||
poesiaModal.style.display = 'none';
|
||||
if (poesiaAudioPlayer) poesiaAudioPlayer.pause();
|
||||
}
|
||||
});
|
||||
|
||||
// Aplicar Template
|
||||
const applyPoesiaTemplate = (key) => {
|
||||
const tmpl = POESIA_TEMPLATES[key];
|
||||
@@ -6867,12 +6807,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
});
|
||||
}
|
||||
|
||||
poesiaHistoryModal.addEventListener('click', (e) => {
|
||||
if (e.target === poesiaHistoryModal) {
|
||||
poesiaHistoryModal.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
async function loadPoesiaHistory() {
|
||||
const listContainer = document.getElementById('poesiaHistoryList');
|
||||
if (!listContainer) return;
|
||||
@@ -7038,12 +6972,6 @@ Se algum dado não for mencionado, deixe a string vazia ou false para boolean.`
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('click', (e) => {
|
||||
if (e.target === brincarAtivoModal) {
|
||||
brincarAtivoModal.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Gerar Atividade
|
||||
if (btnGenerateBrincarAtivo) {
|
||||
btnGenerateBrincarAtivo.addEventListener('click', async () => {
|
||||
@@ -7473,13 +7401,6 @@ window.toggleCustomAudio = (btn) => {
|
||||
});
|
||||
}
|
||||
|
||||
musicaModal.addEventListener('click', (e) => {
|
||||
if (e.target === musicaModal) {
|
||||
musicaModal.style.display = 'none';
|
||||
if (musicaAudioPlayer) musicaAudioPlayer.pause();
|
||||
}
|
||||
});
|
||||
|
||||
// Aplicar Template
|
||||
const applyMusicaTemplate = (key) => {
|
||||
const tmpl = MUSICA_TEMPLATES[key];
|
||||
@@ -7774,12 +7695,6 @@ window.toggleCustomAudio = (btn) => {
|
||||
});
|
||||
}
|
||||
|
||||
musicaHistoryModal.addEventListener('click', (e) => {
|
||||
if (e.target === musicaHistoryModal) {
|
||||
musicaHistoryModal.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
async function loadMusicaHistory() {
|
||||
const listContainer = document.getElementById('musicaHistoryList');
|
||||
if (!listContainer) return;
|
||||
@@ -8053,7 +7968,6 @@ window.toggleCustomAudio = (btn) => {
|
||||
}
|
||||
|
||||
if (btnCloseHistoriaModal) {
|
||||
historiaModal.addEventListener('click', (e) => { if (e.target === historiaModal) historiaModal.style.display = 'none'; });
|
||||
btnCloseHistoriaModal.addEventListener('click', () => historiaModal.style.display = 'none');
|
||||
}
|
||||
|
||||
@@ -8065,7 +7979,6 @@ window.toggleCustomAudio = (btn) => {
|
||||
});
|
||||
}
|
||||
if (btnCloseHistoriaHistory) btnCloseHistoriaHistory.addEventListener('click', () => historiaHistoryModal.style.display = 'none');
|
||||
historiaHistoryModal.addEventListener('click', (e) => { if (e.target === historiaHistoryModal) historiaHistoryModal.style.display = 'none'; });
|
||||
|
||||
// Alternância de Abas
|
||||
function switchHistoriaTab(tab) {
|
||||
@@ -8612,9 +8525,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
btnCloseMindLabModal.addEventListener('click', () => {
|
||||
mindLabModal.style.display = 'none';
|
||||
});
|
||||
mindLabModal.addEventListener('click', (e) => {
|
||||
if (e.target === mindLabModal) mindLabModal.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
if (btnGenerateMindLab) {
|
||||
@@ -11024,7 +10934,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
let currentTimelineAlunoId = null;
|
||||
|
||||
if (btnCloseAlunoTimeline) btnCloseAlunoTimeline.addEventListener('click', () => alunoTimelineModal.style.display = 'none');
|
||||
if (alunoTimelineModal) alunoTimelineModal.addEventListener('click', (e) => { if (e.target === alunoTimelineModal) alunoTimelineModal.style.display = 'none'; });
|
||||
|
||||
window.viewChildTimeline = async (alunoId) => {
|
||||
currentTimelineAlunoId = alunoId;
|
||||
@@ -11196,7 +11105,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const btnProcessCsvImport = document.getElementById('btnProcessCsvImport');
|
||||
|
||||
if (btnCloseCsvImport) btnCloseCsvImport.addEventListener('click', () => csvImportModal.style.display = 'none');
|
||||
if (csvImportModal) csvImportModal.addEventListener('click', (e) => { if (e.target === csvImportModal) csvImportModal.style.display = 'none'; });
|
||||
|
||||
// Botão abrir CSV import (se presente na tela de turmas ou sidebar)
|
||||
window.openCsvImportModal = () => {
|
||||
@@ -11299,7 +11207,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
if (btnCloseCriseModal) btnCloseCriseModal.addEventListener('click', () => criseModal.style.display = 'none');
|
||||
if (criseModal) criseModal.addEventListener('click', (e) => { if (e.target === criseModal) criseModal.style.display = 'none'; });
|
||||
|
||||
if (btnOpenCrisesHistory) {
|
||||
btnOpenCrisesHistory.addEventListener('click', async () => {
|
||||
@@ -11437,7 +11344,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
if (btnCloseAtaModal) btnCloseAtaModal.addEventListener('click', () => ataModal.style.display = 'none');
|
||||
if (ataModal) ataModal.addEventListener('click', (e) => { if (e.target === ataModal) ataModal.style.display = 'none'; });
|
||||
|
||||
if (btnGerarAta) {
|
||||
btnGerarAta.addEventListener('click', async () => {
|
||||
@@ -11617,7 +11523,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
if (btnCloseStickerModal) btnCloseStickerModal.addEventListener('click', () => stickerModal.style.display = 'none');
|
||||
if (stickerModal) stickerModal.addEventListener('click', (e) => { if (e.target === stickerModal) stickerModal.style.display = 'none'; });
|
||||
|
||||
window.deleteStickerRecord = async (id) => {
|
||||
if (confirm('Deseja excluir este sticker?')) {
|
||||
|
||||
Reference in New Issue
Block a user