后台管理页面初版
This commit is contained in:
@@ -38,6 +38,26 @@
|
||||
</a-button>
|
||||
</a-card>
|
||||
</div>
|
||||
<div class="permissions-section" v-if="userPermissions.length > 0">
|
||||
<a-card :bordered="false" class="permissions-card">
|
||||
<template #title>
|
||||
<div class="card-title">
|
||||
<SafetyCertificateOutlined class="title-icon" />
|
||||
<span>我的权限</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="permissions-content">
|
||||
<div v-for="(group, groupName) in groupedPermissions" :key="groupName" class="permission-group">
|
||||
<div class="group-title">{{ groupName }}</div>
|
||||
<div class="permission-tags">
|
||||
<a-tag v-for="permission in group" :key="permission.id" color="blue" class="permission-tag">
|
||||
{{ permission.permissionName }}
|
||||
</a-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-card>
|
||||
</div>
|
||||
<div class="stats-section">
|
||||
<a-card :bordered="false" class="stats-card">
|
||||
<a-row :gutter="16">
|
||||
@@ -136,7 +156,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
SettingOutlined,
|
||||
@@ -147,13 +167,15 @@ import {
|
||||
CreditCardOutlined,
|
||||
BellOutlined,
|
||||
QuestionCircleOutlined,
|
||||
ShopOutlined
|
||||
ShopOutlined,
|
||||
SafetyCertificateOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import type { UploadProps } from 'ant-design-vue'
|
||||
import { authApi } from '@/api/auth'
|
||||
import { userApi, type UserVO } from '@/api/user'
|
||||
import { fileApi } from '@/api/file'
|
||||
import { permissionApi, type PermissionVO } from '@/api/permission'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -166,7 +188,21 @@ const userInfo = ref<UserVO>({
|
||||
updateTime: ''
|
||||
})
|
||||
|
||||
const userPermissions = ref<PermissionVO[]>([])
|
||||
|
||||
const hasNotification = ref(true)
|
||||
|
||||
const groupedPermissions = computed(() => {
|
||||
const groups: Record<string, PermissionVO[]> = {}
|
||||
userPermissions.value.forEach(permission => {
|
||||
if (!groups[permission.permissionGroup]) {
|
||||
groups[permission.permissionGroup] = []
|
||||
}
|
||||
groups[permission.permissionGroup].push(permission)
|
||||
})
|
||||
return groups
|
||||
})
|
||||
|
||||
const editModalVisible = ref(false)
|
||||
const saving = ref(false)
|
||||
const uploading = ref(false)
|
||||
@@ -230,6 +266,18 @@ const fetchUserInfo = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchUserPermissions = async () => {
|
||||
try {
|
||||
console.log('开始获取用户权限...')
|
||||
const res = await permissionApi.getUserPermissions()
|
||||
console.log('获取到的用户权限:', res)
|
||||
userPermissions.value = res as unknown as PermissionVO[]
|
||||
console.log('设置后的 userPermissions:', userPermissions.value)
|
||||
} catch (error) {
|
||||
console.error('获取用户权限失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const handleEditProfile = () => {
|
||||
editForm.value = {
|
||||
nickname: userInfo.value.nickname || '',
|
||||
@@ -355,6 +403,7 @@ const handleSettingsClick = () => {
|
||||
|
||||
onMounted(() => {
|
||||
fetchUserInfo()
|
||||
fetchUserPermissions()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -411,6 +460,73 @@ onMounted(() => {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.permissions-section {
|
||||
padding: 0 15px 15px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.permissions-card {
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.permissions-card :deep(.ant-card-head) {
|
||||
border-bottom: none;
|
||||
padding: 16px 20px 12px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1a1a2e;
|
||||
}
|
||||
|
||||
.title-icon {
|
||||
font-size: 20px;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.permissions-card :deep(.ant-card-body) {
|
||||
padding: 0 20px 20px;
|
||||
}
|
||||
|
||||
.permissions-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.permission-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #667eea;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.permission-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.permission-tag {
|
||||
font-size: 13px;
|
||||
padding: 4px 12px;
|
||||
border-radius: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
@@ -629,6 +745,8 @@ onMounted(() => {
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
color: white;
|
||||
opacity: 1;
|
||||
filter: none;
|
||||
}
|
||||
|
||||
.menu-item :deep(.ant-list-item-meta-title) {
|
||||
@@ -652,10 +770,12 @@ onMounted(() => {
|
||||
.logout-section :deep(.ant-btn-dangerous) {
|
||||
height: 50px;
|
||||
border-radius: 25px;
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
font-size: 17px;
|
||||
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
|
||||
border: none;
|
||||
box-shadow: 0 4px 15px rgba(238, 90, 111, 0.3);
|
||||
color: white !important;
|
||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user