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
|
|
|
|
|
}>>> => {
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('username', params.username)
|
|
|
|
|
formData.append('password', params.password)
|
|
|
|
|
formData.append('rememberMe', String(params.rememberMe ?? true))
|
2026-06-03 09:27:53 +00:00
|
|
|
|
|
|
|
|
if (params.validateCode) {
|
|
|
|
|
formData.append('validateCode', params.validateCode)
|
|
|
|
|
}
|
2025-08-28 07:37:34 +00:00
|
|
|
|
|
|
|
|
return http.post('/login', formData)
|
2025-12-01 08:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-23 07:57:36 +00:00
|
|
|
/**
|
|
|
|
|
* 获取用户信息
|
|
|
|
|
*/
|
|
|
|
|
export const getInfo = (): Promise<AxiosResponse<ApiResponse<any>>> => {
|
|
|
|
|
return http.get('/getInfo')
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|