From 1dbbc547fb801a61754c179517923f2ad8a4a3af Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 22 Apr 2025 09:19:19 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E6=88=90=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E4=B8=8A=E4=BC=A0=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/package.json | 1 + .../src/api/system/user/profile/index.ts | 12 +- .../src/components/cropper/cropper-avatar.vue | 170 ++++++++ .../src/components/cropper/cropper-modal.vue | 374 ++++++++++++++++++ .../src/components/cropper/cropper.vue | 197 +++++++++ apps/web-antd/src/components/cropper/index.ts | 3 + .../web-antd/src/components/cropper/typing.ts | 8 + .../_core/profile/modules/profile-user.vue | 33 +- .../_core/profile/modules/user-social.vue | 2 +- .../@core/base/shared/src/utils/download.ts | 19 + packages/locales/src/langs/en-US/ui.json | 15 + packages/locales/src/langs/zh-CN/ui.json | 15 + pnpm-lock.yaml | 11 + pnpm-workspace.yaml | 1 + 14 files changed, 839 insertions(+), 22 deletions(-) create mode 100644 apps/web-antd/src/components/cropper/cropper-avatar.vue create mode 100644 apps/web-antd/src/components/cropper/cropper-modal.vue create mode 100644 apps/web-antd/src/components/cropper/cropper.vue create mode 100644 apps/web-antd/src/components/cropper/index.ts create mode 100644 apps/web-antd/src/components/cropper/typing.ts diff --git a/apps/web-antd/package.json b/apps/web-antd/package.json index 827ff4744..629a9613a 100644 --- a/apps/web-antd/package.json +++ b/apps/web-antd/package.json @@ -43,6 +43,7 @@ "@tinymce/tinymce-vue": "catalog:", "@vueuse/core": "catalog:", "ant-design-vue": "catalog:", + "cropperjs": "catalog:", "crypto-js": "catalog:", "dayjs": "catalog:", "highlight.js": "catalog:", diff --git a/apps/web-antd/src/api/system/user/profile/index.ts b/apps/web-antd/src/api/system/user/profile/index.ts index c73a665d5..5a5083c1f 100644 --- a/apps/web-antd/src/api/system/user/profile/index.ts +++ b/apps/web-antd/src/api/system/user/profile/index.ts @@ -26,10 +26,11 @@ export namespace SystemUserProfileApi { /** 更新个人信息请求 */ export interface UpdateProfileReqVO { - nickname: string; + nickname?: string; email?: string; mobile?: string; sex?: number; + avatar?: string; } } @@ -46,11 +47,4 @@ export function updateUserProfile(data: SystemUserProfileApi.UpdateProfileReqVO) /** 修改用户个人密码 */ 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); -} +} \ No newline at end of file diff --git a/apps/web-antd/src/components/cropper/cropper-avatar.vue b/apps/web-antd/src/components/cropper/cropper-avatar.vue new file mode 100644 index 000000000..97947fbda --- /dev/null +++ b/apps/web-antd/src/components/cropper/cropper-avatar.vue @@ -0,0 +1,170 @@ + + + + + diff --git a/apps/web-antd/src/components/cropper/cropper-modal.vue b/apps/web-antd/src/components/cropper/cropper-modal.vue new file mode 100644 index 000000000..76dfa8aef --- /dev/null +++ b/apps/web-antd/src/components/cropper/cropper-modal.vue @@ -0,0 +1,374 @@ + + + + + diff --git a/apps/web-antd/src/components/cropper/cropper.vue b/apps/web-antd/src/components/cropper/cropper.vue new file mode 100644 index 000000000..caee6ed57 --- /dev/null +++ b/apps/web-antd/src/components/cropper/cropper.vue @@ -0,0 +1,197 @@ + + + + + diff --git a/apps/web-antd/src/components/cropper/index.ts b/apps/web-antd/src/components/cropper/index.ts new file mode 100644 index 000000000..a553b57d5 --- /dev/null +++ b/apps/web-antd/src/components/cropper/index.ts @@ -0,0 +1,3 @@ +export { default as CropperAvatar } from './cropper-avatar.vue'; +export { default as CropperImage } from './cropper.vue'; +export type { Cropper } from './typing'; diff --git a/apps/web-antd/src/components/cropper/typing.ts b/apps/web-antd/src/components/cropper/typing.ts new file mode 100644 index 000000000..e76cc6f8e --- /dev/null +++ b/apps/web-antd/src/components/cropper/typing.ts @@ -0,0 +1,8 @@ +import type Cropper from 'cropperjs'; + +export interface CropendResult { + imgBase64: string; + imgInfo: Cropper.Data; +} + +export type { Cropper }; 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 index d394bfaa8..5c4c86abc 100644 --- a/apps/web-antd/src/views/_core/profile/modules/profile-user.vue +++ b/apps/web-antd/src/views/_core/profile/modules/profile-user.vue @@ -1,42 +1,51 @@