feat(posts): 类型特殊块移至正文下,采纳答案卡与中奖楼层按评论标记
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,23 +21,21 @@ import Avatar from "@/components/Avatar";
|
||||
|
||||
export default function PostInteractPanels({
|
||||
postId,
|
||||
question,
|
||||
poll,
|
||||
bounty,
|
||||
lottery,
|
||||
loggedIn,
|
||||
}: {
|
||||
postId: number;
|
||||
question?: QuestionState | null;
|
||||
poll?: PollState | null;
|
||||
bounty?: BountyState | null;
|
||||
lottery?: LotteryState | null;
|
||||
loggedIn: boolean;
|
||||
}) {
|
||||
if (!question && !poll && !bounty && !lottery) return null;
|
||||
// 问答状态改在正文下方展示(未解决 / 已解决资料卡),此处不再放
|
||||
if (!poll && !bounty && !lottery) return null;
|
||||
return (
|
||||
<div className="space-y-4 mb-8">
|
||||
{question && <QuestionPanel postId={postId} state={question} />}
|
||||
<div className="j13-interact-below space-y-4">
|
||||
{poll && <PollPanel postId={postId} state={poll} loggedIn={loggedIn} />}
|
||||
{bounty && <BountyPanel postId={postId} state={bounty} />}
|
||||
{lottery && <LotteryPanel postId={postId} state={lottery} />}
|
||||
@@ -54,7 +52,8 @@ function formatEndsAt(iso?: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function QuestionPanel({ postId, state }: { postId: number; state: QuestionState }) {
|
||||
/** 正文下方的问答状态卡(未解决 / 仅标记已解决);有采纳答案时改用 AcceptedAnswerCard */
|
||||
export function QuestionStatusCard({ postId, state }: { postId: number; state: QuestionState }) {
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
@@ -72,7 +71,10 @@ function QuestionPanel({ postId, state }: { postId: number; state: QuestionState
|
||||
};
|
||||
|
||||
return (
|
||||
<section className={`j13-interact-card${state.solved ? " is-solved" : " is-unsolved"}`}>
|
||||
<section
|
||||
className={`j13-interact-card j13-question-below${state.solved ? " is-solved" : " is-unsolved"}`}
|
||||
aria-label={`问答 · ${state.solved ? "已解决" : "未解决"}`}
|
||||
>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-[15px] font-medium" style={{ color: "var(--ink)" }}>
|
||||
@@ -319,20 +321,22 @@ function BountyPanel({ postId, state }: { postId: number; state: BountyState })
|
||||
悬赏 {state.points} 积分
|
||||
</h2>
|
||||
<p className="meta text-[12.5px] mt-1">
|
||||
{state.accepted_comment_id ? (
|
||||
<>
|
||||
已采纳{" "}
|
||||
<a
|
||||
href={`#comment-${state.accepted_comment_id}`}
|
||||
className="hover:underline"
|
||||
style={{ color: "var(--accent)" }}
|
||||
>
|
||||
#{state.accepted_floor || "?"}
|
||||
</a>
|
||||
</>
|
||||
) : (
|
||||
statusText
|
||||
)}
|
||||
{state.accepted_answer
|
||||
? "悬赏积分已发放给采纳答案"
|
||||
: state.accepted_comment_id
|
||||
? (
|
||||
<>
|
||||
已采纳{" "}
|
||||
<a
|
||||
href={`#comment-${state.accepted_comment_id}`}
|
||||
className="hover:underline"
|
||||
style={{ color: "var(--accent)" }}
|
||||
>
|
||||
#{state.accepted_floor || "?"}
|
||||
</a>
|
||||
</>
|
||||
)
|
||||
: statusText}
|
||||
{state.ends_at && !state.settled ? ` · 截止 ${formatEndsAt(state.ends_at)}` : ""}
|
||||
</p>
|
||||
</div>
|
||||
@@ -426,13 +430,20 @@ function LotteryPanel({
|
||||
<ul className="flex flex-wrap gap-3">
|
||||
{state.winners.map((w) => (
|
||||
<li key={w.id}>
|
||||
<Link
|
||||
href={`/u/${w.id}`}
|
||||
className="badge-winner inline-flex items-center gap-2 !py-1.5 !px-2.5 !text-[13px] !font-medium"
|
||||
>
|
||||
<Avatar name={w.nickname || w.username} src={w.avatar || undefined} size={22} />
|
||||
<span>{w.nickname || w.username}</span>
|
||||
</Link>
|
||||
<span className="badge-winner inline-flex items-center gap-2 !py-1.5 !px-2.5 !text-[13px] !font-medium">
|
||||
<Link href={`/u/${w.id}`} className="inline-flex items-center gap-2 min-w-0">
|
||||
<Avatar name={w.nickname || w.username} src={w.avatar || undefined} size={22} />
|
||||
<span className="truncate">{w.nickname || w.username}</span>
|
||||
</Link>
|
||||
{w.comment_id && w.floor ? (
|
||||
<a
|
||||
href={`#comment-${w.comment_id}`}
|
||||
className="opacity-90 hover:underline shrink-0"
|
||||
>
|
||||
#{w.floor}
|
||||
</a>
|
||||
) : null}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user