feat: add quote post selection state and preview card

This commit is contained in:
zetaloop
2026-02-20 23:06:05 +08:00
parent 7e632ce092
commit 505ae9d683
+21 -1
View File
@@ -109,7 +109,7 @@ export default function NewPostPage() {
{postType === "quote" && (
<div className="space-y-2">
<Label></Label>
<Select>
<Select value={selectedQuotePostId} onValueChange={setSelectedQuotePostId}>
<SelectTrigger>
<SelectValue placeholder="选择要引用的帖子" />
</SelectTrigger>
@@ -123,7 +123,27 @@ export default function NewPostPage() {
</Select>
<div className="mt-2 rounded-md border bg-muted/50 p-3 text-sm text-muted-foreground">
<p className="font-medium text-foreground"></p>
{selectedQuotePostId ? (
(() => {
const post = mockPosts.find((p) => p.id === selectedQuotePostId)
if (!post) return <p className="mt-1"></p>
return (
<div className="mt-2 rounded border bg-background p-3">
<p className="font-medium text-foreground">{post.title}</p>
<p className="mt-1 line-clamp-2 text-xs text-muted-foreground">
{post.content}
</p>
<div className="mt-2 flex items-center gap-2 text-xs text-muted-foreground">
<span>@{post.author.nickname}</span>
<span>·</span>
<span>{new Date(post.createdAt).toLocaleDateString("zh-CN")}</span>
</div>
</div>
)
})()
) : (
<p className="mt-1">...</p>
)}
</div>
</div>
)}