helper.js 696 B

123456789101112131415161718192021222324252627282930
  1. import api from '@/api'
  2. import { basePermissions } from '@/settings'
  3. export async function getUserInfo() {
  4. const res = await api.getUser()
  5. const { id, username, profile, roles, currentRole } = res.data || {}
  6. return {
  7. id,
  8. username,
  9. avatar: profile?.avatar,
  10. nickName: profile?.nickName,
  11. gender: profile?.gender,
  12. address: profile?.address,
  13. email: profile?.email,
  14. roles,
  15. currentRole,
  16. }
  17. }
  18. export async function getPermissions() {
  19. let asyncPermissions = []
  20. try {
  21. const res = await api.getRolePermissions()
  22. asyncPermissions = res?.data || []
  23. }
  24. catch (error) {
  25. console.error(error)
  26. }
  27. return basePermissions.concat(asyncPermissions)
  28. }