From 00a0b09e206eb3a12fdc1b6b3ccdb1111463b375 Mon Sep 17 00:00:00 2001 From: marsalva Date: Sun, 13 Sep 2026 13:07:08 +0000 Subject: [PATCH] =?UTF-8?q?layout.js:=20a=C3=B1ade=20favicon=20din=C3=A1mi?= =?UTF-8?q?co=20(icono=20del=20logo=20en=20la=20pesta=C3=B1a)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/layout.js | 60 +++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/js/layout.js b/js/layout.js index 8aace0f..f01d73c 100644 --- a/js/layout.js +++ b/js/layout.js @@ -1,39 +1,45 @@ -/* ... - AQUÍ ARRIBA ESTÁ TODO TU CÓDIGO ORIGINAL DEL LAYOUT - (El que dibuja el sidebar, el header, el menú, etc.) +/* ... +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) // ========================================== -// 1. INYECCIÓN SÚPER RÁPIDA (Para engañar a los iPhone 🍏) +// Crea (o reutiliza) un de icono en el y le pone la URL indicada +function setIconLink(rel, href) { + let link = document.querySelector(`link[rel='${rel}']`); + if (!link) { + link = document.createElement('link'); + link.rel = rel; + document.head.appendChild(link); + } + link.href = href; +} + +// 1. INYECCIÓN SÚPER RÁPIDA (Para engañar a los iPhone 🍏 y pintar ya la pestaña del navegador) // Miramos si ya tenemos el logo guardado en la memoria del móvil const savedLogo = localStorage.getItem("company_logo"); if (savedLogo) { - 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 = savedLogo; + setIconLink('apple-touch-icon', savedLogo); + setIconLink('icon', savedLogo); } // 2. DESCARGA DESDE EL SERVIDOR Y CABECERA 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' + 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 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; @@ -44,29 +50,25 @@ setTimeout(async () => { 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.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); } - // Inyectamos el icono por si es la primera vez que entra - 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; + // Icono de la pestaña del navegador / favicon + setIconLink('icon', logoUrl); + // Icono al añadir la app a la pantalla de inicio (iOS) + setIconLink('apple-touch-icon', logoUrl); } } catch (e) { console.error("No se pudo cargar la configuración visual de la empresa", e); } -}, 100); +}, 100); // 🛑 RASTREADOR FANTASMA GPS (MODO DE CAMINO) DESACTIVADO TEMPORALMENTE 🛑 -// (Por petición del desarrollador, se ha eliminado el bloque setInterval del GPS) \ No newline at end of file +// (Por petición del desarrollador, se ha eliminado el bloque setInterval del GPS)