Add nickname. Recode route.
This commit is contained in:
@@ -54,12 +54,45 @@ export const requestUserInfo = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
export const getNickName = async () => {
|
||||
const user = await getUserInfo()
|
||||
|
||||
return user.userInfo.nickName
|
||||
}
|
||||
|
||||
export const getUsername = async () => {
|
||||
const user = await getUserInfo()
|
||||
|
||||
return user.username
|
||||
}
|
||||
|
||||
export const getPermissionPath = (): string[] => {
|
||||
const s = getLocalStorage(STORAGE_USER_INFO_KEY)
|
||||
if (s === null) {
|
||||
return []
|
||||
}
|
||||
|
||||
const user = JSON.parse(s) as UserWithInfoVo
|
||||
const paths: string[] = []
|
||||
user.menus.forEach((menu) => {
|
||||
paths.join(menu.url)
|
||||
})
|
||||
|
||||
return paths
|
||||
}
|
||||
|
||||
export const getAuthRoute = (route: RouteJsonObject[]): RouteJsonObject[] => {
|
||||
return route.map((value) => {
|
||||
if (value.auth) {
|
||||
value.path
|
||||
}
|
||||
if (value.children) {
|
||||
value.children = getAuthRoute(value.children)
|
||||
}
|
||||
return value
|
||||
})
|
||||
}
|
||||
|
||||
export const getCaptchaSrc = () => {
|
||||
captcha = getCaptcha(300, 150, 4)
|
||||
return captcha.base64Src
|
||||
|
||||
Reference in New Issue
Block a user