| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import http from '@/api'
- import type { BaseEntity } from '@/typings/api'
- export interface UserInfo extends BaseEntity {
- name: string
- sex: number
- username: string
- avatar: string
- email: string
- phone: string
- }
- export interface LoginForm {
- username: string
- password: string
- code: string
- uuid: string
- }
- export interface AuthResponse {
- accessToken: string
- refreshToken: string
- expiresIn: number
- tokenType: string
- scope: string[]
- }
- export interface VerificationCode {
- img: string
- uuid: string
- }
- /**
- * 登录
- * @param loginForm
- */
- export const login = (loginForm: LoginForm) => {
- return http.post<AuthResponse>('/auth/login', loginForm)
- }
- /**
- * 退出
- */
- export const logout = () => {
- return http.post<null>('/auth/logout')
- }
- /**
- * 刷新token
- */
- export const refreshToken = () => {
- return http.post<AuthResponse>('/auth/refresh')
- }
- /**
- * 获取验证码
- */
- export const getCodeImg = () => {
- return http.get<VerificationCode>('/auth/code')
- }
- /**
- * 获取用户信息
- */
- export const getInfo = () => {
- return http.get<UserInfo>('/auth/info')
- }
|