获取昵称修改状态、优化昵称修改逻辑

This commit is contained in:
2025-12-03 11:53:36 +08:00
parent 159b4ab1d2
commit 7c1a1fafc1
6 changed files with 146 additions and 65 deletions

View File

@@ -90,6 +90,14 @@ export interface UserInfoType {
ongoing_games?: string[];
}
export interface NicknameChangeStatus {
can_change: boolean;
remaining_count: number;
period_start_time: string;
next_period_start_time: string;
days_until_next_period: number;
}
// 后端球局数据接口
interface BackendGameData {
id: number;
@@ -681,6 +689,33 @@ export const fetchUserProfile = async (): Promise<
}
};
// 获取昵称修改状态
export const checkNicknameChangeStatus = async (): Promise<
ApiResponse<NicknameChangeStatus>
> => {
try {
const response = await httpService.post(
"/user/check_nickname_change_status"
);
return response;
} catch (error) {
console.error("获取昵称修改状态失败:", error);
throw error;
}
};
// 修改昵称
export const updateNickname = async (nickname: string) => {
try {
const response = await httpService.post("/user/update_nickname", {
nickname,
});
return response;
} catch (error) {
console.error("昵称修改失败:", error);
throw error;
}
};
// 更新用户信息
export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
try {