Compare commits
2 Commits
ada9f6e778
...
9bb9eab922
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bb9eab922 | ||
|
|
3d7b0045b7 |
@@ -661,6 +661,12 @@ export const NotificationProvider = ({ children }) => {
|
|||||||
|
|
||||||
// ========== 连接到 Socket 服务(⚡ 异步初始化,不阻塞首屏) ==========
|
// ========== 连接到 Socket 服务(⚡ 异步初始化,不阻塞首屏) ==========
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// ⚡ Mock 模式下跳过 Socket 连接(避免连接生产服务器失败的错误)
|
||||||
|
if (process.env.REACT_APP_ENABLE_MOCK === 'true') {
|
||||||
|
logger.debug('NotificationContext', 'Mock 模式,跳过 Socket 连接');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ⚡ 防止 React Strict Mode 导致的重复初始化
|
// ⚡ 防止 React Strict Mode 导致的重复初始化
|
||||||
if (socketInitialized) {
|
if (socketInitialized) {
|
||||||
logger.debug('NotificationContext', 'Socket 已初始化,跳过重复执行(Strict Mode 保护)');
|
logger.debug('NotificationContext', 'Socket 已初始化,跳过重复执行(Strict Mode 保护)');
|
||||||
|
|||||||
@@ -1,16 +1,28 @@
|
|||||||
// src/mocks/handlers/bytedesk.js
|
// src/mocks/handlers/bytedesk.js
|
||||||
/**
|
/**
|
||||||
* Bytedesk 客服 Widget MSW Handler
|
* Bytedesk 客服 Widget MSW Handler
|
||||||
* 使用 passthrough 让请求通过到真实服务器,消除 MSW 警告
|
* Mock 模式下返回模拟数据
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { http, passthrough } from 'msw';
|
import { http, HttpResponse, passthrough } from 'msw';
|
||||||
|
|
||||||
export const bytedeskHandlers = [
|
export const bytedeskHandlers = [
|
||||||
// Bytedesk API 请求 - 直接 passthrough
|
// 未读消息数量
|
||||||
// 匹配 /bytedesk/* 路径(通过代理访问后端)
|
http.get('/bytedesk/visitor/api/v1/message/unread/count', () => {
|
||||||
|
return HttpResponse.json({
|
||||||
|
code: 200,
|
||||||
|
message: 'success',
|
||||||
|
data: { count: 0 },
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
|
||||||
|
// 其他 Bytedesk API - 返回通用成功响应
|
||||||
http.all('/bytedesk/*', () => {
|
http.all('/bytedesk/*', () => {
|
||||||
return passthrough();
|
return HttpResponse.json({
|
||||||
|
code: 200,
|
||||||
|
message: 'success',
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Bytedesk 外部 CDN/服务请求
|
// Bytedesk 外部 CDN/服务请求
|
||||||
|
|||||||
Reference in New Issue
Block a user