mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-27 00:20:48 +08:00
refactor(menu): show delete/approve options conditionally
This commit is contained in:
@@ -138,11 +138,17 @@ export default {
|
||||
const loggedIn = computed(() => authState.loggedIn)
|
||||
const isAdmin = computed(() => authState.role === 'ADMIN')
|
||||
const isAuthor = computed(() => authState.username === author.value.username)
|
||||
const articleMenuItems = [
|
||||
{ text: '删除文章', color: 'red', onClick: () => deletePost() },
|
||||
{ text: '通过审核', onClick: () => approvePost() },
|
||||
{ text: '驳回', color: 'red', onClick: () => rejectPost() }
|
||||
]
|
||||
const articleMenuItems = computed(() => {
|
||||
const items = []
|
||||
if (isAuthor.value) {
|
||||
items.push({ text: '删除文章', color: 'red', onClick: () => deletePost() })
|
||||
}
|
||||
if (isAdmin.value && status.value === 'PENDING') {
|
||||
items.push({ text: '通过审核', onClick: () => approvePost() })
|
||||
items.push({ text: '驳回', color: 'red', onClick: () => rejectPost() })
|
||||
}
|
||||
return items
|
||||
})
|
||||
|
||||
const gatherPostItems = () => {
|
||||
const items = []
|
||||
|
||||
Reference in New Issue
Block a user