From b613e019dfea3c0e1c7af055af0ca644a94962b7 Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Fri, 16 Jan 2026 10:04:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 initThemeTransition 中的 MutationObserver(会导致无限循环) - 移除 will-change 属性(大量元素使用会占用过多内存) - 主题切换过渡效果已在 setDarkmode() 函数中实现,无需重复 --- argontheme.js | 14 +++----------- style.css | 2 -- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/argontheme.js b/argontheme.js index d968465..b1956d0 100644 --- a/argontheme.js +++ b/argontheme.js @@ -3710,18 +3710,10 @@ void 0; }); } - // 7. 主题切换动画 + // 7. 主题切换动画 - 已在 header.php 中通过 setDarkmode 函数处理,此处不再重复 function initThemeTransition() { - var observer = new MutationObserver(function(mutations) { - mutations.forEach(function(mutation) { - if (mutation.attributeName === 'class') { - var html = document.documentElement; - html.classList.add('theme-transitioning'); - setTimeout(function() { html.classList.remove('theme-transitioning'); }, 300); - } - }); - }); - observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] }); + // 移除 MutationObserver 避免无限循环导致内存泄漏 + // 主题切换过渡效果已在 setDarkmode() 函数中实现 } // 8. 减少动画偏好检测 diff --git a/style.css b/style.css index 19142b9..6847290 100644 --- a/style.css +++ b/style.css @@ -16327,7 +16327,6 @@ html.darkmode { @media (hover: hover) and (pointer: fine) { article.post.card { transition: transform var(--animation-normal) var(--ease-out-expo), box-shadow var(--animation-normal) var(--ease-standard); - will-change: transform, box-shadow; } article.post.card:hover { transform: translateY(-6px) scale(1.005); @@ -16340,7 +16339,6 @@ html.darkmode { } article.post.card .post-thumbnail { transition: transform var(--animation-slow) var(--ease-out-expo); - will-change: transform; } article.post.card:hover .post-thumbnail { transform: scale(1.05);