feat: 移除通知mock相关数据
This commit is contained in:
@@ -624,14 +624,7 @@ export const NotificationProvider = ({ children }) => {
|
|||||||
setConnectionStatus(CONNECTION_STATUS.CONNECTED);
|
setConnectionStatus(CONNECTION_STATUS.CONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果使用 mock,可以启动定期推送
|
// 订阅事件推送
|
||||||
if (SOCKET_TYPE === 'MOCK') {
|
|
||||||
// 启动模拟推送:使用配置的间隔和数量
|
|
||||||
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;');
|
console.log('%c[NotificationContext] 🔔 订阅事件推送...', 'color: #FF9800; font-weight: bold;');
|
||||||
|
|
||||||
if (socket.subscribeToEvents) {
|
if (socket.subscribeToEvents) {
|
||||||
@@ -646,8 +639,7 @@ export const NotificationProvider = ({ children }) => {
|
|||||||
// ⚠️ 不需要 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');
|
||||||
|
|||||||
Reference in New Issue
Block a user