import { NextRequest, NextResponse } from 'next/server'

export async function POST(request: NextRequest) {
  try {
    const body = await request.json()
    const { email, password } = body

    // 模拟延迟
    await new Promise((resolve) => setTimeout(resolve, 1000))

    // 简单的登录验证
    if (email === 'user@example.com' && password === 'password') {
      return NextResponse.json({
        token: 'mock-jwt-token-12345',
        user: {
          id: '1',
          email: 'user@example.com',
          name: '张三',
        },
      })
    }

    return NextResponse.json({ error: '邮箱或密码错误' }, { status: 401 })
  } catch (error) {
    return NextResponse.json({ error: '服务器错误' }, { status: 500 })
  }
}
