2025-08-28 07:37:34 +00:00
|
|
|
|
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)
|
2025-12-01 08:25:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用户退出登录
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const logout = (): Promise<AxiosResponse<ApiResponse<any>>> => {
|
|
|
|
|
|
return http.post('/logout')
|
2025-08-28 07:37:34 +00:00
|
|
|
|
}
|