From 2c5e2234d8a21b900d7521f573eb7e20ba3e601b Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Sun, 6 Jul 2025 22:09:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(personal):=20=E6=96=B0=E5=A2=9E=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=B8=AD=E5=BF=83=E6=A0=B8=E5=BF=83=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加UserCenter用户头像下拉菜单组件 - 新增个人信息相关API接口封装 - 提供完整的个人信息管理功能接口 --- src/components/common/UserCenter.vue | 112 +++++++++++++++++++++++++++ src/service/api/personal/index.ts | 64 +++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 src/components/common/UserCenter.vue create mode 100644 src/service/api/personal/index.ts 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 @@ + + + + { + if (key === 'personal-center') { + handlePersonalCenter() + } + else if (key === 'logout') { + handleLogout() + } + }" + > + + + + + + + + + + + {{ displayName }} + + + + + + + + + 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) +}