Actualizar js/layout.js
This commit is contained in:
41
js/layout.js
41
js/layout.js
@@ -2,6 +2,47 @@
|
||||
AQUÍ ARRIBA ESTÁ TODO TU CÓDIGO ORIGINAL DEL LAYOUT
|
||||
(El que dibuja el sidebar, el header, el menú, etc.)
|
||||
... */
|
||||
// ==========================================
|
||||
// 🎨 INYECTOR DE LOGO CORPORATIVO (APP)
|
||||
// ==========================================
|
||||
setTimeout(async () => {
|
||||
if (!localStorage.getItem("token")) return;
|
||||
try {
|
||||
// Pedimos la configuración de la empresa a tu servidor
|
||||
const TRACK_API = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
|
||||
? 'http://localhost:3000'
|
||||
: 'https://integrarepara-api.integrarepara.es';
|
||||
|
||||
const res = await fetch(`${TRACK_API}/config/company`, {
|
||||
headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (data.ok && data.config && data.config.company_logo) {
|
||||
// Buscamos el cuadradito de la cabecera (el que tiene la inicial)
|
||||
// Normalmente en tu plantilla es el div naranja con flex center
|
||||
const headerIcon = document.querySelector('header .w-10.h-10.rounded-xl, #header-container .w-10.h-10');
|
||||
|
||||
if (headerIcon) {
|
||||
// Vaciamos la letra inicial
|
||||
headerIcon.innerHTML = '';
|
||||
// Le quitamos el fondo de color
|
||||
headerIcon.className = "w-10 h-10 flex shrink-0";
|
||||
headerIcon.style.background = "transparent";
|
||||
headerIcon.style.boxShadow = "none";
|
||||
|
||||
// Le inyectamos la imagen del logo
|
||||
const img = document.createElement('img');
|
||||
img.src = data.config.company_logo;
|
||||
img.className = "w-full h-full object-contain drop-shadow-sm";
|
||||
headerIcon.appendChild(img);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("No se pudo cargar el logo de la empresa", e);
|
||||
}
|
||||
}, 300); // Le damos 300ms de ventaja para que el HTML se dibuje primero
|
||||
|
||||
|
||||
// ==========================================
|
||||
// RASTREADOR FANTASMA GPS (MODO DE CAMINO)
|
||||
|
||||
Reference in New Issue
Block a user