feat: 书库导入导出/图片变体/书籍搜索/小组件运行时等
新增: - 书库导入导出(library_import/library_export)及测试 - 图片变体生成(image_variants)与响应式图片(responsiveImage) - 书籍搜索(bookSearch)+ BookSearch/LibrarySearchGrid 组件 - 小组件运行时(widgetRuntime)与静态检查(widgetLint) - 上传缓存中间件(upload_cache)与字体 CSS 提取脚本 其它: - 后端 handlers/services 全量调整 - 前端页面、组件、库函数与配置更新
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
MessageCircle,
|
||||
Flame,
|
||||
ChevronRight,
|
||||
Pin,
|
||||
Star,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
fetchPostDetail,
|
||||
@@ -358,22 +360,31 @@ export default async function PostDetailPage({ params, searchParams }: PageProps
|
||||
absoluteCanonical(postPath(urlStyle, post.id), commentPage > 1 ? { page: commentPage } : undefined) ||
|
||||
entityUrl;
|
||||
const authorName = post.user.nickname || post.user.username;
|
||||
// 楼层号 = 跨页连续的主评论序号(含被过滤掉的软删/空占位),故按未过滤索引计算
|
||||
const visibleFloors: JsonLdVisibleComment[] = canFetchComments
|
||||
? comments
|
||||
.filter((c) => !c.deleted && (c.content || "").trim())
|
||||
.map((c) => ({
|
||||
id: c.id,
|
||||
content: c.content,
|
||||
created_at: c.created_at,
|
||||
author: c.user
|
||||
? { id: c.user.id, name: c.user.nickname || c.user.username }
|
||||
: undefined,
|
||||
}))
|
||||
.map((c, i): JsonLdVisibleComment | null =>
|
||||
!c.deleted && (c.content || "").trim()
|
||||
? {
|
||||
id: c.id,
|
||||
floor: (commentPage - 1) * 20 + i + 1,
|
||||
is_root: true,
|
||||
content: c.content,
|
||||
created_at: c.created_at,
|
||||
author: c.user
|
||||
? { id: c.user.id, name: c.user.nickname || c.user.username }
|
||||
: undefined,
|
||||
}
|
||||
: null
|
||||
)
|
||||
.filter((x): x is JsonLdVisibleComment => x !== null)
|
||||
: [];
|
||||
const acceptedForLd: JsonLdVisibleComment | null =
|
||||
canFetchComments && acceptedAnswer && !acceptedAnswer.deleted && acceptedAnswer.content?.trim()
|
||||
? {
|
||||
id: acceptedAnswer.id,
|
||||
floor: acceptedAnswer.floor,
|
||||
is_root: acceptedAnswer.is_root,
|
||||
content: acceptedAnswer.content,
|
||||
created_at: acceptedAnswer.created_at,
|
||||
author: acceptedAnswer.user
|
||||
@@ -475,15 +486,27 @@ export default async function PostDetailPage({ params, searchParams }: PageProps
|
||||
<div className="panel p-4 sm:p-6 lg:p-8 max-sm:-mx-4 max-sm:rounded-none max-sm:border-x-0 max-sm:shadow-none">
|
||||
<header className="mb-5 sm:mb-7">
|
||||
<div className="flex items-start gap-2 flex-wrap mb-6">
|
||||
{/* 仅置顶/推荐在标题左侧 */}
|
||||
{post.pinned > 0 && <span className="badge-pin shrink-0 mt-2 sm:mt-3">置顶</span>}
|
||||
{post.recommended && <span className="badge-rec shrink-0 mt-2 sm:mt-3">推荐</span>}
|
||||
<h1
|
||||
className="text-[26px] sm:text-[34px] font-extrabold leading-tight tracking-tight min-w-0"
|
||||
style={{ color: "var(--ink)" }}
|
||||
>
|
||||
{post.title}
|
||||
</h1>
|
||||
{/* 置顶/推荐与标题包在同一不可折行的 flex item 内:外层 flex-wrap 收集行时只看
|
||||
已在行内元素的收缩能力,shrink-0 徽章会让超长 h1 整体掉到第二行;内层 min-w-0
|
||||
使 h1 在徽章旁的剩余空间内折行,徽章始终与标题首行同行(移动端) */}
|
||||
<div className="flex items-start gap-2 min-w-0">
|
||||
{post.pinned > 0 && (
|
||||
<span className="badge-pin shrink-0 mt-2 sm:mt-3" title="置顶" aria-label="置顶">
|
||||
<Pin size={13} fill="currentColor" strokeWidth={2.2} aria-hidden />
|
||||
</span>
|
||||
)}
|
||||
{post.recommended && (
|
||||
<span className="badge-rec shrink-0 mt-2 sm:mt-3" title="推荐" aria-label="推荐">
|
||||
<Star size={13} fill="currentColor" strokeWidth={2.2} aria-hidden />
|
||||
</span>
|
||||
)}
|
||||
<h1
|
||||
className="text-[26px] sm:text-[34px] font-extrabold leading-tight tracking-tight min-w-0"
|
||||
style={{ color: "var(--ink)" }}
|
||||
>
|
||||
{post.title}
|
||||
</h1>
|
||||
</div>
|
||||
{/* 其余徽章紧跟标题右侧;问答不显示类型徽章 */}
|
||||
{postType !== "discussion" && postType !== "question" && (
|
||||
<span className="badge-type shrink-0 mt-2 sm:mt-3">{postTypeLabel(postType)}</span>
|
||||
|
||||
Reference in New Issue
Block a user