Complete main UI #37
10
src/global.d.ts
vendored
10
src/global.d.ts
vendored
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@ export const getLoginStatus = () => {
|
||||
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) {
|
||||
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<UserVo>(URL_API_USER_INFO).then((value) => {
|
||||
await request.get<UserWithInfoVo>(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<UserVo>((resolve, reject) => {
|
||||
return new Promise<UserWithInfoVo>((resolve, reject) => {
|
||||
if (user) {
|
||||
resolve(user)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user