Atualização automática: 2026-05-24 01:20:13

This commit is contained in:
Hermes
2026-05-24 01:20:13 +00:00
parent 8f454e89ba
commit fc90b0df00
2 changed files with 19 additions and 16 deletions
+6 -4
View File
@@ -316,7 +316,7 @@ async function applyUltraModernRedesign(cloneDir) {
try {
const rawResponse = await askAI(prompt, `Planeje o redesign do site no diretório: ${cloneDir}`);
const jsonStr = rawResponse.replace(/```json/gi, '').replace(/```/g, '').trim();
let jsonStr = rawResponse.match(/\{[\s\S]*\}/)?.[0] || '{}';
const parsed = JSON.parse(jsonStr);
if (parsed.appliedStyles) appliedStyles = parsed.appliedStyles;
if (parsed.elementsRedesigned) elementsRedesigned = parsed.elementsRedesigned;
@@ -324,8 +324,9 @@ async function applyUltraModernRedesign(cloneDir) {
console.error("Erro na IA do Designer:", e);
}
// Injetar o CSS de Redesign Ultra-Moderno gerado pela IA no site clonado
let newPreviewUrl = `/api/preview/${cloneDir.split('/').pop()}`;
// Remover barra no final se houver
let cleanDir = cloneDir.endsWith('/') ? cloneDir.slice(0, -1) : cloneDir;
let newPreviewUrl = `/api/preview/${cleanDir.split('/').pop()}`;
try {
const response = await fetch('/api/ai/inject-redesign', {
method: 'POST',
@@ -335,7 +336,8 @@ async function applyUltraModernRedesign(cloneDir) {
appliedStyles,
elementsRedesigned,
outputDir: settings.outputDir,
agentName: 'designer'
agentName: 'designer',
isCustomPath: agentsState.designer?.currentClone?.isCustomPath || false
})
});
const data = await response.json();
+7 -6
View File
@@ -680,11 +680,14 @@ app.post('/api/ai/inject-redesign', (req, res) => {
if (isCustomPath) {
// Se for um caminho customizado absoluto fornecido pelo usuário
folderPath = cloneDir;
originalFolderName = path.basename(folderPath);
newFolderPath = path.join(path.dirname(folderPath), `${originalFolderName}_${agentName || 'designer'}`);
const cleanPath = cloneDir.endsWith('/') ? cloneDir.slice(0, -1) : cloneDir;
originalFolderName = path.basename(cleanPath);
// Sempre salvar a versão do designer em cloned-sites para o preview funcionar
newFolderPath = path.join(__dirname, '..', 'cloned-sites', `${originalFolderName}_${agentName || 'designer'}`);
} else {
// Comportamento padrão (lendo da storage interna cloned-sites)
originalFolderName = cloneDir.split('/').pop();
const cleanDir = cloneDir.endsWith('/') ? cloneDir.slice(0, -1) : cloneDir;
originalFolderName = cleanDir.split('/').pop();
folderPath = path.join(__dirname, '..', 'cloned-sites', originalFolderName);
newFolderPath = path.join(__dirname, '..', 'cloned-sites', `${originalFolderName}_${agentName || 'designer'}`);
}
@@ -829,15 +832,13 @@ p, span, li, label, td, th {
}
}
// 3. Sincronizar o novo diretório com o host (somente se NÃO for customPath, pois customPath já está no lugar certo)
if (!isCustomPath) {
// 3. Sincronizar o novo diretório com o host
const hostDir = outputDir || '/root/Desktop/CLONE_SITE';
const containerId = require('os').hostname();
exec(`mkdir -p "${hostDir}" && cp -r "${newFolderPath}" "${hostDir}/" 2>/dev/null || docker cp ${containerId}:"${newFolderPath}" "${hostDir}/" 2>/dev/null`, (syncErr) => {
if (syncErr) console.log('⚠️ Redesign sync to host failed:', syncErr.message);
else console.log('✅ Redesign synced to host output dir:', path.basename(newFolderPath));
});
}
res.json({ success: true, message: 'AI Redesign CSS injected successfully', newFolderName: path.basename(newFolderPath) });
});