diff --git a/src/components/common/UserCenter.vue b/src/components/common/UserCenter.vue new file mode 100644 index 0000000..cfc8704 --- /dev/null +++ b/src/components/common/UserCenter.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/src/service/api/personal/index.ts b/src/service/api/personal/index.ts new file mode 100644 index 0000000..2fa9387 --- /dev/null +++ b/src/service/api/personal/index.ts @@ -0,0 +1,64 @@ +import { request } from '../../http' + +// 个人资料数据类型 +export interface PersonalDataVo { + userId: number + userName: string + loginName: string + email?: string + phone?: string + sex?: string + avatar?: string + userStatus?: string + createTime?: string +} + +// 修改个人资料请求类型 +export interface UpdatePersonalBo { + userName?: string + email?: string + phone?: string + sex?: string + avatar?: string +} + +// 修改密码请求类型 +export interface UpdatePasswordBo { + password: string + newPassword: string + confirmPassword: string +} + +/** + * 获取个人资料 + */ +export function getPersonalData() { + return request.Get>('/coder/sysLoginUser/getPersonalData') +} + +/** + * 修改个人基本资料 + */ +export function updateBasicData(data: UpdatePersonalBo) { + return request.Post>('/coder/sysLoginUser/updateBasicData', data) +} + +/** + * 修改登录密码 + */ +export function updatePassword(data: UpdatePasswordBo) { + return request.Post>('/coder/sysLoginUser/updateUserPwd', data) +} + +/** + * 上传头像文件 + * @param file 文件 + * @param fileSize 文件大小限制(MB) + */ +export function uploadAvatar(file: File, fileSize: number = 5) { + const formData = new FormData() + formData.append('file', file) + // 注意:不要手动设置 Content-Type,让浏览器自动设置以包含正确的 boundary + // 使用数字标识符 "1" 代表头像类型,避免数据库字段长度限制 + return request.Post>(`/coder/file/uploadFile/${fileSize}/pictures/1`, formData) +}