ariaLabel="状态筛选"
size="sm"
value={status}
onChange={switchStatus}
options={STATUS_TABS.map((t) => ({
key: t.key,
label: t.label,
count: statusCount(t.key) ?? undefined,
}))}
/>
{error ?
{error}
: null}
{kind === "posts" && posts.length === 0 ? (
} title={empty.title} description={empty.description} />
) : kind === "comments" && comments.length === 0 ? (
} title={empty.title} description={empty.description} />
) : kind === "posts" ? (
posts.map((p, idx) => {
const key = `p-${p.id}`;
const busy = actingKey === key;
const chip = contentStatusChip(p.status, p.deleted);
const pending = isPendingRow(p.status, p.deleted);
return (
{chip.label}
{p.board?.name}
{formatRelative(p.created_at)}
{p.deleted ? (
{p.title}
) : (
{p.title}
)}
{p.user?.nickname} · {p.comment_count} 评
{pending && (
runAction(key, () => apiAdminApprovePost(p.id), "已通过审核,内容已公开")
}
onReject={() => askReject("posts", p.id)}
/>
)}
{p.deleted ? (
<>
runAction(key, () => apiAdminRestorePost(p.id), "帖子已恢复")
}
>
{busy ? (
) : (
)}
askConfirm(
"彻底删除帖子",
`「${p.title}」将从数据库永久删除,且其下评论一并清除,不可撤销。`,
() =>
apiAdminPurgePost(p.id).then(() => {
toast("帖子已彻底删除", "ok");
reloadAfterItemChange();
}),
true
)
}
>
>
) : (
setStaffDeletePost(p)}
>
)}
);
})
) : (
comments.map((c, idx) => {
const key = `c-${c.id}`;
const busy = actingKey === key;
const chip = contentStatusChip(c.status, c.deleted);
const pending = isPendingRow(c.status, c.deleted);
return (
{chip.label}
{c.board?.name}
{formatRelative(c.created_at)}
{excerpt(c.content)}
{c.user?.nickname} ·{" "}
{c.deleted ? (
c.post_title
) : (
{c.post_title || `帖子 #${c.post_id}`}
)}
{pending && (
runAction(key, () => apiAdminApproveComment(c.id), "已通过审核,内容已公开")
}
onReject={() => askReject("comments", c.id)}
/>
)}
setHistoryCommentId(c.id)}
>
{c.deleted ? (
<>
runAction(key, () => apiAdminRestoreComment(c.id), "评论已恢复")
}
>
{busy ? (
) : (
)}
askConfirm(
"彻底删除评论",
"该评论将永久删除且不可恢复。",
() =>
apiAdminPurgeComment(c.id).then(() => {
toast("评论已彻底删除", "ok");
reloadAfterItemChange();
}),
true
)
}
>
>
) : (
setStaffDeleteComment(c)}
>
)}
);
})
)}