fix: 更新背景图片URL并优化背景加载逻辑
移除未使用的分析脚本和广告代码 恢复背景图片加载检测功能 简化背景样式并移除冗余代码
This commit is contained in:
@@ -35,7 +35,7 @@ export const siteConfig: SiteConfig = {
|
|||||||
},
|
},
|
||||||
background: {
|
background: {
|
||||||
enable: true, // Enable background image
|
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'
|
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'
|
||||||
|
|||||||
@@ -126,11 +126,11 @@ 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
|
<!-- <script
|
||||||
data-swup-ignore-script
|
data-swup-ignore-script
|
||||||
is:inline
|
is:inline
|
||||||
src="https://pic.acofork.com/random.js"></script>
|
src="https://pic.acofork.com/random.js"></script> -->
|
||||||
|
|
||||||
{
|
{
|
||||||
/* <!-- Content Security Policy -->
|
/* <!-- Content Security Policy -->
|
||||||
@@ -198,27 +198,25 @@ const bannerOffset =
|
|||||||
`${offset}px`
|
`${offset}px`
|
||||||
);
|
);
|
||||||
|
|
||||||
// // Background image loading detection
|
// Background image loading detection
|
||||||
// const bgUrl = getComputedStyle(document.documentElement).getPropertyValue('--bg-url').trim();
|
const bgUrl = bgConfig.enable && bgConfig.src ? bgConfig.src : '';
|
||||||
// const bgEnable = getComputedStyle(document.documentElement).getPropertyValue('--bg-enable').trim();
|
|
||||||
|
|
||||||
// if (bgUrl && bgUrl !== 'none' && bgEnable === '1') {
|
if (bgUrl) {
|
||||||
// const img = new Image();
|
const img = new Image();
|
||||||
// const urlMatch = bgUrl.match(/url\(["']?([^"')]+)["']?\)/);
|
img.onload = function() {
|
||||||
// if (urlMatch) {
|
// 背景图片完全加载后,显示背景并启用卡片透明效果
|
||||||
// img.onload = function() {
|
document.body.classList.add('bg-loaded');
|
||||||
// // 背景图片完全加载后,显示背景并启用卡片透明效果
|
document.getElementById('bg-box').classList.add('loaded');
|
||||||
// document.body.classList.add('bg-loaded');
|
document.documentElement.style.setProperty('--card-bg', 'var(--card-bg-transparent)');
|
||||||
// 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('--float-panel-bg', 'var(--float-panel-bg-transparent)');
|
document.documentElement.style.setProperty('--page-bg', 'transparent');
|
||||||
// };
|
};
|
||||||
// img.onerror = function() {
|
img.onerror = function() {
|
||||||
// // Keep cards opaque if background image fails to load
|
// Keep cards opaque if background image fails to load
|
||||||
// console.warn('Background image failed to load, keeping cards opaque');
|
console.warn('Background image failed to load, keeping cards opaque');
|
||||||
// };
|
};
|
||||||
// img.src = urlMatch[1];
|
img.src = bgUrl;
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
</script>
|
</script>
|
||||||
<style
|
<style
|
||||||
define:vars={{
|
define:vars={{
|
||||||
@@ -262,18 +260,14 @@ const bannerOffset =
|
|||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
background-image: var(--bg-url);
|
||||||
background-position: var(--bg-position);
|
background-position: var(--bg-position);
|
||||||
background-size: var(--bg-size);
|
background-size: var(--bg-size);
|
||||||
background-repeat: var(--bg-repeat);
|
background-repeat: var(--bg-repeat);
|
||||||
background-attachment: var(--bg-attachment);
|
background-attachment: var(--bg-attachment);
|
||||||
opacity: 0;
|
opacity: var(--bg-opacity);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
transition: opacity 0.3s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#bg-box.loaded {
|
|
||||||
opacity: calc(var(--bg-opacity) * var(--bg-enable));
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -286,22 +280,22 @@ const bannerOffset =
|
|||||||
href={`${Astro.site}rss.xml`}
|
href={`${Astro.site}rss.xml`}
|
||||||
/>
|
/>
|
||||||
<!-- Umami分析(自建) -->
|
<!-- Umami分析(自建) -->
|
||||||
<script
|
<!-- <script
|
||||||
defer
|
defer
|
||||||
src="https://umami.acofork.com/script.js"
|
src="https://umami.acofork.com/script.js"
|
||||||
data-website-id="5d710dbd-3a2e-43e3-a553-97b415090c63"
|
data-website-id="5d710dbd-3a2e-43e3-a553-97b415090c63"
|
||||||
data-swup-ignore-script></script>
|
data-swup-ignore-script></script> -->
|
||||||
{
|
{
|
||||||
/* - Umami分析(云-备用)
|
/* - Umami分析(云-备用)
|
||||||
<script defer src="https://cloud.umami.is/script.js" data-website-id="5d710dbd-3a2e-43e3-a553-97b415090c63" data-swup-ignore-script></script> */
|
<script defer src="https://cloud.umami.is/script.js" data-website-id="5d710dbd-3a2e-43e3-a553-97b415090c63" data-swup-ignore-script></script> */
|
||||||
}
|
}
|
||||||
<!-- 超级吊的Umami eop -->
|
<!-- 超级吊的Umami eop -->
|
||||||
<script
|
<!-- <script
|
||||||
defer
|
defer
|
||||||
src="https://eo-umami.acofork.com/script.js"
|
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 || [];
|
var _hmt = _hmt || [];
|
||||||
(function () {
|
(function () {
|
||||||
var hm = document.createElement("script");
|
var hm = document.createElement("script");
|
||||||
@@ -309,10 +303,10 @@ const bannerOffset =
|
|||||||
var s = document.getElementsByTagName("script")[0];
|
var s = document.getElementsByTagName("script")[0];
|
||||||
s.parentNode.insertBefore(hm, s);
|
s.parentNode.insertBefore(hm, s);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script> -->
|
||||||
|
|
||||||
<!-- clarity 分析 -->
|
<!-- 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) {
|
(function (c, l, a, r, i, t, y) {
|
||||||
c[a] =
|
c[a] =
|
||||||
c[a] ||
|
c[a] ||
|
||||||
@@ -325,20 +319,20 @@ const bannerOffset =
|
|||||||
y = l.getElementsByTagName(r)[0];
|
y = l.getElementsByTagName(r)[0];
|
||||||
y.parentNode.insertBefore(t, y);
|
y.parentNode.insertBefore(t, y);
|
||||||
})(window, document, "clarity", "script", "t8f0gmcwtx");
|
})(window, document, "clarity", "script", "t8f0gmcwtx");
|
||||||
</script>
|
</script> -->
|
||||||
<!-- gad -->
|
<!-- gad -->
|
||||||
<script
|
<!-- <script
|
||||||
async
|
async
|
||||||
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1683686345039700"
|
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1683686345039700"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
data-swup-ignore-script></script>
|
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
|
async
|
||||||
src="https://www.googletagmanager.com/gtag/js?id=G-9Z4LT4H8KH"
|
src="https://www.googletagmanager.com/gtag/js?id=G-9Z4LT4H8KH"
|
||||||
data-swup-ignore-script></script>
|
data-swup-ignore-script></script> -->
|
||||||
<script is:inline>
|
<script is:inline>
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
function gtag() {
|
function gtag() {
|
||||||
@@ -350,11 +344,12 @@ const bannerOffset =
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Cloudflare Web Analytics -->
|
<!-- Cloudflare Web Analytics -->
|
||||||
<script
|
<!-- <script
|
||||||
defer
|
defer
|
||||||
src="https://static.cloudflareinsights.com/beacon.min.js"
|
src="https://static.cloudflareinsights.com/beacon.min.js"
|
||||||
data-cf-beacon='{"token": "15fe148e91b34f10a15652e1a74ab26c"}'
|
data-cf-beacon='{"token": "15fe148e91b34f10a15652e1a74ab26c"}'
|
||||||
data-swup-ignore-script></script><!-- End Cloudflare Web Analytics -->
|
data-swup-ignore-script></script> -->
|
||||||
|
<!-- End Cloudflare Web Analytics -->
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body
|
||||||
class="min-h-screen transition"
|
class="min-h-screen transition"
|
||||||
@@ -438,11 +433,11 @@ const bannerOffset =
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 页面加载完成后执行域名检测
|
// 页面加载完成后执行域名检测
|
||||||
if (document.readyState === "loading") {
|
// if (document.readyState === "loading") {
|
||||||
document.addEventListener("DOMContentLoaded", checkDomain);
|
// document.addEventListener("DOMContentLoaded", checkDomain);
|
||||||
} else {
|
// } else {
|
||||||
checkDomain();
|
// checkDomain();
|
||||||
}
|
// }
|
||||||
</script>
|
</script>
|
||||||
<Analytics />
|
<Analytics />
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user