更新 AdminLayout 以显示当前用户的用户名,并引入获取用户信息的功能
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
<div class="spacer" />
|
||||
<el-dropdown>
|
||||
<span class="el-dropdown-link">
|
||||
管理员<i class="el-icon el-icon--right"><svg width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M7 10l5 5 5-5z"/></svg></i>
|
||||
{{ currentUser?.username || '用户' }}<i class="el-icon el-icon--right"><svg width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M7 10l5 5 5-5z"/></svg></i>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
@@ -78,11 +78,14 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { clearTokens } from '@/utils/auth'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { canAccessRoute } from '@/utils/permission'
|
||||
import { canAccessRoute, getCurrentUser } from '@/utils/permission'
|
||||
|
||||
const collapsed = ref(false)
|
||||
const router = useRouter()
|
||||
|
||||
// 获取当前用户信息
|
||||
const currentUser = computed(() => getCurrentUser())
|
||||
|
||||
// 权限检查
|
||||
const canAccessUsers = computed(() => canAccessRoute('Users'))
|
||||
const canAccessGames = computed(() => canAccessRoute('Games'))
|
||||
|
||||
Reference in New Issue
Block a user