// Eigenes Logo und Favicon der Installation. // Beides ist optional: Ist nichts hinterlegt, antwortet das Backend mit 404 // und die Oberfläche bleibt bei ihrem eingebauten Zeichen. export const BRANDING_KINDS = ["logo", "favicon"]; export function brandingUrl(kind, version) { return `/api/branding/${kind}${version ? `?v=${version}` : ""}`; } /** * Fragt beim Server ab, welche eigenen Bilder hinterlegt sind. * * Frueher lief das als HEAD-Anfrage auf das Bild selbst. FastAPI beantwortet * eine GET-Route aber nicht automatisch auch mit HEAD – die Anfrage endete in * einem 405, und ein hochgeladenes Logo wurde nie angezeigt. Jetzt liefert der * Server einen kleinen Status, ganz ohne Bilddaten. */ export async function brandingStatus() { try { const resp = await fetch("/api/branding"); if (!resp.ok) return {}; return await resp.json(); } catch { return {}; // Server nicht erreichbar: eingebautes Zeichen genügt. } } /** Prüft, ob ein eigenes Bild hinterlegt ist (ohne es zu laden). */ export async function hasBranding(kind) { const status = await brandingStatus(); return Boolean(status[kind]); } /** * Setzt das Favicon auf das hinterlegte Bild. * Läuft bewusst schon vor dem Login – der Browser holt das Favicon sofort. */ export async function applyFavicon() { const link = document.querySelector("link[rel='icon']"); if (!link) return; if (await hasBranding("favicon")) { link.href = brandingUrl("favicon", Date.now()); } }