feat: 更新训练计划和今日训练页面
- 在训练计划中添加了新的类型定义,优化了排课功能 - 修改了今日训练页面的布局,提升用户体验 - 删除了不再使用的排课相关文件,简化代码结构 - 更新了 Redux 状态管理,确保数据处理的准确性和稳定性
This commit is contained in:
@@ -227,8 +227,10 @@ const workoutSlice = createSlice({
|
||||
})
|
||||
.addCase(loadTodayWorkout.fulfilled, (state, action) => {
|
||||
state.loading = false;
|
||||
state.currentSession = action.payload;
|
||||
state.exercises = action.payload.exercises || [];
|
||||
if (action.payload) {
|
||||
state.currentSession = action.payload;
|
||||
state.exercises = action.payload.exercises || [];
|
||||
}
|
||||
})
|
||||
.addCase(loadTodayWorkout.rejected, (state, action) => {
|
||||
state.loading = false;
|
||||
@@ -372,14 +374,14 @@ const workoutSlice = createSlice({
|
||||
.addCase(deleteWorkoutSession.fulfilled, (state, action) => {
|
||||
state.loading = false;
|
||||
const deletedSessionId = action.payload;
|
||||
|
||||
|
||||
// 如果删除的是当前会话,清空当前会话数据
|
||||
if (state.currentSession?.id === deletedSessionId) {
|
||||
state.currentSession = null;
|
||||
state.exercises = [];
|
||||
state.stats = null;
|
||||
}
|
||||
|
||||
|
||||
// 从会话列表中移除已删除的会话
|
||||
state.sessions = state.sessions.filter(session => session.id !== deletedSessionId);
|
||||
})
|
||||
@@ -391,5 +393,5 @@ const workoutSlice = createSlice({
|
||||
});
|
||||
|
||||
export const { clearWorkoutError, clearCurrentWorkout, updateExerciseLocally } = workoutSlice.actions;
|
||||
export { addWorkoutExercise, deleteWorkoutSession };
|
||||
|
||||
export default workoutSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user