feat(comments): 软删占位、理由与恢复,管理删仅对访客打码
自删/管理删差异文案与理由可见性,评论者与管理员免马赛克,并支持恢复与处理人链接。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -35,6 +35,7 @@ import { toast } from "@/lib/toast";
|
||||
import Avatar from "@/components/Avatar";
|
||||
import ConfirmDialog from "@/components/ConfirmDialog";
|
||||
import StaffDeletePostModal from "@/components/StaffDeletePostModal";
|
||||
import DeleteCommentModal from "@/components/DeleteCommentModal";
|
||||
|
||||
const PAGE_SIZE = 15;
|
||||
|
||||
@@ -142,6 +143,8 @@ export default function ContentAdmin({
|
||||
const [confirmBusy, setConfirmBusy] = useState(false);
|
||||
const [staffDeletePost, setStaffDeletePost] = useState<AdminContentPost | null>(null);
|
||||
const [staffDeleteBusy, setStaffDeleteBusy] = useState(false);
|
||||
const [staffDeleteComment, setStaffDeleteComment] = useState<AdminContentComment | null>(null);
|
||||
const [staffDeleteCommentBusy, setStaffDeleteCommentBusy] = useState(false);
|
||||
|
||||
const refreshCounts = useCallback(() => {
|
||||
apiAdminContentCounts().then(setCounts).catch(() => {});
|
||||
@@ -605,18 +608,7 @@ export default function ContentAdmin({
|
||||
type="button"
|
||||
className="btn btn-line btn-sm"
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
askConfirm(
|
||||
"移入回收站",
|
||||
"确定软删这条评论吗?可在「已删除」中恢复。",
|
||||
() =>
|
||||
apiAdminSoftDeleteComment(c.id).then(() => {
|
||||
toast("已移入回收站", "ok");
|
||||
reload(commentsPage);
|
||||
}),
|
||||
true
|
||||
)
|
||||
}
|
||||
onClick={() => setStaffDeleteComment(c)}
|
||||
>
|
||||
<Trash2 size={14} /> 删除
|
||||
</button>
|
||||
@@ -702,6 +694,25 @@ export default function ContentAdmin({
|
||||
.finally(() => setStaffDeleteBusy(false));
|
||||
}}
|
||||
/>
|
||||
|
||||
<DeleteCommentModal
|
||||
open={!!staffDeleteComment}
|
||||
mode="staff"
|
||||
busy={staffDeleteCommentBusy}
|
||||
onClose={() => !staffDeleteCommentBusy && setStaffDeleteComment(null)}
|
||||
onConfirm={(opts) => {
|
||||
if (!staffDeleteComment) return;
|
||||
setStaffDeleteCommentBusy(true);
|
||||
apiAdminSoftDeleteComment(staffDeleteComment.id, opts)
|
||||
.then(() => {
|
||||
toast("已移入回收站", "ok");
|
||||
setStaffDeleteComment(null);
|
||||
reload(commentsPage);
|
||||
})
|
||||
.catch((e) => toast(e instanceof Error ? e.message : "操作失败"))
|
||||
.finally(() => setStaffDeleteCommentBusy(false));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user