fix: 更新背景图片URL并优化背景加载逻辑
移除未使用的分析脚本和广告代码 恢复背景图片加载检测功能 简化背景样式并移除冗余代码
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -126,11 +126,11 @@ const bannerOffset =
|
||||
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<script src="/js/umami-share.js" defer></script>
|
||||
<script
|
||||
<!-- <script src="/js/umami-share.js" defer></script> -->
|
||||
<!-- <script
|
||||
data-swup-ignore-script
|
||||
is:inline
|
||||
src="https://pic.acofork.com/random.js"></script>
|
||||
src="https://pic.acofork.com/random.js"></script> -->
|
||||
|
||||
{
|
||||
/* <!-- Content Security Policy -->
|
||||
@@ -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();
|
||||
// Background image loading detection
|
||||
const bgUrl = bgConfig.enable && bgConfig.src ? bgConfig.src : '';
|
||||
|
||||
// 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];
|
||||
// }
|
||||
// }
|
||||
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;
|
||||
}
|
||||
</script>
|
||||
<style
|
||||
define:vars={{
|
||||
@@ -262,18 +260,14 @@ const bannerOffset =
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: var(--bg-url);
|
||||
background-position: var(--bg-position);
|
||||
background-size: var(--bg-size);
|
||||
background-repeat: var(--bg-repeat);
|
||||
background-attachment: var(--bg-attachment);
|
||||
opacity: 0;
|
||||
opacity: var(--bg-opacity);
|
||||
pointer-events: none;
|
||||
z-index: -1;
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
#bg-box.loaded {
|
||||
opacity: calc(var(--bg-opacity) * var(--bg-enable));
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -286,22 +280,22 @@ const bannerOffset =
|
||||
href={`${Astro.site}rss.xml`}
|
||||
/>
|
||||
<!-- Umami分析(自建) -->
|
||||
<script
|
||||
<!-- <script
|
||||
defer
|
||||
src="https://umami.acofork.com/script.js"
|
||||
data-website-id="5d710dbd-3a2e-43e3-a553-97b415090c63"
|
||||
data-swup-ignore-script></script>
|
||||
data-swup-ignore-script></script> -->
|
||||
{
|
||||
/* - Umami分析(云-备用)
|
||||
<script defer src="https://cloud.umami.is/script.js" data-website-id="5d710dbd-3a2e-43e3-a553-97b415090c63" data-swup-ignore-script></script> */
|
||||
}
|
||||
<!-- 超级吊的Umami eop -->
|
||||
<script
|
||||
<!-- <script
|
||||
defer
|
||||
src="https://eo-umami.acofork.com/script.js"
|
||||
data-website-id="3f525363-5e81-4653-9491-1bd205c2a571"></script>
|
||||
data-website-id="3f525363-5e81-4653-9491-1bd205c2a571"></script> -->
|
||||
<!-- 百度统计 -->
|
||||
<script data-swup-ignore-script>
|
||||
<!-- <script data-swup-ignore-script>
|
||||
var _hmt = _hmt || [];
|
||||
(function () {
|
||||
var hm = document.createElement("script");
|
||||
@@ -309,10 +303,10 @@ const bannerOffset =
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</script>
|
||||
</script> -->
|
||||
|
||||
<!-- clarity 分析 -->
|
||||
<script type="text/javascript" data-swup-ignore-script>
|
||||
<!-- <script type="text/javascript" data-swup-ignore-script>
|
||||
(function (c, l, a, r, i, t, y) {
|
||||
c[a] =
|
||||
c[a] ||
|
||||
@@ -325,20 +319,20 @@ const bannerOffset =
|
||||
y = l.getElementsByTagName(r)[0];
|
||||
y.parentNode.insertBefore(t, y);
|
||||
})(window, document, "clarity", "script", "t8f0gmcwtx");
|
||||
</script>
|
||||
</script> -->
|
||||
<!-- gad -->
|
||||
<script
|
||||
<!-- <script
|
||||
async
|
||||
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1683686345039700"
|
||||
crossorigin="anonymous"
|
||||
data-swup-ignore-script></script>
|
||||
<meta name="google-adsense-account" content="ca-pub-1683686345039700" />
|
||||
<meta name="google-adsense-account" content="ca-pub-1683686345039700" /> -->
|
||||
|
||||
<!-- 谷歌分析 -->
|
||||
<script
|
||||
<!-- <script
|
||||
async
|
||||
src="https://www.googletagmanager.com/gtag/js?id=G-9Z4LT4H8KH"
|
||||
data-swup-ignore-script></script>
|
||||
data-swup-ignore-script></script> -->
|
||||
<script is:inline>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
@@ -350,11 +344,12 @@ const bannerOffset =
|
||||
</script>
|
||||
|
||||
<!-- Cloudflare Web Analytics -->
|
||||
<script
|
||||
<!-- <script
|
||||
defer
|
||||
src="https://static.cloudflareinsights.com/beacon.min.js"
|
||||
data-cf-beacon='{"token": "15fe148e91b34f10a15652e1a74ab26c"}'
|
||||
data-swup-ignore-script></script><!-- End Cloudflare Web Analytics -->
|
||||
data-swup-ignore-script></script> -->
|
||||
<!-- End Cloudflare Web Analytics -->
|
||||
</head>
|
||||
<body
|
||||
class="min-h-screen transition"
|
||||
@@ -438,11 +433,11 @@ const bannerOffset =
|
||||
}
|
||||
|
||||
// 页面加载完成后执行域名检测
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", checkDomain);
|
||||
} else {
|
||||
checkDomain();
|
||||
}
|
||||
// if (document.readyState === "loading") {
|
||||
// document.addEventListener("DOMContentLoaded", checkDomain);
|
||||
// } else {
|
||||
// checkDomain();
|
||||
// }
|
||||
</script>
|
||||
<Analytics />
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user