export async function enableMocking() {
  // 只在开发环境启用 mock
  if (process.env.NODE_ENV !== 'development') {
    return
  }

  // 检查是否启用 mock
  const shouldMock = process.env.NEXT_PUBLIC_ENABLE_MOCK === 'true'

  console.log('shouldMock', shouldMock)
  if (!shouldMock) {
    return
  }

  if (typeof window === 'undefined') {
    // 服务端环境
    const { server } = await import('./server')
    server.listen({
      onUnhandledRequest: 'bypass',
    })
  } else {
    // 客户端环境
    const { worker } = await import('./browser')
    await worker.start({
      onUnhandledRequest: 'bypass',
    })
  }
}
