From 6e6001e3cdb5c98bb7c18db0a0eedbc6c357464b Mon Sep 17 00:00:00 2001 From: lirui Date: Fri, 16 Jan 2026 22:41:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=9B=BE=E7=89=87URL=E5=B9=B6=E4=BC=98=E5=8C=96=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除未使用的分析脚本和广告代码 恢复背景图片加载检测功能 简化背景样式并移除冗余代码 --- src/config.ts | 2 +- src/layouts/Layout.astro | 93 +++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/src/config.ts b/src/config.ts index 58a3cac..3732232 100644 --- a/src/config.ts +++ b/src/config.ts @@ -35,7 +35,7 @@ export const siteConfig: SiteConfig = { }, background: { enable: true, // Enable background image - src: "https://t.alcy.cc/acg", // Background image URL (supports HTTPS) + src: "https://t.alcy.cc/ycy", // Background image URL (supports HTTPS) position: "center", // Background position: 'top', 'center', 'bottom' size: "cover", // Background size: 'cover', 'contain', 'auto' repeat: "no-repeat", // Background repeat: 'no-repeat', 'repeat', 'repeat-x', 'repeat-y' diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index fc9f949..c456313 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -126,11 +126,11 @@ const bannerOffset = - - --> + { /* @@ -198,27 +198,25 @@ const bannerOffset = `${offset}px` ); - // // Background image loading detection - // const bgUrl = getComputedStyle(document.documentElement).getPropertyValue('--bg-url').trim(); - // const bgEnable = getComputedStyle(document.documentElement).getPropertyValue('--bg-enable').trim(); - - // if (bgUrl && bgUrl !== 'none' && bgEnable === '1') { - // const img = new Image(); - // const urlMatch = bgUrl.match(/url\(["']?([^"')]+)["']?\)/); - // if (urlMatch) { - // img.onload = function() { - // // 背景图片完全加载后,显示背景并启用卡片透明效果 - // document.body.classList.add('bg-loaded'); - // document.documentElement.style.setProperty('--card-bg', 'var(--card-bg-transparent)'); - // document.documentElement.style.setProperty('--float-panel-bg', 'var(--float-panel-bg-transparent)'); - // }; - // img.onerror = function() { - // // Keep cards opaque if background image fails to load - // console.warn('Background image failed to load, keeping cards opaque'); - // }; - // img.src = urlMatch[1]; - // } - // } + // Background image loading detection + const bgUrl = bgConfig.enable && bgConfig.src ? bgConfig.src : ''; + + if (bgUrl) { + const img = new Image(); + img.onload = function() { + // 背景图片完全加载后,显示背景并启用卡片透明效果 + document.body.classList.add('bg-loaded'); + document.getElementById('bg-box').classList.add('loaded'); + document.documentElement.style.setProperty('--card-bg', 'var(--card-bg-transparent)'); + document.documentElement.style.setProperty('--float-panel-bg', 'var(--float-panel-bg-transparent)'); + document.documentElement.style.setProperty('--page-bg', 'transparent'); + }; + img.onerror = function() { + // Keep cards opaque if background image fails to load + console.warn('Background image failed to load, keeping cards opaque'); + }; + img.src = bgUrl; + }