perf: perf axios config

This commit is contained in:
kailong321200875
2022-06-25 20:04:58 +08:00
parent 1878c2ede7
commit 39edd84023
5 changed files with 49 additions and 31 deletions

View File

@@ -1,13 +1,15 @@
import { useAxios } from '@/hooks/web/useAxios'
import type { UserLoginType, UserType } from './types'
import type { UserType } from './types'
import { IUserModel } from '@/api-types/user'
const request = useAxios()
export const loginApi = (data: UserLoginType) => {
return request.post({
export const loginApi = async (data: Pick<IUserModel, 'user_name' | 'password'>) => {
const res = await request.post<IResponse<IUserModel>>({
url: '/user/login',
data
})
return res && res.data
}
export const loginOutApi = () => {

View File

@@ -8,12 +8,14 @@ interface ICodeModel {
uuid: string
}
export const getCodeApi = async () => {
const res = await request.get<IResponse<ICodeModel>>({ url: 'user/captcha' })
export const getCodeApi = async (): Promise<IResponse<ICodeModel>> => {
const res = await request.get({ url: 'user/captcha' })
return res && res.data
}
export const registerApi = async (data: Omit<IUserModel, 'is_admin'>) => {
const res = await request.post<IResponse<IUserModel>>({ url: 'user/register', data })
export const registerApi = async (
data: Omit<IUserModel, 'is_admin'>
): Promise<IResponse<IUserModel>> => {
const res = await request.post({ url: 'user/register', data })
return res && res.data
}