feat(moderation): 帖评删除占位感知与硬删清场
管理删帖须填类型与理由并展示专用页;评论软删占位、版主可硬删不占楼。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -34,6 +34,7 @@ import { formatRelative } from "@/lib/format";
|
||||
import { toast } from "@/lib/toast";
|
||||
import Avatar from "@/components/Avatar";
|
||||
import ConfirmDialog from "@/components/ConfirmDialog";
|
||||
import StaffDeletePostModal from "@/components/StaffDeletePostModal";
|
||||
|
||||
const PAGE_SIZE = 15;
|
||||
|
||||
@@ -139,6 +140,8 @@ export default function ContentAdmin({
|
||||
run: () => Promise<void>;
|
||||
} | null>(null);
|
||||
const [confirmBusy, setConfirmBusy] = useState(false);
|
||||
const [staffDeletePost, setStaffDeletePost] = useState<AdminContentPost | null>(null);
|
||||
const [staffDeleteBusy, setStaffDeleteBusy] = useState(false);
|
||||
|
||||
const refreshCounts = useCallback(() => {
|
||||
apiAdminContentCounts().then(setCounts).catch(() => {});
|
||||
@@ -515,18 +518,7 @@ export default function ContentAdmin({
|
||||
type="button"
|
||||
className="btn btn-line btn-sm"
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
askConfirm(
|
||||
"移入回收站",
|
||||
`确定软删帖子「${p.title}」吗?可稍后在「已删除」中恢复。`,
|
||||
() =>
|
||||
apiAdminSoftDeletePost(p.id).then(() => {
|
||||
toast("已移入回收站", "ok");
|
||||
reload(postsPage);
|
||||
}),
|
||||
true
|
||||
)
|
||||
}
|
||||
onClick={() => setStaffDeletePost(p)}
|
||||
>
|
||||
<Trash2 size={14} /> 删除
|
||||
</button>
|
||||
@@ -691,6 +683,25 @@ export default function ContentAdmin({
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<StaffDeletePostModal
|
||||
open={!!staffDeletePost}
|
||||
title={staffDeletePost?.title}
|
||||
busy={staffDeleteBusy}
|
||||
onClose={() => !staffDeleteBusy && setStaffDeletePost(null)}
|
||||
onConfirm={(opts) => {
|
||||
if (!staffDeletePost) return;
|
||||
setStaffDeleteBusy(true);
|
||||
apiAdminSoftDeletePost(staffDeletePost.id, opts)
|
||||
.then(() => {
|
||||
toast("已移入回收站", "ok");
|
||||
setStaffDeletePost(null);
|
||||
reload(postsPage);
|
||||
})
|
||||
.catch((e) => toast(e instanceof Error ? e.message : "操作失败"))
|
||||
.finally(() => setStaffDeleteBusy(false));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user