优化不能修改昵称弹窗
This commit is contained in:
@@ -45,6 +45,15 @@ const fetchUserInfoWithLock = async (set) => {
|
||||
return fetchUserInfoPromise;
|
||||
};
|
||||
|
||||
const getTimeNextDate = (time: string) => {
|
||||
const date = new Date(time);
|
||||
date.setDate(date.getDate() + 1);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
export const useUser = create<UserState>()((set) => ({
|
||||
user: {},
|
||||
fetchUserInfo: () => fetchUserInfoWithLock(set),
|
||||
@@ -68,7 +77,13 @@ export const useUser = create<UserState>()((set) => ({
|
||||
checkNicknameChangeStatus: async () => {
|
||||
try {
|
||||
const res = await checkNicknameChangeStatusApi();
|
||||
set({ nicknameChangeStatus: res.data });
|
||||
const { next_period_start_time } = res.data;
|
||||
set({
|
||||
nicknameChangeStatus: {
|
||||
...res.data,
|
||||
next_period_start_date: getTimeNextDate(next_period_start_time),
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("检查昵称变更状态失败:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user