feat: otimiza prompts de enquadramento da Fábrica de Quadrinhos e corrige fluxo do botão Criar Poesia
This commit is contained in:
+30
-5
@@ -2092,13 +2092,34 @@ const initApp = () => {
|
||||
document.querySelectorAll('.btn-prompt-mode').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
if (btn.id === 'barBtnEstudio') return; // Manipulado separadamente
|
||||
if (btn.id === 'barBtnComics') return; // Manipulado separadamente
|
||||
|
||||
const mode = btn.dataset.mode;
|
||||
const text = userInput.value.trim();
|
||||
|
||||
// Se não houver texto digitado, insere um exemplo de prompt baseado na modalidade
|
||||
if (!text) {
|
||||
// Se for modo POETRY ou TEXT, ou se o input estiver vazio, preenchemos o input com a sugestão correspondente sem enviar
|
||||
const isTextOrPoetry = (mode === 'POETRY' || mode === 'TEXT');
|
||||
|
||||
if (!text || isTextOrPoetry) {
|
||||
let suggestion = "";
|
||||
let baseText = text;
|
||||
|
||||
// Se o texto atual já for uma das sugestões padrão, limpamos para não duplicar
|
||||
const suggestionsList = [
|
||||
"Crie uma música pedagógica alegre e animada sobre ",
|
||||
"Crie um roteiro detalhado para um vídeo educativo sobre ",
|
||||
"Crie uma ilustração pedagógica com cores vibrantes mostrando ",
|
||||
"Escreva uma poesia infantil rimada e educativa sobre ",
|
||||
"Escreva uma história educativa infantil curta sobre "
|
||||
];
|
||||
|
||||
for (const sugg of suggestionsList) {
|
||||
if (baseText.startsWith(sugg)) {
|
||||
baseText = baseText.replace(sugg, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode === 'AUDIO') {
|
||||
suggestion = "Crie uma música pedagógica alegre e animada sobre ";
|
||||
} else if (mode === 'VIDEO') {
|
||||
@@ -2110,9 +2131,13 @@ const initApp = () => {
|
||||
} else if (mode === 'TEXT') {
|
||||
suggestion = "Escreva uma história educativa infantil curta sobre ";
|
||||
}
|
||||
userInput.value = suggestion;
|
||||
|
||||
userInput.value = suggestion + baseText;
|
||||
userInput.focus();
|
||||
|
||||
// Mover cursor para o final do texto
|
||||
userInput.selectionStart = userInput.selectionEnd = userInput.value.length;
|
||||
|
||||
// Ajustar altura do textarea para acomodar a sugestão
|
||||
userInput.style.height = 'auto';
|
||||
userInput.style.height = userInput.scrollHeight + 'px';
|
||||
@@ -2120,8 +2145,8 @@ const initApp = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Se houver texto, envia imediatamente forçando o modo correspondente (POETRY é gerado como texto)
|
||||
handleSendMessage(text, false, null, mode === 'POETRY' ? 'TEXT' : mode);
|
||||
// Se houver texto e for outro modo (AUDIO, VIDEO, IMAGE), envia imediatamente
|
||||
handleSendMessage(text, false, null, mode);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user