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 @@