mirror of
https://github.com/zclzone/vue-naive-admin.git
synced 2025-05-01 14:49:00 +08:00
30 lines
694 B
JavaScript
30 lines
694 B
JavaScript
import { basePermissions } from '@/settings'
|
|
import api from '@/api'
|
|
|
|
export async function getUserInfo() {
|
|
const res = await api.getUser()
|
|
const { id, username, profile, roles, currentRole } = res.data || {}
|
|
return {
|
|
id,
|
|
username,
|
|
avatar: profile?.avatar,
|
|
nickName: profile?.nickName,
|
|
gender: profile?.gender,
|
|
address: profile?.address,
|
|
email: profile?.email,
|
|
roles,
|
|
currentRole,
|
|
}
|
|
}
|
|
|
|
export async function getPermissions() {
|
|
let asyncPermissions = []
|
|
try {
|
|
const res = await api.getRolePermissions()
|
|
asyncPermissions = res?.data || []
|
|
} catch (error) {
|
|
console.error(error)
|
|
}
|
|
return basePermissions.concat(asyncPermissions)
|
|
}
|