fix: The banner configuration is not enabled, resulting in console error (#293)
Some checks failed
Code quality / quality (push) Failing after 4s
Build and Check / Astro Check for Node.js 22 (push) Failing after 4s
Build and Check / Astro Check for Node.js 23 (push) Failing after 3s
Build and Check / Astro Build for Node.js 22 (push) Failing after 4s
Build and Check / Astro Build for Node.js 23 (push) Failing after 4s

* fix: The banner configuration is not enabled, resulting in console errors

* refactor: simplify banner visibility check and improve error handling in showBanner function

---------

Co-authored-by: jump-and-jump <984292420@qq.com>
Co-authored-by: L4Ph <4ranci0ne@gmail.com>
This commit is contained in:
jump-and-jump
2025-04-09 20:36:28 +08:00
committed by GitHub
parent 9a21c0e9e1
commit 8cceb83e81

View File

@@ -208,7 +208,9 @@ import {
BANNER_HEIGHT,
BANNER_HEIGHT_HOME,
BANNER_HEIGHT_EXTEND,
MAIN_PANEL_OVERLAPS_BANNER_HEIGHT} from "../constants/constants";
MAIN_PANEL_OVERLAPS_BANNER_HEIGHT
} from "../constants/constants";
import { siteConfig } from '../config';
/* Preload fonts */
// (async function() {
@@ -325,12 +327,15 @@ function initCustomScrollbar() {
}
function showBanner() {
const banner = document.getElementById('banner')
if (!siteConfig.banner.enable) return;
const banner = document.getElementById('banner');
if (!banner) {
console.error('Failed to find the banner element')
return
console.error('Banner element not found');
return;
}
banner.classList.remove('opacity-0', 'scale-105')
banner.classList.remove('opacity-0', 'scale-105');
}
function init() {