From 0bb288dc86eee276eb37302490d7c929f66b0575 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 9 Nov 2026 15:32:53 +0800 Subject: [PATCH] =?UTF-8?q?style(doc):=20=E6=96=87=E6=A1=A3=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=B8=8D=E5=86=8D=E6=95=B4=E4=BD=93=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C=E6=BB=9A=E5=8A=A8=E6=9D=A1=E4=BB=85=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E5=9C=A8=E4=BE=A7=E8=BE=B9=E6=A0=8F=E4=B8=8E=E6=AD=A3=E6=96=87?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - body 固定视口高度、flex 纵向布局并 overflow:hidden,页面级滚动条移除,sidebar/content 各自独立滚动(含移动端 40vh 侧边栏) - 标题下显示创建时间(创建于),正文末尾显示最后更新时间(新增 .doc-foot 样式) - 新增 @media print,打印时恢复自然文档流避免长文被固定高度裁切 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- backend/app/service/doc_site.js | 63 ++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/backend/app/service/doc_site.js b/backend/app/service/doc_site.js index da0ff72..2d6413e 100644 --- a/backend/app/service/doc_site.js +++ b/backend/app/service/doc_site.js @@ -266,6 +266,7 @@ class DocSiteService extends Service { const rendered = markdown.render(this.stripLeadingTitle(current.content, current.title)); const toc = rendered.toc.filter(item => item.level >= 2 && item.level <= 4); + const created = dateOnly(current.createdAt || current.created_at); const updated = dateOnly(current.updatedAt || current.updated_at); const summary = current.summary || markdown.plainText(current.content, 140); @@ -273,7 +274,7 @@ class DocSiteService extends Service {

${escape(current.title)}

${summary ? `

${escape(summary)}

` : ''} - ${updated ? `

最近更新:${updated}

` : ''} + ${created ? `

创建于:${created}

` : ''}
${rendered.html} @@ -282,6 +283,7 @@ class DocSiteService extends Service {
本页目录
` : ''} + ${updated ? `

最后更新:${updated}

` : ''} `; } @@ -347,21 +349,26 @@ ${this.styles()} --code-bg: #0f172a; } * { box-sizing: border-box; } -html, body { margin: 0; padding: 0; } +html, body { margin: 0; padding: 0; height: 100%; } body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: #fff; line-height: 1.75; font-size: 15px; + /* 页面本身不滚动,滚动条只出现在侧边栏与正文区 */ + display: flex; + flex-direction: column; + height: 100%; + overflow: hidden; } a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; } .topbar { - position: sticky; - top: 0; + position: relative; z-index: 10; + flex: 0 0 auto; display: flex; align-items: center; gap: 16px; @@ -409,14 +416,21 @@ a:hover { text-decoration: underline; } .layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); + grid-template-rows: minmax(0, 1fr); + flex: 1 1 auto; max-width: 1440px; + width: 100%; margin: 0 auto; - min-height: calc(100vh - 56px - 60px); + min-height: 0; + overflow: hidden; } .sidebar { padding: 24px 16px 40px; background: var(--side-bg); border-right: 1px solid var(--border); + min-height: 0; + overflow-y: auto; + overscroll-behavior: contain; } .side-head { font-size: 12px; @@ -445,7 +459,13 @@ a:hover { text-decoration: underline; } .side-link.is-active { background: var(--brand); color: #fff; } .side-empty { color: var(--text-muted); font-size: 13px; padding: 0 6px; } -.content { padding: 32px 40px 64px; min-width: 0; } +.content { + padding: 32px 40px 64px; + min-width: 0; + min-height: 0; + overflow-y: auto; + overscroll-behavior: contain; +} .doc { max-width: 820px; } .doc-head h1 { font-size: 30px; line-height: 1.35; margin: 0 0 8px; } .doc-summary { margin: 0 0 6px; color: var(--text-muted); } @@ -498,11 +518,21 @@ a:hover { text-decoration: underline; } .doc-toc .lv-3 { padding-left: 14px; } .doc-toc .lv-4 { padding-left: 28px; } +.doc-foot { + max-width: 820px; + margin: 32px 0 0; + padding-top: 16px; + border-top: 1px solid var(--border); + font-size: 12.5px; + color: #94a3b8; +} + .empty { max-width: 720px; } .empty h1 { font-size: 26px; } .empty p { color: var(--text-muted); } .footer { + flex: 0 0 auto; border-top: 1px solid var(--border); padding: 20px; text-align: center; @@ -511,11 +541,28 @@ a:hover { text-decoration: underline; } } @media (max-width: 900px) { - .layout { grid-template-columns: 1fr; } - .sidebar { border-right: 0; border-bottom: 1px solid var(--border); } + .layout { + grid-template-columns: minmax(0, 1fr); + grid-template-rows: minmax(0, auto) minmax(0, 1fr); + } + .sidebar { + max-height: 40vh; + border-right: 0; + border-bottom: 1px solid var(--border); + padding: 16px 16px 20px; + } .content { padding: 24px 20px 48px; } .doc-head h1 { font-size: 24px; } } + +/* 打印时恢复自然文档流,避免长文被固定高度裁掉 */ +@media print { + html, body { height: auto; overflow: visible; } + body { display: block; } + .topbar { position: static; } + .layout { display: block; overflow: visible; min-height: 0; } + .sidebar, .content { overflow: visible; max-height: none; height: auto; } +} `; } }