GuDingZiChan/frontend/src/auth/permissions.ts

36 lines
1.1 KiB
TypeScript

import type { UserRole } from '@/types'
export const PERMISSIONS = {
ASSETS_VIEW_ALL: 'assets.view_all',
ASSETS_VIEW_OWN: 'assets.view_own',
ASSETS_CREATE: 'assets.create',
ASSETS_IMPORT: 'assets.import',
ASSETS_CORRECT: 'assets.correct',
ASSETS_DELETE: 'assets.delete',
ASSETS_BORROW: 'assets.borrow',
ASSETS_TRANSFER: 'assets.transfer',
ASSETS_MAINTENANCE: 'assets.maintenance',
ASSETS_MOUNT: 'assets.mount',
ASSETS_PRINT_LABELS: 'assets.print_labels',
DISPOSALS_APPLY: 'disposals.apply',
DISPOSALS_APPROVE: 'disposals.approve',
DISPOSALS_COMPLETE: 'disposals.complete',
INVENTORY_MANAGE: 'inventory.manage',
NOTIFICATIONS_VIEW: 'notifications.view',
USERS_MANAGE: 'users.manage',
SYNC_MANAGE: 'sync.manage',
SYSTEM_SETTINGS: 'system.settings',
REPORTS_VIEW: 'reports.view'
} as const
export type Permission = (typeof PERMISSIONS)[keyof typeof PERMISSIONS]
export const ROLE_LABELS: Record<UserRole, string> = {
admin: '管理员',
administrative: '行政',
it: 'IT',
user: '普通用户'
}
export const getRoleLabel = (role?: string | null) => ROLE_LABELS[role as UserRole] || '普通用户'