-
连接状态: {isConnected ? '已连接' : '未连接'}
-
-
-
-
-
-
-
- );
-}
-```
-
-### 消息格式(v2.0.0)
-
-```javascript
-{
- // 必填字段
- type: 'announcement' | 'stock_alert' | 'event_alert' | 'analysis_report',
- priority: 'urgent' | 'important' | 'normal',
- title: '通知标题',
- content: '详细消息内容',
-
- // 时间字段
- publishTime: 1711611000000, // 发布时间(毫秒时间戳)
- pushTime: Date.now(), // 推送时间(毫秒时间戳)
-
- // 元数据
- isAIGenerated: false, // 是否 AI 生成(显示 AI 徽章)
- clickable: true, // 是否可点击
- link: '/event-detail/ann001', // 点击跳转链接
-
- // 作者信息(仅 analysis_report 需要)
- author: {
- name: '李明',
- organization: '中信证券',
- },
-
- // 额外信息(自定义,根据类型不同)
- extra: {
- // announcement
- announcementType: '财报',
- companyCode: '600519',
-
- // stock_alert
- stockCode: '300750',
- priceChange: '+5.2%', // 💡 重要:涨跌判断依据
- currentPrice: '245.50',
-
- // event_alert
- eventId: 'evt001',
- relatedStocks: 12,
- impactLevel: '重大利好',
-
- // analysis_report
- reportType: '行业研报',
- industry: '医药',
- rating: '强烈推荐',
-
- // 🆕 预测通知专用字段
- isPrediction: true, // 是否为预测通知(显示"预测"徽章)
- statusHint: '详细报告生成中...', // 状态提示文字(可选)
- relatedPredictionId: 'pred_001', // 关联预测ID(用于追溯,可选)
- },
-
- // 自动关闭
- autoClose: 10000, // 毫秒,0 或 false 表示不自动关闭
-
- // 自动生成字段(无需手动设置)
- id: 'unique_id', // 自动生成
- timestamp: Date.now(), // 自动生成
-}
-```
-
----
-
-## 🔧 配置说明
-
-### Mock 服务配置
-
-在 `src/services/mockSocketService.js` 中可以配置:
-
-```javascript
-// 修改模拟数据(14 条金融资讯)
-const mockFinancialNews = [
- // 3 条公告通知
- {
- type: NOTIFICATION_TYPES.ANNOUNCEMENT,
- priority: PRIORITY_LEVELS.IMPORTANT,
- title: '贵州茅台发布2024年度财报公告',
- content: '2024年度营收同比增长15.2%,净利润创历史新高...',
- // ...
- },
-
- // 3 条股票动向
- {
- type: NOTIFICATION_TYPES.STOCK_ALERT,
- priority: PRIORITY_LEVELS.URGENT,
- title: '您关注的股票触发预警',
- content: '宁德时代(300750) 当前价格 ¥245.50,涨幅 +5.2%...',
- extra: {
- priceChange: '+5.2%', // 红色(涨)
- },
- // ...
- },
-
- // 3 条事件动向
- {
- type: NOTIFICATION_TYPES.EVENT_ALERT,
- priority: PRIORITY_LEVELS.IMPORTANT,
- title: '央行宣布降准0.5个百分点',
- // ...
- },
-
- // 4 条分析报告(2 条人工 + 2 条 AI)
- {
- type: NOTIFICATION_TYPES.ANALYSIS_REPORT,
- priority: PRIORITY_LEVELS.IMPORTANT,
- author: {
- name: '李明',
- organization: '中信证券',
- },
- isAIGenerated: false,
- // ...
- },
- {
- type: NOTIFICATION_TYPES.ANALYSIS_REPORT,
- author: {
- name: 'AI分析师',
- organization: '价值前沿',
- },
- isAIGenerated: true, // AI 徽章
- // ...
- },
-];
-
-// 调整推送频率
-socket.startMockPush(15000, 1); // 每15秒推送1条
-```
-
-### 通知类型常量配置
-
-在 `src/constants/notificationTypes.js` 中可以修改:
-
-```javascript
-// 修改类型配色
-export const NOTIFICATION_TYPE_CONFIGS = {
- [NOTIFICATION_TYPES.ANNOUNCEMENT]: {
- name: '公告通知',
- icon: MdCampaign,
- colorScheme: 'blue', // 修改颜色主题
- bg: 'blue.50',
- borderColor: 'blue.400',
- iconColor: 'blue.500',
- hoverBg: 'blue.100',
- },
- // ...
-};
-
-// 修改优先级标签
-export const PRIORITY_CONFIGS = {
- [PRIORITY_LEVELS.URGENT]: {
- label: '紧急',
- colorScheme: 'red',
- show: true,
- },
- // ...
-};
-```
-
-### NotificationContext 配置
-
-在 `src/contexts/NotificationContext.js` 中:
-
-```javascript
-// 修改最大消息数量(默认 5 条)
-const maxNotifications = 5; // 修改为其他数值
-
-// 修改默认音效状态
-const [soundEnabled, setSoundEnabled] = useState(true); // false 关闭音效
-
-// 修改音效音量
-audioRef.current.volume = 0.5; // 0.0 - 1.0
-```
-
-### NotificationContainer 配置
-
-在 `src/components/NotificationContainer/index.js` 中:
-
-```javascript
-// 调整通知宽度(默认 400px)
-