From 85af3dcdd1332acea0b6d774d3fe22d78a1638b9 Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Fri, 23 Jan 2026 15:32:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=9A=E8=BF=87attr=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?style=E6=B7=BB=E5=8A=A0important=E5=BC=BA=E5=88=B6=E9=9A=90?= =?UTF-8?q?=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用attr方法直接修改style属性 - 添加!important确保优先级最高 - 移除调试日志,保持代码简洁 - 这是最终解决方案 --- argontheme.js | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/argontheme.js b/argontheme.js index 2ee7989..873e905 100644 --- a/argontheme.js +++ b/argontheme.js @@ -2832,25 +2832,10 @@ $(document).pjax("a[href]:not([no-pjax]):not(.no-pjax):not([target='_blank']):no $card.addClass("post-pjax-loading"); $("#main").addClass("post-list-pjax-loading"); - // 强制隐藏其他卡片 - $(".post-preview").not($card).css("opacity", "0"); - - // 调试信息 - console.log("=== 文章加载动画调试 ==="); - console.log("点击的卡片:", $card[0]); - console.log("#main 是否有 post-list-pjax-loading 类:", $("#main").hasClass("post-list-pjax-loading")); - console.log("页面中 .post-preview 总数:", $(".post-preview").length); - console.log("应该隐藏的 .post-preview 数量:", $("#main.post-list-pjax-loading .post-preview").length); - console.log("被点击的卡片是否有 post-pjax-loading 类:", $card.hasClass("post-pjax-loading")); - - // 检查CSS是否生效 - setTimeout(function() { - $(".post-preview").each(function(index) { - let opacity = $(this).css("opacity"); - let hasLoadingClass = $(this).hasClass("post-pjax-loading"); - console.log(`卡片 ${index}: opacity=${opacity}, hasLoadingClass=${hasLoadingClass}`); - }); - }, 100); + // 强制隐藏其他卡片 - 使用attr设置style以添加!important + $(".post-preview").not($card).each(function() { + $(this).attr('style', ($(this).attr('style') || '') + ' opacity: 0 !important; pointer-events: none !important;'); + }); let offsetTop = $($card).offset().top - $("#main").offset().top; if ($("html").hasClass("is-home") && $("html").hasClass("banner-as-cover")){