diff --git a/src/mocks/handlers/market.js b/src/mocks/handlers/market.js index b5a7ba0e..ba0fb21a 100644 --- a/src/mocks/handlers/market.js +++ b/src/mocks/handlers/market.js @@ -131,14 +131,14 @@ export const marketHandlers = [ // 热门概念列表 const conceptPool = [ - { name: '人工智能', desc: '人工智能是"技术突破+政策扶持"双轮驱动的硬科技主题。随着大模型技术的突破,AI应用场景不断拓展。' }, - { name: '新能源汽车', desc: '新能源汽车行业景气度持续向好,渗透率不断提升。政策支持力度大,产业链上下游企业均受益。' }, - { name: '半导体', desc: '国产半导体替代加速,自主可控需求强烈。政策和资金支持力度大,行业迎来黄金发展期。' }, - { name: '光伏', desc: '光伏装机量快速增长,成本持续下降,行业景气度维持高位。双碳目标下前景广阔。' }, - { name: '锂电池', desc: '锂电池技术进步,成本优势扩大,下游应用领域持续扩张。新能源汽车和储能需求旺盛。' }, - { name: '储能', desc: '储能市场爆发式增长,政策支持力度大,应用场景不断拓展。未来市场空间巨大。' }, - { name: '算力', desc: 'AI大模型推动算力需求爆发,数据中心、服务器、芯片等产业链受益明显。' }, - { name: '机器人', desc: '人形机器人产业化加速,特斯拉、小米等巨头入局,产业链迎来发展机遇。' }, + { name: '人工智能', desc: '人工智能是"技术突破+政策扶持"双轮驱动的硬科技主题。随着大模型技术的突破,AI应用场景不断拓展。', tags: ['AI大模型', '算力', '政策驱动'] }, + { name: '新能源汽车', desc: '新能源汽车行业景气度持续向好,渗透率不断提升。政策支持力度大,产业链上下游企业均受益。', tags: ['新能源', '汽车制造', '政策扶持'] }, + { name: '半导体', desc: '国产半导体替代加速,自主可控需求强烈。政策和资金支持力度大,行业迎来黄金发展期。', tags: ['芯片', '自主可控', '国产替代'] }, + { name: '光伏', desc: '光伏装机量快速增长,成本持续下降,行业景气度维持高位。双碳目标下前景广阔。', tags: ['清洁能源', '双碳', '装机量'] }, + { name: '锂电池', desc: '锂电池技术进步,成本优势扩大,下游应用领域持续扩张。新能源汽车和储能需求旺盛。', tags: ['储能', '新能源', '技术突破'] }, + { name: '储能', desc: '储能市场爆发式增长,政策支持力度大,应用场景不断拓展。未来市场空间巨大。', tags: ['新型储能', '电力系统', '政策驱动'] }, + { name: '算力', desc: 'AI大模型推动算力需求爆发,数据中心、服务器、芯片等产业链受益明显。', tags: ['数据中心', 'AI算力', '服务器'] }, + { name: '机器人', desc: '人形机器人产业化加速,特斯拉、小米等巨头入局,产业链迎来发展机遇。', tags: ['人形机器人', '产业化', '巨头入局'] }, ]; // 股票池(扩展到足够多的股票) @@ -245,6 +245,8 @@ export const marketHandlers = [ }, change_percent: changePercent, // 兼容字段 happened_times: generateHappenedTimes(i), + outbreak_dates: generateHappenedTimes(i).slice(0, 2), // 爆发日期 + tags: concept.tags || [], // 标签 stocks: relatedStocks, hot_score: Math.floor(Math.random() * 100) }); @@ -450,23 +452,33 @@ export const marketHandlers = [ const alertTypes = ['surge_up', 'surge_down', 'volume_spike', 'limit_up', 'rank_jump']; - // 生成 15-25 个异动 - const alertCount = Math.floor(Math.random() * 10) + 15; + // 生成 12-18 个异动(减少数量,更符合实际) + const alertCount = Math.floor(Math.random() * 6) + 12; const alerts = []; - const usedTimes = new Set(); + const usedTimeGroups = new Set(); // 记录已使用的10分钟时间段 + + // 获取10分钟时间段 + const getTimeGroup = (timeStr) => { + const [h, m] = timeStr.split(':').map(Number); + const groupStart = Math.floor(m / 10) * 10; + return `${h}:${groupStart < 10 ? '0' : ''}${groupStart}`; + }; for (let i = 0; i < alertCount; i++) { - // 随机选择一个时间点 + // 随机选择一个时间点,尽量分散到不同10分钟时间段 let timeIdx; let attempts = 0; + let timeGroup; do { timeIdx = Math.floor(Math.random() * timeline.length); + timeGroup = getTimeGroup(timeline[timeIdx].time); attempts++; - } while (usedTimes.has(timeIdx) && attempts < 50); + // 允许同一时间段最多2个异动 + } while (usedTimeGroups.has(timeGroup) && Math.random() > 0.3 && attempts < 50); if (attempts >= 50) continue; - // 同一时间可以有多个异动 + usedTimeGroups.add(timeGroup); const time = timeline[timeIdx].time; const conceptName = conceptNames[Math.floor(Math.random() * conceptNames.length)]; const alertType = alertTypes[Math.floor(Math.random() * alertTypes.length)];