feat: 添加用户活动热力图组件
在个人页面新增活动热力图展示组件,并实现浮动动画效果优化统计卡片交互体验。
This commit is contained in:
@@ -20,6 +20,17 @@ export type UserProfile = {
|
||||
maxUsageCount?: number;
|
||||
};
|
||||
|
||||
export type WeightHistoryItem = {
|
||||
weight: string;
|
||||
source: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
export type ActivityHistoryItem = {
|
||||
date: string;
|
||||
level: number;
|
||||
};
|
||||
|
||||
export type UserState = {
|
||||
token: string | null;
|
||||
profile: UserProfile;
|
||||
@@ -27,12 +38,7 @@ export type UserState = {
|
||||
error: string | null;
|
||||
privacyAgreed: boolean;
|
||||
weightHistory: WeightHistoryItem[];
|
||||
};
|
||||
|
||||
export type WeightHistoryItem = {
|
||||
weight: string;
|
||||
source: string;
|
||||
createdAt: string;
|
||||
activityHistory: ActivityHistoryItem[];
|
||||
};
|
||||
|
||||
export const DEFAULT_MEMBER_NAME = '普拉提星球学员';
|
||||
@@ -49,6 +55,7 @@ const initialState: UserState = {
|
||||
error: null,
|
||||
privacyAgreed: false,
|
||||
weightHistory: [],
|
||||
activityHistory: [],
|
||||
};
|
||||
|
||||
export type LoginPayload = Record<string, any> & {
|
||||
@@ -176,6 +183,16 @@ export const fetchWeightHistory = createAsyncThunk('user/fetchWeightHistory', as
|
||||
}
|
||||
});
|
||||
|
||||
// 获取用户活动历史记录
|
||||
export const fetchActivityHistory = createAsyncThunk('user/fetchActivityHistory', async (_, { rejectWithValue }) => {
|
||||
try {
|
||||
const data: ActivityHistoryItem[] = await api.get('/api/users/activity-history');
|
||||
console.log('fetchActivityHistory', data);
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
return rejectWithValue(err?.message ?? '获取用户活动历史记录失败');
|
||||
}
|
||||
});
|
||||
|
||||
const userSlice = createSlice({
|
||||
name: 'user',
|
||||
@@ -240,11 +257,15 @@ const userSlice = createSlice({
|
||||
})
|
||||
.addCase(fetchWeightHistory.rejected, (state, action) => {
|
||||
state.error = (action.payload as string) ?? '获取用户体重历史记录失败';
|
||||
})
|
||||
.addCase(fetchActivityHistory.fulfilled, (state, action) => {
|
||||
state.activityHistory = action.payload;
|
||||
})
|
||||
.addCase(fetchActivityHistory.rejected, (state, action) => {
|
||||
state.error = (action.payload as string) ?? '获取用户活动历史记录失败';
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const { updateProfile, setDailyStepsGoal, setDailyCaloriesGoal, setPilatesPurposes } = userSlice.actions;
|
||||
export default userSlice.reducer;
|
||||
|
||||
|
||||
export default userSlice.reducer;
|
||||
Reference in New Issue
Block a user