feat(frontend): allow admins to delete posts and comments

This commit is contained in:
Tim
2025-07-14 00:41:50 +08:00
parent 2327c530f2
commit f71baaf217
2 changed files with 3 additions and 2 deletions

View File

@@ -103,8 +103,9 @@ const CommentItem = {
showEditor.value = !showEditor.value
}
const isAuthor = computed(() => authState.username === props.comment.userName)
const isAdmin = computed(() => authState.role === 'ADMIN')
const commentMenuItems = computed(() =>
isAuthor.value ? [{ text: '删除评论', color: 'red', onClick: () => deleteComment() }] : []
(isAuthor.value || isAdmin.value) ? [{ text: '删除评论', color: 'red', onClick: () => deleteComment() }] : []
)
const deleteComment = async () => {
const token = getToken()