增加权限系统

This commit is contained in:
yml2213
2026-05-27 05:41:59 +08:00
parent a04327fd05
commit 1458fc279c
29 changed files with 2276 additions and 46 deletions
+31 -12
View File
@@ -12,7 +12,9 @@ import {
SwitchButton,
Tickets,
User,
Wallet
UserFilled,
Wallet,
Setting
} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { computed, ref } from 'vue'
@@ -25,19 +27,36 @@ const router = useRouter()
const adminSession = useAdminSessionStore()
const isCollapsed = ref(false)
const navItems = [
{ label: '仪表盘', to: '/admin/dashboard', icon: DataLine },
{ label: '用户管理', to: '/admin/users', icon: User },
{ label: '订单管理', to: '/admin/orders', icon: Tickets },
{ label: '商品管理', to: '/admin/listings', icon: Shop },
{ label: '商品审核', to: '/admin/listings/review', icon: DocumentChecked },
{ label: '仲裁中心', to: '/admin/disputes', icon: ScaleToOriginal },
{ label: '客服群聊', to: '/admin/chats', icon: ChatDotRound },
{ label: '资金流水', to: '/admin/wallet-ledger', icon: Wallet },
{ label: '系统配置', to: '/admin/system-configs', icon: Operation },
{ label: '审计日志', to: '/admin/audit-logs', icon: Document },
interface NavItem {
label: string
to: string
icon: any
permission?: string
}
const allNavItems: NavItem[] = [
{ label: '仪表盘', to: '/admin/dashboard', icon: DataLine, permission: 'dashboard:view' },
{ label: '用户管理', to: '/admin/users', icon: User, permission: 'user:view' },
{ label: '订单管理', to: '/admin/orders', icon: Tickets, permission: 'order:view' },
{ label: '商品管理', to: '/admin/listings', icon: Shop, permission: 'listing:view' },
{ label: '商品审核', to: '/admin/listings/review', icon: DocumentChecked, permission: 'listing:approve' },
{ label: '仲裁中心', to: '/admin/disputes', icon: ScaleToOriginal, permission: 'dispute:view' },
{ label: '客服群聊', to: '/admin/chats', icon: ChatDotRound, permission: 'chat:view' },
{ label: '资金流水', to: '/admin/wallet-ledger', icon: Wallet, permission: 'wallet:view' },
{ label: '系统配置', to: '/admin/system-configs', icon: Operation, permission: 'system_config:view' },
{ label: '审计日志', to: '/admin/audit-logs', icon: Document, permission: 'audit_log:view' },
{ label: '管理员管理', to: '/admin/admin-users', icon: UserFilled, permission: 'admin_user:manage' },
{ label: '角色管理', to: '/admin/roles', icon: Setting, permission: 'role:manage' },
]
const navItems = computed(() => {
if (adminSession.isSuperAdmin) return allNavItems
return allNavItems.filter((item) => {
if (!item.permission) return true
return adminSession.hasPermission(item.permission)
})
})
const adminName = computed(() => adminSession.nickname || adminSession.username || '管理员')
async function handleLogout() {