Add nickname. Recode route.

This commit is contained in:
2023-10-31 18:44:18 +08:00
parent 652d3f0132
commit b314a9f801
7 changed files with 64 additions and 10 deletions

View File

@@ -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