重构:重构登录页面前端代码

This commit is contained in:
2023-02-04 13:16:41 +08:00
parent d035d5a362
commit 35e2964b49
3 changed files with 95 additions and 114 deletions

View File

@@ -2,25 +2,29 @@ import axios from 'axios';
import type { RouteRecordNormalized } from 'vue-router';
import { UserState } from '@/store/modules/login/types';
const BASE_URL = '/auth';
export interface LoginReq {
username: string;
password: string;
captcha: string;
uuid: string;
}
export interface LoginRes {
token: string;
}
export function login(req: LoginReq) {
return axios.post<LoginRes>('/auth/login', req);
return axios.post<LoginRes>(`${BASE_URL}/login`, req);
}
export function logout() {
return axios.post('/auth/logout');
return axios.post(`${BASE_URL}/logout`);
}
export function getUserInfo() {
return axios.get<UserState>('/auth/user/info');
return axios.get<UserState>(`${BASE_URL}/user/info`);
}
export function getMenuList() {