Files
aitsc/vue-app/src/api/modules/auth.ts

29 lines
844 B
TypeScript
Raw Normal View History

import client from '../client'
import type { LoginResponse, LogoutResponse, RegisterResponse } from '../types/auth'
import type { CheckLoginResponse } from '../types/user'
export function checkLogin() {
return client.get<CheckLoginResponse>('/api/check-login').then((r) => r.data)
}
export function postLogin(login_name: string, login_pwd: string) {
return client.post<LoginResponse>('/api/login', { login_name, login_pwd }).then((r) => r.data)
}
export function postLogout() {
return client.post<LogoutResponse>('/api/logout', {}).then((r) => r.data)
}
export interface RegisterBody {
login_name: string
login_pwd: string
nickname: string
email?: string
mobile?: string
sex?: number
}
export function postRegister(body: RegisterBody) {
return client.post<RegisterResponse>('/api/register', body).then((r) => r.data)
}