feat: 添加mock数据
This commit is contained in:
@@ -434,13 +434,8 @@ export const accountHandlers = [
|
|||||||
http.get('/api/account/calendar/events', async ({ request }) => {
|
http.get('/api/account/calendar/events', async ({ request }) => {
|
||||||
await delay(NETWORK_DELAY);
|
await delay(NETWORK_DELAY);
|
||||||
|
|
||||||
const currentUser = getCurrentUser();
|
// Mock 模式下允许无登录访问,使用默认用户 id: 1
|
||||||
if (!currentUser) {
|
const currentUser = getCurrentUser() || { id: 1 };
|
||||||
return HttpResponse.json(
|
|
||||||
{ success: false, error: '未登录' },
|
|
||||||
{ status: 401 }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const startDate = url.searchParams.get('start_date');
|
const startDate = url.searchParams.get('start_date');
|
||||||
@@ -455,8 +450,8 @@ export const accountHandlers = [
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取投资计划和复盘,转换为日历事件格式
|
// 2. 获取投资计划和复盘,转换为日历事件格式
|
||||||
|
// Mock 模式:不过滤 user_id,显示所有 mock 数据(方便开发测试)
|
||||||
const investmentPlansAsEvents = mockInvestmentPlans
|
const investmentPlansAsEvents = mockInvestmentPlans
|
||||||
.filter(plan => plan.user_id === currentUser.id)
|
|
||||||
.map(plan => ({
|
.map(plan => ({
|
||||||
id: plan.id,
|
id: plan.id,
|
||||||
user_id: plan.user_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,
|
calendarEvents: calendarEvents.length,
|
||||||
investmentPlansAsEvents: investmentPlansAsEvents.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({
|
return HttpResponse.json({
|
||||||
|
|||||||
Reference in New Issue
Block a user