From f71baaf2177f62d6a4c3c98aed9991ad196f5cac Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Mon, 14 Jul 2025 00:41:50 +0800 Subject: [PATCH] feat(frontend): allow admins to delete posts and comments --- open-isle-cli/src/components/CommentItem.vue | 3 ++- open-isle-cli/src/views/PostPageView.vue | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/open-isle-cli/src/components/CommentItem.vue b/open-isle-cli/src/components/CommentItem.vue index edf3e380e..d32de6679 100644 --- a/open-isle-cli/src/components/CommentItem.vue +++ b/open-isle-cli/src/components/CommentItem.vue @@ -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() diff --git a/open-isle-cli/src/views/PostPageView.vue b/open-isle-cli/src/views/PostPageView.vue index 950ee57c0..4e575914b 100644 --- a/open-isle-cli/src/views/PostPageView.vue +++ b/open-isle-cli/src/views/PostPageView.vue @@ -140,7 +140,7 @@ export default { const isAuthor = computed(() => authState.username === author.value.username) const articleMenuItems = computed(() => { const items = [] - if (isAuthor.value) { + if (isAuthor.value || isAdmin.value) { items.push({ text: '删除文章', color: 'red', onClick: () => deletePost() }) } if (isAdmin.value && status.value === 'PENDING') {