feat: 移除通知mock相关数据

This commit is contained in:
zdl
2025-11-10 15:30:50 +08:00
parent 9069a2be55
commit 71f2e89072

View File

@@ -624,30 +624,22 @@ export const NotificationProvider = ({ children }) => {
setConnectionStatus(CONNECTION_STATUS.CONNECTED); setConnectionStatus(CONNECTION_STATUS.CONNECTED);
} }
// 如果使用 mock可以启动定期推送 // 订阅事件推送
if (SOCKET_TYPE === 'MOCK') { console.log('%c[NotificationContext] 🔔 订阅事件推送...', 'color: #FF9800; font-weight: bold;');
// 启动模拟推送:使用配置的间隔和数量
const { interval, maxBatch } = NOTIFICATION_CONFIG.mockPush;
socket.startMockPush(interval, maxBatch);
logger.info('NotificationContext', 'Mock push started', { interval, maxBatch });
} else {
// ✅ 真实模式下,订阅事件推送
console.log('%c[NotificationContext] 🔔 订阅事件推送...', 'color: #FF9800; font-weight: bold;');
if (socket.subscribeToEvents) { if (socket.subscribeToEvents) {
socket.subscribeToEvents({ socket.subscribeToEvents({
eventType: 'all', eventType: 'all',
importance: 'all', importance: 'all',
onSubscribed: (data) => { onSubscribed: (data) => {
console.log('%c[NotificationContext] ✅ 订阅成功!', 'color: #4CAF50; font-weight: bold;'); console.log('%c[NotificationContext] ✅ 订阅成功!', 'color: #4CAF50; font-weight: bold;');
console.log('[NotificationContext] 订阅确认:', data); console.log('[NotificationContext] 订阅确认:', data);
logger.info('NotificationContext', 'Events subscribed', data); logger.info('NotificationContext', 'Events subscribed', data);
}, },
// ⚠️ 不需要 onNewEvent 回调,因为 NotificationContext 已经通过 socket.on('new_event') 监听 // ⚠️ 不需要 onNewEvent 回调,因为 NotificationContext 已经通过 socket.on('new_event') 监听
}); });
} else { } else {
console.warn('[NotificationContext] ⚠️ socket.subscribeToEvents 方法不可用'); console.error('[NotificationContext] socket.subscribeToEvents 方法不可用');
}
} }
}); });
@@ -752,11 +744,6 @@ export const NotificationProvider = ({ children }) => {
return () => { return () => {
logger.info('NotificationContext', 'Cleaning up socket connection'); logger.info('NotificationContext', 'Cleaning up socket connection');
// 如果是 mock service停止推送
if (SOCKET_TYPE === 'MOCK') {
socket.stopMockPush();
}
socket.off('connect'); socket.off('connect');
socket.off('disconnect'); socket.off('disconnect');
socket.off('connect_error'); socket.off('connect_error');