Fix: Final Web UI image rendering logic
This commit is contained in:
@@ -1041,8 +1041,14 @@
|
|||||||
const panel = document.getElementById('insights-panel');
|
const panel = document.getElementById('insights-panel');
|
||||||
if (!panel) return;
|
if (!panel) return;
|
||||||
|
|
||||||
// Injeta a senha web nas URLs das imagens para autenticação inline
|
// Transforma caminhos da VPS ( em links da nossa API segura
|
||||||
const mdWithAuth = markdown.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(webPassword) + '&path=');
|
// 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 `}&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
|
// Renderiza o Markdown para HTML usando marked.js
|
||||||
panel.innerHTML = `<div class="animate-fade-in">${marked.parse(mdWithAuth)}</div>`;
|
panel.innerHTML = `<div class="animate-fade-in">${marked.parse(mdWithAuth)}</div>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user