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; }