feat: 事件关注功能优化 - Redux 乐观更新 + Mock 数据状态同步
1. communityDataSlice 添加事件关注乐观更新 - pending: 立即切换 isFollowing 状态 - rejected: 回滚到之前状态 - fulfilled: 使用 API 返回的准确数据覆盖 2. Mock 数据添加内存状态管理 - 新增 followedEventsSet 和 followedEventsMap 存储 - toggleEventFollowStatus: 切换关注状态 - isEventFollowed: 检查是否已关注 - getFollowedEvents: 获取关注事件列表 3. Mock handlers 使用内存状态 - follow handler: 使用 toggleEventFollowStatus - following handler: 使用 getFollowedEvents 动态返回 - 事件详情: 返回正确的 is_following 状态 修复: 关注事件后导航栏"自选事件"列表不同步更新的问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,8 @@ import {
|
||||
mockInvestmentPlans,
|
||||
mockCalendarEvents,
|
||||
mockSubscriptionCurrent,
|
||||
getCalendarEventsByDateRange
|
||||
getCalendarEventsByDateRange,
|
||||
getFollowedEvents
|
||||
} from '../data/account';
|
||||
|
||||
// 模拟网络延迟(毫秒)
|
||||
@@ -250,7 +251,7 @@ export const accountHandlers = [
|
||||
|
||||
// ==================== 事件关注管理 ====================
|
||||
|
||||
// 8. 获取关注的事件
|
||||
// 8. 获取关注的事件(使用内存状态动态返回)
|
||||
http.get('/api/account/events/following', async () => {
|
||||
await delay(NETWORK_DELAY);
|
||||
|
||||
@@ -262,11 +263,14 @@ export const accountHandlers = [
|
||||
);
|
||||
}
|
||||
|
||||
console.log('[Mock] 获取关注的事件');
|
||||
// 从内存存储获取已关注的事件列表
|
||||
const followedEvents = getFollowedEvents();
|
||||
|
||||
console.log('[Mock] 获取关注的事件, 数量:', followedEvents.length);
|
||||
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
data: mockFollowingEvents
|
||||
data: followedEvents
|
||||
});
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user