更新Company页面的UI为FUI风格
This commit is contained in:
@@ -1585,4 +1585,107 @@ export const eventHandlers = [
|
||||
);
|
||||
}
|
||||
}),
|
||||
|
||||
// ==================== 主线模式相关 ====================
|
||||
|
||||
// 获取按主线(lv2概念)分组的事件列表
|
||||
http.get('/api/events/mainline', async ({ request }) => {
|
||||
await delay(500);
|
||||
|
||||
const url = new URL(request.url);
|
||||
const recentDays = parseInt(url.searchParams.get('recent_days') || '7', 10);
|
||||
const importance = url.searchParams.get('importance') || 'all';
|
||||
const limitPerMainline = parseInt(url.searchParams.get('limit') || '20', 10);
|
||||
|
||||
console.log('[Mock Event] 获取主线数据:', { recentDays, importance, limitPerMainline });
|
||||
|
||||
try {
|
||||
// 生成 mock 事件数据
|
||||
const allEvents = generateDynamicNewsEvents(100);
|
||||
|
||||
// 定义 lv2 主线分类
|
||||
const mainlineDefinitions = [
|
||||
{ lv2_id: 'L2_AI_INFRA', lv2_name: 'AI基础设施 (算力/CPO/PCB)', lv1_name: 'TMT (科技/媒体/通信)', keywords: ['算力', 'AI', '人工智能', 'CPO', 'PCB', '光模块', '大模型', '智能体'] },
|
||||
{ lv2_id: 'L2_SEMICONDUCTOR', lv2_name: '半导体 (设计/制造/封测)', lv1_name: 'TMT (科技/媒体/通信)', keywords: ['半导体', '芯片', '光刻', 'IC', '晶圆', '封装', '测试'] },
|
||||
{ lv2_id: 'L2_ROBOT', lv2_name: '机器人 (人形机器人/工业机器人)', lv1_name: 'TMT (科技/媒体/通信)', keywords: ['机器人', '人形', '自动化', '工业机器人', '具身智能'] },
|
||||
{ lv2_id: 'L2_CONSUMER_ELEC', lv2_name: '消费电子 (手机/XR/可穿戴)', lv1_name: 'TMT (科技/媒体/通信)', keywords: ['手机', 'XR', 'VR', 'AR', '可穿戴', '华为', '苹果', '消费电子'] },
|
||||
{ lv2_id: 'L2_NEW_ENERGY', lv2_name: '新能源 (光伏/储能/电池)', lv1_name: '新能源与环保', keywords: ['光伏', '储能', '电池', '锂电', '新能源', '风电', '清洁能源'] },
|
||||
{ lv2_id: 'L2_EV', lv2_name: '新能源汽车 (整车/零部件)', lv1_name: '新能源与环保', keywords: ['新能源汽车', '电动车', '智能驾驶', '汽车', '整车', '零部件'] },
|
||||
{ lv2_id: 'L2_LOW_ALTITUDE', lv2_name: '低空经济 (无人机/eVTOL)', lv1_name: '先进制造', keywords: ['低空', '无人机', 'eVTOL', '飞行', '空域'] },
|
||||
{ lv2_id: 'L2_MILITARY', lv2_name: '军工 (航空航天/国防)', lv1_name: '先进制造', keywords: ['军工', '国防', '航空', '航天', '卫星', '导弹'] },
|
||||
{ lv2_id: 'L2_PHARMA', lv2_name: '医药医疗 (创新药/器械)', lv1_name: '医药健康', keywords: ['医药', '医疗', '创新药', '器械', '生物', 'CXO'] },
|
||||
{ lv2_id: 'L2_FINANCE', lv2_name: '金融 (银行/券商/保险)', lv1_name: '金融', keywords: ['金融', '银行', '券商', '保险', '证券'] },
|
||||
];
|
||||
|
||||
// 按主线分组事件
|
||||
const mainlineGroups = {};
|
||||
|
||||
allEvents.forEach(event => {
|
||||
// 从事件的 keywords (related_concepts) 中查找匹配的主线
|
||||
const keywords = event.keywords || event.related_concepts || [];
|
||||
const conceptNames = keywords.map(k => k.concept || k.name || k).join(' ');
|
||||
const titleAndDesc = `${event.title || ''} ${event.description || ''}`;
|
||||
const textToMatch = `${conceptNames} ${titleAndDesc}`.toLowerCase();
|
||||
|
||||
// 匹配主线
|
||||
mainlineDefinitions.forEach(mainline => {
|
||||
const matched = mainline.keywords.some(kw => textToMatch.includes(kw.toLowerCase()));
|
||||
if (matched) {
|
||||
if (!mainlineGroups[mainline.lv2_id]) {
|
||||
mainlineGroups[mainline.lv2_id] = {
|
||||
lv2_id: mainline.lv2_id,
|
||||
lv2_name: mainline.lv2_name,
|
||||
lv1_name: mainline.lv1_name,
|
||||
events: []
|
||||
};
|
||||
}
|
||||
// 避免重复添加
|
||||
if (!mainlineGroups[mainline.lv2_id].events.find(e => e.id === event.id)) {
|
||||
mainlineGroups[mainline.lv2_id].events.push(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 转换为数组,限制每组数量,按事件数量排序
|
||||
const mainlines = Object.values(mainlineGroups)
|
||||
.map(group => ({
|
||||
...group,
|
||||
events: group.events.slice(0, limitPerMainline),
|
||||
event_count: Math.min(group.events.length, limitPerMainline)
|
||||
}))
|
||||
.filter(group => group.event_count > 0)
|
||||
.sort((a, b) => b.event_count - a.event_count);
|
||||
|
||||
// 统计未分组的事件
|
||||
const groupedEventIds = new Set();
|
||||
mainlines.forEach(m => m.events.forEach(e => groupedEventIds.add(e.id)));
|
||||
const ungroupedCount = allEvents.filter(e => !groupedEventIds.has(e.id)).length;
|
||||
|
||||
console.log('[Mock Event] 主线数据生成完成:', {
|
||||
mainlineCount: mainlines.length,
|
||||
totalEvents: allEvents.length,
|
||||
ungroupedCount
|
||||
});
|
||||
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
mainlines,
|
||||
total_events: allEvents.length,
|
||||
mainline_count: mainlines.length,
|
||||
ungrouped_count: ungroupedCount
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[Mock Event] 主线数据获取失败:', error);
|
||||
return HttpResponse.json(
|
||||
{
|
||||
success: false,
|
||||
error: error.message || '获取主线数据失败'
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user