fix: 修复 MSW 接口和调试代码清理...

This commit is contained in:
zdl
2025-11-06 01:17:06 +08:00
parent ad933e9fb2
commit c5d6247f49
4 changed files with 27 additions and 23 deletions

View File

@@ -31,11 +31,11 @@ export async function startMockServiceWorker() {
try {
await worker.start({
// 🎯 严格模式(关键配置)
// 🎯 警告模式(关键配置)
// 'bypass': 未定义 Mock 的请求自动转发到真实后端
// 'warn': 未定义的请求会显示警告(调试用)
// 'error': 未定义的请求会抛出错误(严格模式)✅ 当前使用 穿透模式 bypass
onUnhandledRequest: 'error',
// 'warn': 未定义的请求会显示警告(调试用)✅ 当前使用(允许 passthrough
// 'error': 未定义的请求会抛出错误(严格模式,不允许 passthrough
onUnhandledRequest: 'warn',
// 自定义 Service Worker URL如果需要
serviceWorker: {
@@ -48,11 +48,11 @@ export async function startMockServiceWorker() {
isStarted = true;
console.log(
'%c[MSW] Mock Service Worker 已启动 🎭 严格模式)',
'%c[MSW] Mock Service Worker 已启动 🎭 警告模式)',
'color: #4CAF50; font-weight: bold; font-size: 14px;'
);
console.log(
'%c严格模式:已定义 Mock → 返回假数据 | 未定义 Mock → 控制台报错 ❌',
'%c警告模式:已定义 Mock → 返回假数据 | 未定义 Mock → 显示警告 ⚠️ | 允许 passthrough',
'color: #FF9800; font-weight: bold; font-size: 12px;'
);
console.log(