64 lines
2.8 KiB
JavaScript
64 lines
2.8 KiB
JavaScript
/* ...
|
|
AQUÍ ARRIBA ESTÁ TODO TU CÓDIGO ORIGINAL DEL LAYOUT
|
|
(El que dibuja el sidebar, el header, el menú, etc.)
|
|
... */
|
|
|
|
// ==========================================
|
|
// 🎨 INYECTOR DE LOGO CORPORATIVO Y PWA (ICONOS APP)
|
|
// ==========================================
|
|
setTimeout(async () => {
|
|
if (!localStorage.getItem("token")) return;
|
|
|
|
try {
|
|
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) {
|
|
const logoUrl = data.config.company_logo;
|
|
|
|
// 1. INYECTAR EN LA CABECERA (Reemplaza la letra naranja por el logo)
|
|
const headerIcon = document.querySelector('header .w-10.h-10.rounded-xl, #header-container .w-10.h-10');
|
|
if (headerIcon) {
|
|
headerIcon.innerHTML = '';
|
|
headerIcon.className = "w-10 h-10 flex shrink-0 items-center justify-center";
|
|
headerIcon.style.background = "transparent";
|
|
headerIcon.style.boxShadow = "none";
|
|
|
|
const img = document.createElement('img');
|
|
img.src = logoUrl;
|
|
img.className = "max-w-full max-h-full object-contain drop-shadow-sm";
|
|
headerIcon.appendChild(img);
|
|
}
|
|
|
|
// 2. INYECTAR ICONO DE APP (Favicon para PC y Android)
|
|
let favicon = document.querySelector("link[rel~='icon']");
|
|
if (!favicon) {
|
|
favicon = document.createElement('link');
|
|
favicon.rel = 'icon';
|
|
document.head.appendChild(favicon);
|
|
}
|
|
favicon.href = logoUrl;
|
|
|
|
// 3. INYECTAR ICONO DE iPHONE (Apple Touch Icon)
|
|
// Esto le dice a Safari qué foto usar si le dan a "Añadir a la pantalla de inicio"
|
|
let appleIcon = document.querySelector("link[rel='apple-touch-icon']");
|
|
if (!appleIcon) {
|
|
appleIcon = document.createElement('link');
|
|
appleIcon.rel = 'apple-touch-icon';
|
|
document.head.appendChild(appleIcon);
|
|
}
|
|
appleIcon.href = logoUrl;
|
|
}
|
|
} catch (e) {
|
|
console.error("No se pudo cargar la configuración visual de la empresa", e);
|
|
}
|
|
}, 300); // Pequeño retraso para dejar que el HTML se dibuje primero
|
|
|
|
// 🛑 RASTREADOR FANTASMA GPS (MODO DE CAMINO) DESACTIVADO TEMPORALMENTE 🛑
|
|
// (Por petición del desarrollador, se ha eliminado el bloque setInterval del GPS)
|