import Link from "next/link"; import { CheckCircle2, CircleHelp, Coins } from "lucide-react"; import type { AcceptedAnswer } from "@/lib/api"; import Avatar from "@/components/Avatar"; import MarkdownBody from "@/components/MarkdownBody"; /** 正文下方已采纳答案:对齐类型帖 typed-card;已采纳后不可重新打开 */ export default async function AcceptedAnswerCard({ answer, variant = "question", solvedAt, }: { answer: AcceptedAnswer; /** 问答用「最佳答案」,悬赏用「已采纳」 */ variant?: "question" | "bounty"; /** 解决/采纳时刻;缺省用答案创建时间 */ solvedAt?: string; }) { const name = answer.user.nickname || answer.user.username || "用户"; const isQuestion = variant === "question"; const title = isQuestion ? "问答" : "悬赏"; const statusLabel = isQuestion ? "已解决" : "已采纳"; const answerLabel = isQuestion ? "最佳答案" : "采纳答案"; const endTime = solvedAt || answer.created_at; const endLabel = formatEndsAt(endTime); return (

{isQuestion ? ( ) : ( )} {title}

{statusLabel}
{answerLabel}
{name}

{answer.floor > 0 && ( <> · #{answer.floor} )}

{answer.deleted ? (

该答案已被删除

) : ( )}
{isQuestion ? "已采纳答案" : "悬赏已发放"} {endLabel ? ( 结束时间: {endLabel} ) : null}
); } function formatEndsAt(iso?: string) { if (!iso) return ""; try { return new Date(iso).toLocaleString("zh-CN"); } catch { return iso; } }