From 5fc636e574a090c3ec6cdaecbad03ebb8313dbd5 Mon Sep 17 00:00:00 2001
From: Sakurasan <26715255+Sakurasan@users.noreply.github.com>
Date: Fri, 2 Oct 2026 21:00:31 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BD=92=E6=A1=A3=E7=9F=AD=E6=96=87=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=E5=AF=B9=E9=BD=90=E3=80=8C=E6=9C=80=E8=BF=91=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E3=80=8D=EF=BC=9A=E5=89=A5=E9=93=BE=E6=8E=A5=E5=8F=96?=
=?UTF-8?q?=E6=AD=A3=E6=96=87=E6=91=98=E5=BD=95=EF=BC=8C=E5=85=9C=E5=BA=95?=
=?UTF-8?q?=E9=93=BE=E4=B8=8E=E4=BE=A7=E6=A0=8F=E4=B8=80=E8=87=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- classic 与 vivid 两套归档的短文摘录改用同一套规则:剥 后取正文
开头(贴链接的短文不再显示一长串 URL),剥完没字依次退到链接卡标题、
📷 图片、短文
- vivid 归档的类型徽标同步为单字(长 / 短)
---
frontend/src/ui/yohaku/YohakuArchive.vue | 17 ++++++++++++++---
frontend/src/views/ArchiveView.vue | 19 +++++++++++++++++--
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/frontend/src/ui/yohaku/YohakuArchive.vue b/frontend/src/ui/yohaku/YohakuArchive.vue
index 742f57e..6b525e3 100644
--- a/frontend/src/ui/yohaku/YohakuArchive.vue
+++ b/frontend/src/ui/yohaku/YohakuArchive.vue
@@ -2,20 +2,31 @@
import { RouterLink } from 'vue-router'
// 余白归档。对应设计稿 viewArchive():page-head + 年块(年 + 篇数)+ 月分组。
-// 短文没有标题,列表里用正文开头(后端对 short 返回全文 content_html,够用)。
+// 短文没有标题,列表里用正文开头当标识——与侧栏「最近更新」同一套摘录规则:
+// 先剥 (贴链接的短文开头是 URL 本身,没有信息量),剥完没字退到链接卡标题。
const props = defineProps({ years: { type: Array, default: () => [] } })
const fmt = new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' })
const fmtDate = (iso) => fmt.format(new Date(iso)).replace(/\//g, '-')
-const kindLabel = (k) => (k === 'long' ? '长文' : '短文')
+const kindLabel = (k) => (k === 'long' ? '长' : '短')
const plain = (html) => {
if (!html) return ''
const el = document.createElement('div')
el.innerHTML = html
return (el.textContent || '').trim()
}
-const titleOf = (p) => (p.kind === 'long' ? p.title : plain(p.content_html).slice(0, 48))
+const titleOf = (p) => {
+ if (p.kind === 'long') return p.title || '无题'
+ const noLinks = (p.content_html || '').replace(/]*>[\s\S]*?<\/a>/gi, ' ')
+ const text = plain(noLinks)
+ if (text) return text.length > 48 ? text.slice(0, 48) + '…' : text
+ if (p.link_card && p.link_card.title) {
+ const t = p.link_card.title
+ return t.length > 48 ? t.slice(0, 48) + '…' : t
+ }
+ return p.images && p.images.length ? '📷 图片' : '短文'
+}
diff --git a/frontend/src/views/ArchiveView.vue b/frontend/src/views/ArchiveView.vue
index 38c32ce..2742dcb 100644
--- a/frontend/src/views/ArchiveView.vue
+++ b/frontend/src/views/ArchiveView.vue
@@ -5,7 +5,7 @@ import RightRail from '../components/RightRail.vue'
import { publicApi } from '../api'
import YohakuArchive from '../ui/yohaku/YohakuArchive.vue'
import { applyDocTitle, site } from '../site'
-import { formatDateShort } from '../utils'
+import { formatDateShort, stripTags } from '../utils'
const years = ref([])
// vivid(余白)是另一套 DOM,数据来源不变,只在视图层分叉
@@ -29,6 +29,21 @@ const total = computed(() =>
years.value.reduce((n, y) => n + (y.count || 0), 0)
)
+// 短文摘录:与「最近更新」同一套规则——贴链接的短文开头是 URL 本身,
+// 先剥 ;剥完没字(纯链接贴)退到链接卡标题
+const EXCERPT_LEN = 48
+function excerpt(p) {
+ if (p.kind !== 'short') return p.title || '无题'
+ const noLinks = (p.content_html || '').replace(/]*>[\s\S]*?<\/a>/gi, ' ')
+ const text = stripTags(noLinks).replace(/\s+/g, ' ').trim()
+ if (text) return text.length > EXCERPT_LEN ? text.slice(0, EXCERPT_LEN) + '…' : text
+ if (p.link_card && p.link_card.title) {
+ const t = p.link_card.title
+ return t.length > EXCERPT_LEN ? t.slice(0, EXCERPT_LEN) + '…' : t
+ }
+ return p.images && p.images.length ? '📷 图片' : '短文'
+}
+
applyDocTitle('归档')
@@ -59,7 +74,7 @@ applyDocTitle('归档')
{{ formatDateShort(p.published_at).slice(5) }}
- {{ p.kind === 'short' ? '短文' : p.title || '无题' }}
+ {{ excerpt(p) }}
短