mirror of
https://github.com/afoim/fuwari.git
synced 2026-01-31 09:03:18 +08:00
fix(背景图片): 更新背景图片URL并优化加载逻辑
将背景图片URL统一更新为https://cf-img.acofork.com/h 移除原随机脚本注释并优化背景图片加载检测逻辑 使用伪元素替代原bg-box div实现背景效果
This commit is contained in:
@@ -37,7 +37,7 @@ export const siteConfig: SiteConfig = {
|
|||||||
},
|
},
|
||||||
background: {
|
background: {
|
||||||
enable: true, // Enable background image
|
enable: true, // Enable background image
|
||||||
src: "", // Background image URL (supports HTTPS)
|
src: "https://cf-img.acofork.com/h", // Background image URL (supports HTTPS)
|
||||||
position: "center", // Background position: 'top', 'center', 'bottom'
|
position: "center", // Background position: 'top', 'center', 'bottom'
|
||||||
size: "cover", // Background size: 'cover', 'contain', 'auto'
|
size: "cover", // Background size: 'cover', 'contain', 'auto'
|
||||||
repeat: "no-repeat", // Background repeat: 'no-repeat', 'repeat', 'repeat-x', 'repeat-y'
|
repeat: "no-repeat", // Background repeat: 'no-repeat', 'repeat', 'repeat-x', 'repeat-y'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: 加群向导
|
title: 加群向导
|
||||||
image: /random/h
|
image: https://cf-img.acofork.com/h
|
||||||
published: 2025-05-24
|
published: 2025-05-24
|
||||||
pinned: true
|
pinned: true
|
||||||
category: 置顶
|
category: 置顶
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
category: 记录
|
category: 记录
|
||||||
description: 一些记录,不定时更新
|
description: 一些记录,不定时更新
|
||||||
draft: false
|
draft: false
|
||||||
image: /random/h
|
image: https://cf-img.acofork.com/h
|
||||||
lang: zh_CN
|
lang: zh_CN
|
||||||
published: 1999-01-01
|
published: 1999-01-01
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ const bannerOffset =
|
|||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<meta name="generator" content={Astro.generator} />
|
<meta name="generator" content={Astro.generator} />
|
||||||
<script src="/js/umami-share.js" defer></script>
|
<script src="/js/umami-share.js" defer></script>
|
||||||
<script data-swup-ignore-script is:inline src="https://pic.acofork.com/random.js"></script>
|
{/* <!-- <script data-swup-ignore-script is:inline src="https://pic.acofork.com/random.js"></script> --> */}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/* <!-- Content Security Policy -->
|
{/* <!-- Content Security Policy -->
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' https://giscus.app https://hpic.072103.xyz https://umami.acofork.com https://hm.baidu.com https://www.googletagmanager.com https://www.google-analytics.com https://pagead2.googlesyndication.com https://googleads.g.doubleclick.net https://static.cloudflareinsights.com https://*.adtrafficquality.google; style-src 'self' 'unsafe-inline' https://giscus.app https://fonts.googleapis.com https://api.iconify.design; font-src 'self' https://fonts.gstatic.com https://api.iconify.design; img-src 'self' data: https: http:; connect-src 'self' https://umami.acofork.com https://hm.baidu.com https://www.google-analytics.com https://analytics.google.com https://api.iconify.design https://static.cloudflareinsights.com https://pic.2x.nz https://q2.qlogo.cn https://ep1.adtrafficquality.google https://googleads.g.doubleclick.net; frame-src 'self' https://giscus.app *.bilibili.com https://www.google.com https://googleads.g.doubleclick.net https://support.nodeget.com https://*.adtrafficquality.google; object-src 'none'; base-uri 'self'; form-action 'self';"> */}
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' https://giscus.app https://hpic.072103.xyz https://umami.acofork.com https://hm.baidu.com https://www.googletagmanager.com https://www.google-analytics.com https://pagead2.googlesyndication.com https://googleads.g.doubleclick.net https://static.cloudflareinsights.com https://*.adtrafficquality.google; style-src 'self' 'unsafe-inline' https://giscus.app https://fonts.googleapis.com https://api.iconify.design; font-src 'self' https://fonts.gstatic.com https://api.iconify.design; img-src 'self' data: https: http:; connect-src 'self' https://umami.acofork.com https://hm.baidu.com https://www.google-analytics.com https://analytics.google.com https://api.iconify.design https://static.cloudflareinsights.com https://pic.2x.nz https://q2.qlogo.cn https://ep1.adtrafficquality.google https://googleads.g.doubleclick.net; frame-src 'self' https://giscus.app *.bilibili.com https://www.google.com https://googleads.g.doubleclick.net https://support.nodeget.com https://*.adtrafficquality.google; object-src 'none'; base-uri 'self'; form-action 'self';"> */}
|
||||||
@@ -160,6 +162,28 @@ const bannerOffset =
|
|||||||
let offset = Math.floor(window.innerHeight * (BANNER_HEIGHT_EXTEND / 100));
|
let offset = Math.floor(window.innerHeight * (BANNER_HEIGHT_EXTEND / 100));
|
||||||
offset = offset - offset % 4;
|
offset = offset - offset % 4;
|
||||||
document.documentElement.style.setProperty('--banner-height-extend', `${offset}px`);
|
document.documentElement.style.setProperty('--banner-height-extend', `${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];
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style define:vars={{
|
<style define:vars={{
|
||||||
configHue,
|
configHue,
|
||||||
@@ -193,24 +217,27 @@ const bannerOffset =
|
|||||||
--bg-opacity: var(--bg-opacity);
|
--bg-opacity: var(--bg-opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
#bg-box {
|
body::before {
|
||||||
position: fixed;
|
content: '' !important;
|
||||||
top: 0;
|
position: fixed !important;
|
||||||
left: 0;
|
top: 0 !important;
|
||||||
width: 100%;
|
left: 0 !important;
|
||||||
height: 100%;
|
width: 100% !important;
|
||||||
background-position: var(--bg-position);
|
height: 100% !important;
|
||||||
background-size: var(--bg-size);
|
background-image: var(--bg-url) !important;
|
||||||
background-repeat: var(--bg-repeat);
|
background-position: var(--bg-position) !important;
|
||||||
background-attachment: var(--bg-attachment);
|
background-size: var(--bg-size) !important;
|
||||||
opacity: 0;
|
background-repeat: var(--bg-repeat) !important;
|
||||||
pointer-events: none;
|
background-attachment: var(--bg-attachment) !important;
|
||||||
z-index: -1;
|
opacity: 0 !important;
|
||||||
transition: opacity 0.3s ease-in-out;
|
pointer-events: none !important;
|
||||||
|
z-index: -1 !important;
|
||||||
|
display: block !important;
|
||||||
|
transition: opacity 0.3s ease-in-out !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#bg-box.loaded {
|
body.bg-loaded::before {
|
||||||
opacity: calc(var(--bg-opacity) * var(--bg-enable));
|
opacity: calc(var(--bg-opacity) * var(--bg-enable)) !important;
|
||||||
}
|
}
|
||||||
</style> <!-- defines global css variables. This will be applied to <html> <body> and some other elements idk why -->
|
</style> <!-- defines global css variables. This will be applied to <html> <body> and some other elements idk why -->
|
||||||
|
|
||||||
@@ -262,7 +289,6 @@ var _hmt = _hmt || [];
|
|||||||
<body class=" min-h-screen transition " class:list={[{"lg:is-home": isHomePage, "enable-banner": enableBanner}]}
|
<body class=" min-h-screen transition " class:list={[{"lg:is-home": isHomePage, "enable-banner": enableBanner}]}
|
||||||
data-overlayscrollbars-initialize
|
data-overlayscrollbars-initialize
|
||||||
>
|
>
|
||||||
<div id="bg-box"></div>
|
|
||||||
<ConfigCarrier></ConfigCarrier>
|
<ConfigCarrier></ConfigCarrier>
|
||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user