Merge pull request #205 from Aqr-K/dev-login

This commit is contained in:
jxxghp
2024-10-22 12:31:17 +08:00
committed by GitHub
3 changed files with 36 additions and 22 deletions

View File

@@ -21,8 +21,11 @@ const props = defineProps({
},
})
// 当前用户名称
const currentLoginUser = store.state.auth.userName
// 当前用户的ID
const currentLoginUserId = computed(() => store.state.auth.userID)
// 当前用户是否是管理员
const currentUserIsSuperuser = computed(() => store.state.auth.superUser)
// 定义触发的自定义事件
const emit = defineEmits(['remove', 'save'])
@@ -57,7 +60,7 @@ async function fetchSubscriptions() {
// 删除用户
async function removeUser() {
if (props.user.name == currentLoginUser) {
if (props.user.id === currentLoginUserId.value) {
$toast.error('不能删除当前登录用户!')
return
}
@@ -84,19 +87,6 @@ function editUser() {
userEditDialog.value = true
}
// 计算是否有用户编辑权限
const canEditUser = computed(() => {
if (store.state.auth.superUser && props.user.name !== currentLoginUser) return true
return false
})
// 计算是否有用户管理权限
const canManageUser = computed(() => {
if (props.user.name == currentLoginUser) return false
if (store.state.auth.superUser) return true
return false
})
// 用户重新完成时
function onUserUpdate() {
userEditDialog.value = false
@@ -139,8 +129,9 @@ onMounted(() => {
</div>
</VCardText>
<VCardText class="pb-6">
<h5 class="text-h6">详情</h5>
<VDivider class="my-2" />
<VDivider class="my-2">
<h5 class="text-h6">详情</h5>
</VDivider>
<VList lines="one">
<VListItem>
<VListItemTitle class="text-sm">
@@ -170,8 +161,22 @@ onMounted(() => {
</VList>
</VCardText>
<VCardText class="flex flex-row justify-center">
<VBtn v-if="canEditUser" color="primary" class="me-4" @click="editUser">编辑</VBtn>
<VBtn v-if="canManageUser" color="error" variant="outlined" @click="removeUser"> 删除 </VBtn>
<VBtn
v-if="currentUserIsSuperuser"
color="primary"
class="me-4"
@click="editUser"
>
编辑
</VBtn>
<VBtn
v-if="currentUserIsSuperuser && props.user.id != currentLoginUserId"
color="error"
variant="outlined"
@click="removeUser"
>
删除
</VBtn>
</VCardText>
</VCard>
<!-- 用户编辑弹窗 -->