Atualização automática: 2026-05-23 20:55:21
This commit is contained in:
@@ -312,21 +312,33 @@ async function applyUltraModernRedesign(cloneDir) {
|
||||
}
|
||||
|
||||
// Injetar o CSS de Redesign Ultra-Moderno gerado pela IA no site clonado
|
||||
let newPreviewUrl = `/api/preview/${cloneDir.split('/').pop()}`;
|
||||
try {
|
||||
await fetch('/api/ai/inject-redesign', {
|
||||
const response = await fetch('/api/ai/inject-redesign', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ cloneDir, appliedStyles, elementsRedesigned })
|
||||
body: JSON.stringify({
|
||||
cloneDir,
|
||||
appliedStyles,
|
||||
elementsRedesigned,
|
||||
outputDir: settings.outputDir,
|
||||
agentName: 'designer'
|
||||
})
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.newFolderName) {
|
||||
newPreviewUrl = `/api/preview/${data.newFolderName}`;
|
||||
if (agentsState.designer.currentClone) {
|
||||
agentsState.designer.currentClone.directory = 'cloned-sites/' + data.newFolderName;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Erro ao injetar CSS de redesign:", e);
|
||||
}
|
||||
|
||||
const previewUrl = `/api/preview/${cloneDir.split('/').pop()}`;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
previewUrl,
|
||||
previewUrl: newPreviewUrl,
|
||||
appliedStyles,
|
||||
elementsRedesigned
|
||||
};
|
||||
|
||||
@@ -304,7 +304,10 @@ async function startCloning(url, options) {
|
||||
response = await fetch('/api/smart-clone', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ url })
|
||||
body: JSON.stringify({
|
||||
url,
|
||||
outputDir: settings.outputDir
|
||||
})
|
||||
});
|
||||
} else {
|
||||
// WGET logic
|
||||
@@ -313,7 +316,8 @@ async function startCloning(url, options) {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
url,
|
||||
depth: options.depth
|
||||
depth: options.depth,
|
||||
outputDir: settings.outputDir
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -584,9 +588,13 @@ function loadSettings() {
|
||||
}
|
||||
|
||||
// Populate settings form (if needed)
|
||||
const outDirInput = document.getElementById('settingsOutputDir');
|
||||
if (outDirInput) outDirInput.value = settings.outputDir || '/root/Desktop/Clonados';
|
||||
}
|
||||
|
||||
function saveSettings() {
|
||||
const outDirInput = document.getElementById('settingsOutputDir');
|
||||
if (outDirInput) settings.outputDir = outDirInput.value;
|
||||
localStorage.setItem('cloneSettings', JSON.stringify(settings));
|
||||
showToast('Configurações salvas!', 'success');
|
||||
}
|
||||
|
||||
@@ -250,8 +250,8 @@
|
||||
<p>Local onde os sites clonados serão salvos</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<input type="text" class="form-control" value="M:\CLONEWEB\cloned-sites" readonly>
|
||||
<button class="btn btn-secondary btn-sm">
|
||||
<input type="text" id="settingsOutputDir" class="form-control" value="/root/Desktop/Clonados">
|
||||
<button class="btn btn-secondary btn-sm" onclick="openCloneFolder(document.getElementById('settingsOutputDir').value)">
|
||||
<i class="fas fa-folder-open"></i> Abrir
|
||||
</button>
|
||||
</div>
|
||||
@@ -293,7 +293,7 @@
|
||||
</div>
|
||||
|
||||
<div class="settings-actions">
|
||||
<button class="btn btn-primary">
|
||||
<button class="btn btn-primary" onclick="saveSettings()">
|
||||
<i class="fas fa-save"></i> Salvar Configurações
|
||||
</button>
|
||||
<button class="btn btn-secondary">
|
||||
|
||||
+42
-22
@@ -301,7 +301,7 @@ app.post('/api/wget-clone', async (req, res) => {
|
||||
const { exec } = require('child_process');
|
||||
const containerId = require('os').hostname();
|
||||
const cloneDir = directory.split('/').pop();
|
||||
const hostDir = '/root/Desktop/Clonados';
|
||||
const hostDir = req.body.outputDir || '/root/Desktop/Clonados';
|
||||
exec(`mkdir -p ${hostDir} && cp -r ${directory} ${hostDir}/ 2>/dev/null || docker cp ${containerId}:${directory} ${hostDir}/ 2>/dev/null`, (err) => {
|
||||
if (err) console.log('⚠️ Sync to host failed:', err.message);
|
||||
else console.log('✅ Clone synced to host Desktop:', cloneDir);
|
||||
@@ -378,7 +378,7 @@ app.post('/api/smart-clone', (req, res) => {
|
||||
const { exec } = require('child_process');
|
||||
const containerId = require('os').hostname();
|
||||
const cloneDir = directory.split('/').pop();
|
||||
const hostDir = '/root/Desktop/Clonados';
|
||||
const hostDir = req.body.outputDir || '/root/Desktop/Clonados';
|
||||
exec(`mkdir -p ${hostDir} && cp -r ${directory} ${hostDir}/ 2>/dev/null || docker cp ${containerId}:${directory} ${hostDir}/ 2>/dev/null`, (err) => {
|
||||
if (err) console.log('⚠️ SmartClone sync to host failed:', err.message);
|
||||
else console.log('✅ SmartClone synced to host Desktop:', cloneDir);
|
||||
@@ -634,11 +634,11 @@ app.post('/api/ai/agent', async (req, res) => {
|
||||
|
||||
// AI Inject Redesign Route (Pilar 1 - Agente Designer Real)
|
||||
app.post('/api/ai/inject-redesign', (req, res) => {
|
||||
const { cloneDir, appliedStyles, elementsRedesigned } = req.body;
|
||||
const { cloneDir, appliedStyles, elementsRedesigned, outputDir, agentName } = req.body;
|
||||
if (!cloneDir) return res.status(400).json({ error: 'cloneDir is required' });
|
||||
|
||||
const folderName = cloneDir.split('/').pop();
|
||||
const folderPath = path.join(__dirname, '..', 'cloned-sites', folderName);
|
||||
const originalFolderName = cloneDir.split('/').pop();
|
||||
const folderPath = path.join(__dirname, '..', 'cloned-sites', originalFolderName);
|
||||
|
||||
if (!fs.existsSync(folderPath)) {
|
||||
return res.status(404).json({ error: 'Cloned site folder not found' });
|
||||
@@ -753,26 +753,46 @@ p, span, li, label, td, th {
|
||||
}
|
||||
`;
|
||||
|
||||
const cssPath = path.join(folderPath, '__ai_redesign.css');
|
||||
fs.writeFileSync(cssPath, cssContent, 'utf8');
|
||||
const newFolderName = `${originalFolderName}_${agentName || 'designer'}`;
|
||||
const newFolderPath = path.join(__dirname, '..', 'cloned-sites', newFolderName);
|
||||
|
||||
// 2. Injetar a tag <link> no index.html do clone
|
||||
const indexPath = path.join(folderPath, 'index.html');
|
||||
if (fs.existsSync(indexPath)) {
|
||||
let html = fs.readFileSync(indexPath, 'utf8');
|
||||
const linkTag = `\n<link rel="stylesheet" href="/__ai_redesign.css" id="__AI_REDESIGN_LINK__">\n`;
|
||||
|
||||
if (!html.includes('__ai_redesign.css')) {
|
||||
if (html.includes('</head>')) {
|
||||
html = html.replace('</head>', linkTag + '</head>');
|
||||
} else {
|
||||
html = linkTag + html;
|
||||
}
|
||||
fs.writeFileSync(indexPath, html, 'utf8');
|
||||
// Copy the original folder to the new folder
|
||||
exec(`cp -r "${folderPath}" "${newFolderPath}"`, (copyErr) => {
|
||||
if (copyErr) {
|
||||
console.error('Error copying folder for agent redesign:', copyErr);
|
||||
return res.status(500).json({ error: 'Failed to create new agent folder' });
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ success: true, message: 'AI Redesign CSS injected successfully' });
|
||||
// 1. Criar o arquivo CSS de Redesign Ultra-Moderno (__ai_redesign.css) no novo diretório
|
||||
const cssPath = path.join(newFolderPath, '__ai_redesign.css');
|
||||
fs.writeFileSync(cssPath, cssContent, 'utf8');
|
||||
|
||||
// 2. Injetar a tag <link> no index.html do novo clone
|
||||
const indexPath = path.join(newFolderPath, 'index.html');
|
||||
if (fs.existsSync(indexPath)) {
|
||||
let html = fs.readFileSync(indexPath, 'utf8');
|
||||
const linkTag = `\n<link rel="stylesheet" href="/__ai_redesign.css" id="__AI_REDESIGN_LINK__">\n`;
|
||||
|
||||
if (!html.includes('__ai_redesign.css')) {
|
||||
if (html.includes('</head>')) {
|
||||
html = html.replace('</head>', linkTag + '</head>');
|
||||
} else {
|
||||
html = linkTag + html;
|
||||
}
|
||||
fs.writeFileSync(indexPath, html, 'utf8');
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Sincronizar o novo diretório com o host
|
||||
const hostDir = outputDir || '/root/Desktop/Clonados';
|
||||
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:', newFolderName);
|
||||
});
|
||||
|
||||
res.json({ success: true, message: 'AI Redesign CSS injected successfully', newFolderName });
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error injecting AI redesign:', err);
|
||||
res.status(500).json({ error: err.message });
|
||||
|
||||
Reference in New Issue
Block a user