From 5358303db026f07727e6734ebd190bb92032ef9c Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Fri, 5 Dec 2025 15:28:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0mock=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mocks/handlers/account.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/mocks/handlers/account.js b/src/mocks/handlers/account.js index a415b318..3394e0df 100644 --- a/src/mocks/handlers/account.js +++ b/src/mocks/handlers/account.js @@ -434,13 +434,8 @@ export const accountHandlers = [ http.get('/api/account/calendar/events', async ({ request }) => { await delay(NETWORK_DELAY); - const currentUser = getCurrentUser(); - if (!currentUser) { - return HttpResponse.json( - { success: false, error: '未登录' }, - { status: 401 } - ); - } + // Mock 模式下允许无登录访问,使用默认用户 id: 1 + const currentUser = getCurrentUser() || { id: 1 }; const url = new URL(request.url); const startDate = url.searchParams.get('start_date'); @@ -455,8 +450,8 @@ export const accountHandlers = [ } // 2. 获取投资计划和复盘,转换为日历事件格式 + // Mock 模式:不过滤 user_id,显示所有 mock 数据(方便开发测试) const investmentPlansAsEvents = mockInvestmentPlans - .filter(plan => plan.user_id === currentUser.id) .map(plan => ({ id: plan.id, user_id: plan.user_id, @@ -489,10 +484,13 @@ export const accountHandlers = [ }); } - console.log('[Mock] 合并后的日历事件数量:', { + console.log('[Mock] 日历事件详情:', { + currentUserId: currentUser.id, calendarEvents: calendarEvents.length, investmentPlansAsEvents: investmentPlansAsEvents.length, - total: filteredEvents.length + total: filteredEvents.length, + plansCount: filteredEvents.filter(e => e.type === 'plan').length, + reviewsCount: filteredEvents.filter(e => e.type === 'review').length }); return HttpResponse.json({