From 8cceb83e81e87b468806265fb2f4161e115521d1 Mon Sep 17 00:00:00 2001 From: jump-and-jump <984292420@qq.com> Date: Wed, 9 Apr 2025 20:36:28 +0800 Subject: [PATCH] fix: The banner configuration is not enabled, resulting in console error (#293) * 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> --- src/layouts/Layout.astro | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 375c4f4f..a61344b0 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -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() {