From 23771f0661ff6086b2504d37444d505ec2fe6aa0 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Tue, 29 Sep 2026 00:53:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E6=8E=92=E7=89=88=E5=9B=9B?= =?UTF-8?q?=E4=BB=B6=E5=A5=97=EF=BC=88=E5=8F=82=E8=80=83=20xLog=EF=BC=89?= =?UTF-8?q?=EF=BC=9A=E7=9B=98=E5=8F=A4=E4=B9=8B=E7=99=BD=20+=20=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E5=9C=86=E8=A7=92=E6=96=91=E9=A9=AC=E7=BA=B9=20+=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9D=97=E5=B0=81=E9=A1=B6=E4=B8=8E=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E6=8C=89=E9=92=AE=20+=20=E6=A0=87=E9=A2=98=E6=82=AC?= =?UTF-8?q?=E5=81=9C=E9=94=9A=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PanguHTML:CJK 与拉丁/数字间补空格,标签原样保留、code/pre 内文本不动;详情/时间线短文/RSS 描述三个出口生效(带单测) - 表格改圆角容器 + tbody 斑马纹 + 纵向大留白(classic/vivid 双主题) - pre max-height 30.5em 封顶内部滚动;enhanceProse 注入悬停复制按钮(App 全局委托),按下有 2px 物理感 - 带 id 的 h2-h4 悬停浮现 # 锚点,点击跳转 - 中文字体栈此前已配(PingFang SC 等),无需改动 --- backend/internal/api/api.go | 11 +++- backend/internal/render/pangu.go | 92 +++++++++++++++++++++++++++ backend/internal/render/pangu_test.go | 40 ++++++++++++ frontend/src/App.vue | 27 +++++++- frontend/src/styles.css | 57 ++++++++++++++--- frontend/src/ui/yohaku/article.css | 22 ++++++- frontend/src/utils.js | 22 ++++++- 7 files changed, 257 insertions(+), 14 deletions(-) create mode 100644 backend/internal/render/pangu.go create mode 100644 backend/internal/render/pangu_test.go diff --git a/backend/internal/api/api.go b/backend/internal/api/api.go index d19440b..0a4173b 100644 --- a/backend/internal/api/api.go +++ b/backend/internal/api/api.go @@ -18,6 +18,7 @@ import ( "oneblog/internal/hub" "oneblog/internal/model" "oneblog/internal/ratelimit" + "oneblog/internal/render" "oneblog/internal/storage" "oneblog/internal/store" "oneblog/internal/thumbs" @@ -128,6 +129,12 @@ func (a *API) listPosts(w http.ResponseWriter, r *http.Request) { httpx.ServerError(w, err) return } + // 时间线上短文直接铺正文:出口处做盘古之白(库里存的是原始渲染结果) + for i := range page.Items { + if page.Items[i].Kind == model.KindShort { + page.Items[i].ContentHTML = render.PanguHTML(page.Items[i].ContentHTML) + } + } httpx.OK(w, page) } @@ -156,6 +163,8 @@ func (a *API) getPost(w http.ResponseWriter, r *http.Request) { if err != nil { nb = nil } + // 详情正文出口做盘古之白(存库不动,改的是渲染层) + p.ContentHTML = render.PanguHTML(p.ContentHTML) httpx.OK(w, struct { model.Post Neighbors []model.Post `json:"neighbors"` @@ -255,7 +264,7 @@ func (a *API) RSS(w http.ResponseWriter, r *http.Request) { } desc := p.Summary if desc == "" { - desc = trimRunes(stripTags(p.ContentHTML), 160) + desc = trimRunes(stripTags(render.PanguHTML(p.ContentHTML)), 160) } item := rssItem{ Title: title, diff --git a/backend/internal/render/pangu.go b/backend/internal/render/pangu.go new file mode 100644 index 0000000..0f97a3d --- /dev/null +++ b/backend/internal/render/pangu.go @@ -0,0 +1,92 @@ +// 盘古之白:在 CJK 与拉丁字母/数字之间补一个空格,中文混排的阅读观感 +// 差别很大(「把MVP搬进仓库」→「把 MVP 搬进仓库」)。 +// 在 HTML 层做:标签原样保留,/
/