diff --git a/apps/web-antd/src/api/core/index.ts b/apps/web-antd/src/api/core/index.ts index a0032eb01..269586ee8 100644 --- a/apps/web-antd/src/api/core/index.ts +++ b/apps/web-antd/src/api/core/index.ts @@ -1,2 +1 @@ export * from './auth'; -export * from './user'; diff --git a/apps/web-antd/src/api/core/user.ts b/apps/web-antd/src/api/core/user.ts deleted file mode 100644 index 43d1fca40..000000000 --- a/apps/web-antd/src/api/core/user.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { UserInfo } from '@vben/types'; - -import { requestClient } from '#/api/request'; - -/** - * 获取用户信息 - */ -export async function getUserInfoApi() { - return requestClient.get('/system/user/profile/get'); -} diff --git a/apps/web-antd/src/api/system/user/profile/index.ts b/apps/web-antd/src/api/system/user/profile/index.ts new file mode 100644 index 000000000..ae3f77d98 --- /dev/null +++ b/apps/web-antd/src/api/system/user/profile/index.ts @@ -0,0 +1,63 @@ +import { requestClient } from '#/api/request'; + +export namespace SystemUserProfileApi { + /** 社交用户信息 */ + export interface SocialUser { + type: number; + openid: string; + } + + /** 用户个人中心信息 */ + export interface UserProfileRespVO { + id: number; + username: string; + nickname: string; + email?: string; + mobile?: string; + sex?: number; + avatar?: string; + loginIp: string; + loginDate: string; + createTime: string; + roles: any[]; + dept: any; + posts: any[]; + socialUsers: SocialUser[]; + } + + /** 更新密码请求 */ + export interface UpdatePasswordReqVO { + oldPassword: string; + newPassword: string; + } + + /** 更新个人信息请求 */ + export interface UpdateProfileReqVO { + nickname: string; + email?: string; + mobile?: string; + sex?: number; + } +} + +/** 获取登录用户信息 */ +export function getUserProfile() { + return requestClient.get('/system/user/profile/get'); +} + +/** 修改用户个人信息 */ +export function updateUserProfile(data: SystemUserProfileApi.UpdateProfileReqVO) { + return requestClient.put('/system/user/profile/update', data); +} + +/** 修改用户个人密码 */ +export function updateUserPassword(data: SystemUserProfileApi.UpdatePasswordReqVO) { + return requestClient.put('/system/user/profile/update-password', data); +} + +/** 上传用户个人头像 */ +export function updateUserAvatar(file: File) { + const formData = new FormData(); + formData.append('avatarFile', file); + return requestClient.put('/system/user/profile/update-avatar', formData); +} diff --git a/apps/web-antd/src/layouts/basic.vue b/apps/web-antd/src/layouts/basic.vue index 51b4b51ab..e61cd6792 100644 --- a/apps/web-antd/src/layouts/basic.vue +++ b/apps/web-antd/src/layouts/basic.vue @@ -6,7 +6,7 @@ import { computed, ref, watch } from 'vue'; import { AuthenticationLoginExpiredModal } from '@vben/common-ui'; import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants'; import { useWatermark } from '@vben/hooks'; -import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons'; +import { BookOpenText, CircleHelp, MdiGithub, AntdProfileOutlined } from '@vben/icons'; import { BasicLayout, LockScreen, @@ -20,6 +20,7 @@ import { openWindow } from '@vben/utils'; import { $t } from '#/locales'; import { useAuthStore } from '#/store'; import LoginForm from '#/views/_core/authentication/login.vue'; +import { router } from '#/router'; const notifications = ref([ { @@ -61,6 +62,13 @@ const showDot = computed(() => ); const menus = computed(() => [ + { + handler: () => { + router.push({ name: 'Profile' }); + }, + icon: AntdProfileOutlined, + text: $t('ui.widgets.profile'), + }, { handler: () => { openWindow(VBEN_DOC_URL, { diff --git a/apps/web-antd/src/router/routes/modules/dashboard.ts b/apps/web-antd/src/router/routes/modules/dashboard.ts index ff02d0c5b..2cccc8115 100644 --- a/apps/web-antd/src/router/routes/modules/dashboard.ts +++ b/apps/web-antd/src/router/routes/modules/dashboard.ts @@ -33,6 +33,16 @@ const routes: RouteRecordRaw[] = [ }, ], }, + { + name: 'Profile', + path: '/profile', + component: () => import('#/views/_core/profile/index.vue'), + meta: { + icon: 'ant-design:profile-outlined', + title: $t('ui.widgets.profile'), + hideInMenu: true, + }, + }, ]; export default routes; diff --git a/apps/web-antd/src/views/_core/profile/index.vue b/apps/web-antd/src/views/_core/profile/index.vue new file mode 100644 index 000000000..c74c17b09 --- /dev/null +++ b/apps/web-antd/src/views/_core/profile/index.vue @@ -0,0 +1,58 @@ + + + diff --git a/apps/web-antd/src/views/_core/profile/modules/profile-user.vue b/apps/web-antd/src/views/_core/profile/modules/profile-user.vue new file mode 100644 index 000000000..d394bfaa8 --- /dev/null +++ b/apps/web-antd/src/views/_core/profile/modules/profile-user.vue @@ -0,0 +1,116 @@ + + + diff --git a/packages/icons/src/iconify/index.ts b/packages/icons/src/iconify/index.ts index 967204cdc..48db12a4f 100644 --- a/packages/icons/src/iconify/index.ts +++ b/packages/icons/src/iconify/index.ts @@ -15,3 +15,5 @@ export const AntdDingTalk = createIconifyIcon('ant-design:dingtalk') export const MdiCheckboxMarkedCircleOutline = createIconifyIcon( 'mdi:checkbox-marked-circle-outline', ); + +export const AntdProfileOutlined = createIconifyIcon('ant-design:profile-outlined'); \ No newline at end of file diff --git a/packages/locales/src/langs/en-US/ui.json b/packages/locales/src/langs/en-US/ui.json index 6515bcd8c..76c7f5f23 100644 --- a/packages/locales/src/langs/en-US/ui.json +++ b/packages/locales/src/langs/en-US/ui.json @@ -77,6 +77,7 @@ }, "widgets": { "document": "Document", + "profile": "Profile", "qa": "Q&A", "setting": "Settings", "logoutTip": "Do you want to logout?", diff --git a/packages/locales/src/langs/zh-CN/ui.json b/packages/locales/src/langs/zh-CN/ui.json index 7f2a72cf3..1afc38853 100644 --- a/packages/locales/src/langs/zh-CN/ui.json +++ b/packages/locales/src/langs/zh-CN/ui.json @@ -77,6 +77,7 @@ }, "widgets": { "document": "文档", + "profile": "个人中心", "qa": "问题 & 帮助", "setting": "设置", "logoutTip": "是否退出登录?",