20 lines
584 B
TypeScript
20 lines
584 B
TypeScript
|
|
import http from '@/utils/http'
|
|||
|
|
import type { ApiResponse, LoginParams } from '@/types'
|
|||
|
|
import type { AxiosResponse } from 'axios'
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 用户登录
|
|||
|
|
*/
|
|||
|
|
export const login = (params: LoginParams): Promise<AxiosResponse<ApiResponse<{
|
|||
|
|
token: string
|
|||
|
|
userInfo: any
|
|||
|
|
}>>> => {
|
|||
|
|
// 创建FormData对象
|
|||
|
|
const formData = new FormData()
|
|||
|
|
formData.append('username', params.username)
|
|||
|
|
formData.append('password', params.password)
|
|||
|
|
// 添加rememberMe参数,默认为true
|
|||
|
|
formData.append('rememberMe', String(params.rememberMe ?? true))
|
|||
|
|
|
|||
|
|
return http.post('/login', formData)
|
|||
|
|
}
|