Fix: Final Web UI image rendering logic

This commit is contained in:
Marcos
2026-03-22 12:45:49 -03:00
parent 75d2a16fec
commit 029b8973b3

View File

@@ -1041,8 +1041,14 @@
const panel = document.getElementById('insights-panel');
if (!panel) return;
// Injeta a senha web nas URLs das imagens para autenticação inline
const mdWithAuth = markdown.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(webPassword) + '&path=');
// Transforma caminhos da VPS (![alt](/host_root/...) em links da nossa API segura
// Ex: /host_root/root/img.jpg -> /api/host_file?pwd=...&path=/host_root/root/img.jpg
let mdWithAuth = markdown.replace(/!\[(.*?)\]\((\/host_root\/.*?)\)/g, (match, alt, path) => {
return `![${alt}](/api/host_file?pwd=${encodeURIComponent(webPassword)}&path=${encodeURIComponent(path)})`;
});
// Fallback para qualquer outro caso que tenha sobrado do prefixo antigo
mdWithAuth = mdWithAuth.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(webPassword) + '&path=');
// Renderiza o Markdown para HTML usando marked.js
panel.innerHTML = `<div class="animate-fade-in">${marked.parse(mdWithAuth)}</div>`;