更新UserAPI接口

This commit is contained in:
洛洛希雅Lolosia 2023-06-06 09:26:23 +08:00
parent 83ba0e45d2
commit 4b2b62a01c

View File

@ -1,5 +1,5 @@
//获取用户信息 //获取用户信息
import request, { post } from '@/utils/request' import request, { baseUrl, post } from '@/utils/request'
export interface IUser { export interface IUser {
id: string id: string
@ -10,6 +10,7 @@ export interface IUser {
legacyId: number legacyId: number
database: string database: string
Authorization: string Authorization: string
avatar: string
} }
export interface IUserRole { export interface IUserRole {
@ -21,7 +22,11 @@ export interface IUserRole {
} }
export async function getMyInfo(): Promise<IUser> { export async function getMyInfo(): Promise<IUser> {
return post('/user/myInfo') const rs = await post<IUser>('/user/myInfo')
if (rs.avatar && !/^((https?|data):|\/\/)/.test(rs.avatar)) {
rs.avatar = `${baseUrl}/api/user/avatar?id=${rs.id}`
}
return rs
} }
export async function getMyRole(): Promise<IUserRole> { export async function getMyRole(): Promise<IUserRole> {