Atualização automática: 2026-05-24 01:20:13
This commit is contained in:
@@ -316,7 +316,7 @@ async function applyUltraModernRedesign(cloneDir) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const rawResponse = await askAI(prompt, `Planeje o redesign do site no diretório: ${cloneDir}`);
|
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);
|
const parsed = JSON.parse(jsonStr);
|
||||||
if (parsed.appliedStyles) appliedStyles = parsed.appliedStyles;
|
if (parsed.appliedStyles) appliedStyles = parsed.appliedStyles;
|
||||||
if (parsed.elementsRedesigned) elementsRedesigned = parsed.elementsRedesigned;
|
if (parsed.elementsRedesigned) elementsRedesigned = parsed.elementsRedesigned;
|
||||||
@@ -324,8 +324,9 @@ async function applyUltraModernRedesign(cloneDir) {
|
|||||||
console.error("Erro na IA do Designer:", e);
|
console.error("Erro na IA do Designer:", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Injetar o CSS de Redesign Ultra-Moderno gerado pela IA no site clonado
|
// Remover barra no final se houver
|
||||||
let newPreviewUrl = `/api/preview/${cloneDir.split('/').pop()}`;
|
let cleanDir = cloneDir.endsWith('/') ? cloneDir.slice(0, -1) : cloneDir;
|
||||||
|
let newPreviewUrl = `/api/preview/${cleanDir.split('/').pop()}`;
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/ai/inject-redesign', {
|
const response = await fetch('/api/ai/inject-redesign', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -335,7 +336,8 @@ async function applyUltraModernRedesign(cloneDir) {
|
|||||||
appliedStyles,
|
appliedStyles,
|
||||||
elementsRedesigned,
|
elementsRedesigned,
|
||||||
outputDir: settings.outputDir,
|
outputDir: settings.outputDir,
|
||||||
agentName: 'designer'
|
agentName: 'designer',
|
||||||
|
isCustomPath: agentsState.designer?.currentClone?.isCustomPath || false
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|||||||
@@ -680,11 +680,14 @@ app.post('/api/ai/inject-redesign', (req, res) => {
|
|||||||
if (isCustomPath) {
|
if (isCustomPath) {
|
||||||
// Se for um caminho customizado absoluto fornecido pelo usuário
|
// Se for um caminho customizado absoluto fornecido pelo usuário
|
||||||
folderPath = cloneDir;
|
folderPath = cloneDir;
|
||||||
originalFolderName = path.basename(folderPath);
|
const cleanPath = cloneDir.endsWith('/') ? cloneDir.slice(0, -1) : cloneDir;
|
||||||
newFolderPath = path.join(path.dirname(folderPath), `${originalFolderName}_${agentName || 'designer'}`);
|
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 {
|
} else {
|
||||||
// Comportamento padrão (lendo da storage interna cloned-sites)
|
// 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);
|
folderPath = path.join(__dirname, '..', 'cloned-sites', originalFolderName);
|
||||||
newFolderPath = path.join(__dirname, '..', 'cloned-sites', `${originalFolderName}_${agentName || 'designer'}`);
|
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)
|
// 3. Sincronizar o novo diretório com o host
|
||||||
if (!isCustomPath) {
|
|
||||||
const hostDir = outputDir || '/root/Desktop/CLONE_SITE';
|
const hostDir = outputDir || '/root/Desktop/CLONE_SITE';
|
||||||
const containerId = require('os').hostname();
|
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) => {
|
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);
|
if (syncErr) console.log('⚠️ Redesign sync to host failed:', syncErr.message);
|
||||||
else console.log('✅ Redesign synced to host output dir:', path.basename(newFolderPath));
|
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) });
|
res.json({ success: true, message: 'AI Redesign CSS injected successfully', newFolderName: path.basename(newFolderPath) });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user