Change UserVo to UserWithInfoVo

This commit is contained in:
2023-10-30 18:41:20 +08:00
parent fcd4fd532c
commit 652d3f0132
2 changed files with 13 additions and 7 deletions

10
src/global.d.ts vendored
View File

@@ -51,7 +51,7 @@ type TokenVo = {
token: string token: string
} }
type UserVo = { type UserWithInfoVo = {
id: string id: string
username: string username: string
locking: boolean locking: boolean
@@ -62,11 +62,18 @@ type UserVo = {
lastLoginIp: string lastLoginIp: string
createTime: Date createTime: Date
updateTime: Date updateTime: Date
modules: ModuleVo[]
menus: MenuVo[] menus: MenuVo[]
elements: ElementVo[] elements: ElementVo[]
operations: OperationVo[] operations: OperationVo[]
} }
type ModuleVo = {
id: number
name: string
powerId: number
}
type MenuVo = { type MenuVo = {
id: number id: number
name: string name: string
@@ -88,7 +95,6 @@ type OperationVo = {
name: string name: string
code: string code: string
powerId: number powerId: number
parentId: number
elementId: number elementId: number
} }

View File

@@ -26,19 +26,19 @@ export const getLoginStatus = () => {
return getLocalStorage(STORAGE_TOKEN_KEY) !== null return getLocalStorage(STORAGE_TOKEN_KEY) !== null
} }
export const getUserInfo = async (): Promise<UserVo> => { export const getUserInfo = async (): Promise<UserWithInfoVo> => {
if (getLocalStorage(STORAGE_USER_INFO_KEY) !== null) { if (getLocalStorage(STORAGE_USER_INFO_KEY) !== null) {
return new Promise((resolve) => { return new Promise((resolve) => {
resolve(JSON.parse(getLocalStorage(STORAGE_USER_INFO_KEY) as string) as UserVo) resolve(JSON.parse(getLocalStorage(STORAGE_USER_INFO_KEY) as string) as UserWithInfoVo)
}) })
} }
return requestUserInfo() return requestUserInfo()
} }
export const requestUserInfo = async () => { export const requestUserInfo = async () => {
let user: UserVo | null let user: UserWithInfoVo | null
await request.get<UserVo>(URL_API_USER_INFO).then((value) => { await request.get<UserWithInfoVo>(URL_API_USER_INFO).then((value) => {
const response = value.data const response = value.data
if (response.code === DATABASE_SELECT_SUCCESS) { if (response.code === DATABASE_SELECT_SUCCESS) {
user = response.data user = response.data
@@ -46,7 +46,7 @@ export const requestUserInfo = async () => {
} }
}) })
return new Promise<UserVo>((resolve, reject) => { return new Promise<UserWithInfoVo>((resolve, reject) => {
if (user) { if (user) {
resolve(user) resolve(user)
} }