优化渲染逻辑
This commit is contained in:
@@ -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 = '<img src="' + logoToUse + '" alt="Logo" class="logo-icon-img">';
|
||||
} 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 });
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
@@ -60,7 +85,7 @@
|
||||
<div class="header-left">
|
||||
<div class="logo">
|
||||
<div id="logoIconContainer">
|
||||
<svg class="logo-icon" id="logoSvg" viewBox="0 0 32 32" fill="none">
|
||||
<svg class="logo-icon" id="logoSvg" viewBox="0 0 32 32" fill="none" style="visibility: hidden;">
|
||||
<rect x="2" y="2" width="28" height="28" rx="8" stroke="url(#logoGrad)" stroke-width="2.5" />
|
||||
<path d="M8 22 L12 14 L16 18 L20 10 L24 16" stroke="url(#logoGrad)" stroke-width="2"
|
||||
stroke-linecap="round" stroke-linejoin="round" fill="none" />
|
||||
@@ -74,7 +99,7 @@
|
||||
</defs>
|
||||
</svg>
|
||||
</div>
|
||||
<h1 class="logo-text" id="logoText">数据可视化展示大屏</h1>
|
||||
<h1 class="logo-text" id="logoText"></h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
|
||||
Reference in New Issue
Block a user