重构:重构个人中心前端代码

This commit is contained in:
2023-02-04 16:20:35 +08:00
parent 35e2964b49
commit 86c4350de4
11 changed files with 265 additions and 270 deletions

View File

@@ -1,5 +1,7 @@
import axios from 'axios';
const BASE_URL = '/system/user/center';
export interface BasicInfoModel {
username: string;
nickname: string;
@@ -9,24 +11,27 @@ export interface BasicInfoModel {
export interface AvatarRes {
avatar: string;
}
export function uploadAvatar(data: FormData) {
return axios.post<AvatarRes>('/system/user/center/avatar', data);
return axios.post<AvatarRes>(`${BASE_URL}/avatar`, data);
}
export interface UpdateBasicInfoReq {
nickname: string;
gender: number;
}
export function updateBasicInfo(req: UpdateBasicInfoReq) {
return axios.patch('/system/user/center/basic/info', req);
return axios.patch(`${BASE_URL}/basic/info`, req);
}
export interface UpdatePasswordReq {
oldPassword: string;
newPassword: string;
}
export function updatePassword(req: UpdatePasswordReq) {
return axios.patch('/system/user/center/password', req);
return axios.patch(`${BASE_URL}/password`, req);
}
export interface UpdateEmailReq {
@@ -34,6 +39,7 @@ export interface UpdateEmailReq {
captcha: string;
currentPassword: string;
}
export function updateEmail(req: UpdateEmailReq) {
return axios.patch('/system/user/center/email', req);
return axios.patch(`${BASE_URL}/email`, req);
}