From 91d89fb958f725c184ec462dd82c8008919ba3d5 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Tue, 30 Dec 2025 15:55:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(mock):=20=E5=B8=82=E5=9C=BA=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=20API=20=E5=A2=9E=E5=8A=A0=E6=98=A8=E6=97=A5=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /api/market/statistics 返回 yesterday 字段 - 包含昨日市值、成交额、涨跌家数 - 支持前端计算环比变化率 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/mocks/handlers/market.js | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) 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) }); }), ];