- 未读消息数量返回 { count: 0 }
- 其他 API 返回通用成功响应
- 解决 mock 模式下 404 错误
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
35 lines
835 B
JavaScript
35 lines
835 B
JavaScript
// src/mocks/handlers/bytedesk.js
|
|
/**
|
|
* Bytedesk 客服 Widget MSW Handler
|
|
* Mock 模式下返回模拟数据
|
|
*/
|
|
|
|
import { http, HttpResponse, passthrough } from 'msw';
|
|
|
|
export const bytedeskHandlers = [
|
|
// 未读消息数量
|
|
http.get('/bytedesk/visitor/api/v1/message/unread/count', () => {
|
|
return HttpResponse.json({
|
|
code: 200,
|
|
message: 'success',
|
|
data: { count: 0 },
|
|
});
|
|
}),
|
|
|
|
// 其他 Bytedesk API - 返回通用成功响应
|
|
http.all('/bytedesk/*', () => {
|
|
return HttpResponse.json({
|
|
code: 200,
|
|
message: 'success',
|
|
data: null,
|
|
});
|
|
}),
|
|
|
|
// Bytedesk 外部 CDN/服务请求
|
|
http.all('https://www.weiyuai.cn/*', () => {
|
|
return passthrough();
|
|
}),
|
|
];
|
|
|
|
export default bytedeskHandlers;
|