diff --git a/src/mocks/handlers/market.js b/src/mocks/handlers/market.js index 1e0b8659..2e0f9d64 100644 --- a/src/mocks/handlers/market.js +++ b/src/mocks/handlers/market.js @@ -582,19 +582,38 @@ export const marketHandlers = [ console.log('[Mock Market] 获取市场统计数据:', { date: tradeDate }); + // 生成今日数据 + const todayMarketCap = parseFloat((Math.random() * 5000 + 80000).toFixed(2)); + const todayAmount = parseFloat((Math.random() * 3000 + 8000).toFixed(2)); + const todayRising = Math.floor(Math.random() * 1500 + 1500); + const todayFalling = Math.floor(Math.random() * 1500 + 1000); + + // 生成昨日数据(用于对比) + const yesterdayMarketCap = parseFloat((todayMarketCap * (0.98 + Math.random() * 0.04)).toFixed(2)); + const yesterdayAmount = parseFloat((todayAmount * (0.85 + Math.random() * 0.3)).toFixed(2)); + const yesterdayRising = Math.floor(todayRising * (0.7 + Math.random() * 0.6)); + const yesterdayFalling = Math.floor(todayFalling * (0.7 + Math.random() * 0.6)); + return HttpResponse.json({ success: true, summary: { - total_market_cap: parseFloat((Math.random() * 5000 + 80000).toFixed(2)), // 80000-85000亿 - total_amount: parseFloat((Math.random() * 3000 + 8000).toFixed(2)), // 8000-11000亿 - avg_pe: parseFloat((Math.random() * 5 + 12).toFixed(2)), // 12-17 - avg_pb: parseFloat((Math.random() * 0.5 + 1.3).toFixed(2)), // 1.3-1.8 - rising_stocks: Math.floor(Math.random() * 1500 + 1500), // 1500-3000 - falling_stocks: Math.floor(Math.random() * 1500 + 1000), // 1000-2500 - unchanged_stocks: Math.floor(Math.random() * 200 + 100) // 100-300 + total_market_cap: todayMarketCap, + total_amount: todayAmount, + avg_pe: parseFloat((Math.random() * 5 + 12).toFixed(2)), + avg_pb: parseFloat((Math.random() * 0.5 + 1.3).toFixed(2)), + rising_stocks: todayRising, + falling_stocks: todayFalling, + unchanged_stocks: Math.floor(Math.random() * 200 + 100) + }, + // 昨日对比数据 + yesterday: { + total_market_cap: yesterdayMarketCap, + total_amount: yesterdayAmount, + rising_stocks: yesterdayRising, + falling_stocks: yesterdayFalling }, trade_date: tradeDate, - available_dates: availableDates.slice(0, 20) // 返回最近20个交易日 + available_dates: availableDates.slice(0, 20) }); }), ];