Files
webgame-frontend/src/api/modules/user/info.ts
2026-06-16 12:12:33 +08:00

52 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { requestClient } from '@/api/request'
/**
* 性别枚举
*
* 对应 OpenAPI: Sex (x-enums)
* 1 = 男2 = 女
*/
export const Sex = {
/** 男 */
MALE: 1,
/** 女 */
FEMALE: 2
} as const
/** 性别类型 */
export type SexType = (typeof Sex)[keyof typeof Sex]
/**
* 用户信息响应
*
* 对应 OpenAPI: UserInfoResponse
* 所有字段均为可选,部分字段可能为 null
*/
export interface UserInfoResponse {
/** 用户昵称,最长 16 位 */
nickName?: string
/** 头像图片 URL 地址,可能为 null */
avatar?: string | null
/** 个性签名,最长 64 位,可能为 null */
signature?: string | null
/** 年龄,可能为 null */
age?: number | null
/** 性别1=男2=女,可能为 null */
sex?: SexType | null
/** 生日ISO 8601 日期格式),可能为 null */
birthday?: string | null
}
/**
* 获取当前登录用户信息
*
* 根据请求头中的 saToken 获取当前登录用户的详细信息,
* 包括昵称、头像、个性签名、年龄、性别、生日。
* 需登录认证。
*
* @returns 当前登录用户的详细信息
*/
export function getUserInfo() {
return requestClient.get<UserInfoResponse>('/user/info')
}