diff --git a/src/global.d.ts b/src/global.d.ts index 07e0eec..80eae3b 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -51,7 +51,7 @@ type TokenVo = { token: string } -type UserVo = { +type UserWithInfoVo = { id: string username: string locking: boolean @@ -62,11 +62,18 @@ type UserVo = { lastLoginIp: string createTime: Date updateTime: Date + modules: ModuleVo[] menus: MenuVo[] elements: ElementVo[] operations: OperationVo[] } +type ModuleVo = { + id: number + name: string + powerId: number +} + type MenuVo = { id: number name: string @@ -88,7 +95,6 @@ type OperationVo = { name: string code: string powerId: number - parentId: number elementId: number } diff --git a/src/utils/auth.ts b/src/utils/auth.ts index fd583ea..c73a7f2 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -26,19 +26,19 @@ export const getLoginStatus = () => { return getLocalStorage(STORAGE_TOKEN_KEY) !== null } -export const getUserInfo = async (): Promise => { +export const getUserInfo = async (): Promise => { if (getLocalStorage(STORAGE_USER_INFO_KEY) !== null) { 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() } export const requestUserInfo = async () => { - let user: UserVo | null + let user: UserWithInfoVo | null - await request.get(URL_API_USER_INFO).then((value) => { + await request.get(URL_API_USER_INFO).then((value) => { const response = value.data if (response.code === DATABASE_SELECT_SUCCESS) { user = response.data @@ -46,7 +46,7 @@ export const requestUserInfo = async () => { } }) - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { if (user) { resolve(user) }