diff --git a/public/index.html b/public/index.html index 45fc8d2..d8e45e6 100644 --- a/public/index.html +++ b/public/index.html @@ -35,13 +35,38 @@ document.title = settings.page_name; } - // Handle page name visibility - if (settings.show_page_name === 0) { - document.addEventListener('DOMContentLoaded', function() { - const lt = document.getElementById('logoText'); - if (lt) lt.style.display = 'none'; - }); - } + // Advanced Anti-Flicker: Wait for header elements to appear + const observer = new MutationObserver(function(mutations, me) { + const logoText = document.getElementById('logoText'); + const logoIcon = document.getElementById('logoIconContainer'); + const header = document.getElementById('header'); + + if (logoText || logoIcon) { + // If we found either, apply what we have + if (logoText) { + const displayTitle = settings.title || settings.page_name || '数据可视化展示大屏'; + logoText.textContent = displayTitle; + if (settings.show_page_name === 0) logoText.style.display = 'none'; + } + + if (logoIcon) { + const actualTheme = document.documentElement.classList.contains('light-theme') ? 'light' : 'dark'; + const logoToUse = (actualTheme === 'dark' && settings.logo_url_dark) ? settings.logo_url_dark : (settings.logo_url || null); + if (logoToUse) { + logoIcon.innerHTML = 'Logo'; + } else { + // Only if we REALLY have no logo URL, we show the default SVG fallback + // (But since it's already in HTML, we just don't touch it or we show it if we hid it) + const svg = logoIcon.querySelector('svg'); + if (svg) svg.style.visibility = 'visible'; + } + } + + // Once found everything or we are past header, we are done + if (logoText && logoIcon) me.disconnect(); + } + }); + observer.observe(document.documentElement, { childList: true, subtree: true }); })(); @@ -60,7 +85,7 @@