From 3f280dd9ef4610f83b3e85d1490fddda06fd5e2c Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Fri, 16 Jan 2026 15:08:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BE=A7=E8=BE=B9?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E5=BD=95=E5=92=8CTODO=E6=BA=A2=E5=87=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=A2=9E=E5=BC=BA=E5=BA=8F=E5=8F=B7?= =?UTF-8?q?=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 part2 和 part3 高度自适应,避免内容溢出窗口 - part2 和 part3 动态分配可用空间(part2 占 60%,part3 占 40%) - 增强序号识别:支持第一、第二、(1)、[1]、I. II. 等格式 - 移除 todo-list-scroll 固定高度限制,改为动态计算 --- argontheme.js | 29 ++++++++++++++++++++++++++++- sidebar.php | 8 ++++---- style.css | 18 ++++++++++++------ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/argontheme.js b/argontheme.js index b1956d0..62d3114 100644 --- a/argontheme.js +++ b/argontheme.js @@ -524,8 +524,35 @@ $(document).on("change" , ".search-filter" , function(e){ leftbarPart2.classList.add('sticky'); if (leftbarPart3) { leftbarPart3.classList.add('sticky'); - // 动态设置 part2 高度变量 + // 计算可用空间并分配给 part2 和 part3 + let viewportHeight = window.innerHeight; + let topOffset = argonConfig.headroom !== 'absolute' ? 90 : 20; + let availableHeight = viewportHeight - topOffset - 20; // 20px 底部边距 + + // 获取 part3 的自然高度(不受限制时的高度) + leftbarPart3.style.maxHeight = 'none'; + let part3NaturalHeight = leftbarPart3.scrollHeight; + leftbarPart3.style.maxHeight = ''; + + // 最小高度限制 + let minPart2Height = 150; + let minPart3Height = 100; + + // 计算分配 + let part2Height, part3MaxHeight; + if (part3NaturalHeight + minPart2Height <= availableHeight) { + // part3 可以完全显示 + part3MaxHeight = part3NaturalHeight; + part2Height = availableHeight - part3NaturalHeight - 10; + } else { + // 需要按比例分配,part2 占 60%,part3 占 40% + part2Height = Math.max(minPart2Height, availableHeight * 0.6); + part3MaxHeight = Math.max(minPart3Height, availableHeight - part2Height - 10); + } + document.documentElement.style.setProperty('--leftbar-part2-height', leftbarPart2.offsetHeight + 10 + 'px'); + document.documentElement.style.setProperty('--leftbar-part3-height', part3MaxHeight + 'px'); + document.documentElement.style.setProperty('--leftbar-part3-max-height', part3MaxHeight + 'px'); } }else{ //滚动条在顶部 不浮动状态 diff --git a/sidebar.php b/sidebar.php index 91345d3..d792376 100644 --- a/sidebar.php +++ b/sidebar.php @@ -558,9 +558,9 @@ $author_desc = get_option('argon_sidebar_author_description'); return; } - // 检测是否有标题已经带序号(如 "1. xxx" 或 "1.1 xxx") - var numberPattern = /^[\d一二三四五六七八九十]+[.、.]\s*/; - var hasNumberedHeadings = false; + // 检测是否有标题已经带序号 + // 支持格式:1. 1.1 一、二、第一、第二、(1) (一) [1] 等 + var numberPattern = /^([\d一二三四五六七八九十百千]+[.、.::]\s*|第[一二三四五六七八九十百千\d]+[章节部分条款、]\s*|[(\(【\[]\s*[\d一二三四五六七八九十]+\s*[)\)】\]]\s*|[IVXLCDM]+[.、.]\s*)/; var numberedCount = 0; items.forEach(function(item) { @@ -571,7 +571,7 @@ $author_desc = get_option('argon_sidebar_author_description'); }); // 如果超过一半的标题已有序号,认为文章自带编号 - hasNumberedHeadings = numberedCount > items.length / 2; + var hasNumberedHeadings = numberedCount > items.length / 2; if (!hasNumberedHeadings) { // 添加 CSS 计数器样式 diff --git a/style.css b/style.css index 6847290..3c71da6 100644 --- a/style.css +++ b/style.css @@ -2531,13 +2531,9 @@ html.navbar-absolute #leftbar_part2.sticky { } #leftbar_part2_inner { - - max-height: calc(100vh - 110px); - + max-height: calc(100vh - 110px - var(--leftbar-part3-height, 0px)); overflow-y: auto; - padding: 10px; - } #leftbar_part2_inner::-webkit-scrollbar { @@ -12607,6 +12603,16 @@ article .post-content .huhua a:before { position: fixed; top: calc(80px + var(--leftbar-part2-height, 300px)); width: 240px; + max-height: var(--leftbar-part3-max-height, 50vh); + overflow: hidden; + display: flex; + flex-direction: column; +} + +#leftbar_part3.sticky .card-body { + overflow-y: auto; + flex: 1; + min-height: 0; } body.leftbar-can-headroom.headroom---unpinned #leftbar_part3.sticky { @@ -12706,7 +12712,7 @@ html.navbar-absolute #leftbar_part3.sticky { } .todo-list-scroll { - max-height: 240px; + max-height: none; overflow-y: auto; padding-right: 5px; }