From 30836b07973a9587d62ead920943acf0d513ac7e Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 28 Jul 2022 10:28:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=B3=E9=97=AD=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E5=8A=9F=E8=83=BD=E5=89=8D=E7=AB=AF=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/system/user/profile/index.ts | 4 ++-- yudao-ui-admin-vue3/src/hooks/web/useAxios.ts | 9 ++++++++- .../src/views/Login/components/LoginForm.vue | 18 +++++++++++++----- .../views/Profile/components/ProfileUser.vue | 4 ++-- .../views/Profile/components/UserAvatar.vue | 19 +++++++++++++------ 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/yudao-ui-admin-vue3/src/api/system/user/profile/index.ts b/yudao-ui-admin-vue3/src/api/system/user/profile/index.ts index bf3d322f1..a5a24490f 100644 --- a/yudao-ui-admin-vue3/src/api/system/user/profile/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/user/profile/index.ts @@ -24,6 +24,6 @@ export const updateUserPwdApi = (oldPassword: string, newPassword: string) => { } // 用户头像上传 -export const uploadAvatarApi = (data) => { - return request.put({ url: '/system/user/profile/update-avatar', data: data }) +export const uploadAvatarApi = (params) => { + return request.upload({ url: '/system/user/profile/update-avatar', params }) } diff --git a/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts b/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts index f8aacd087..331969c6e 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useAxios.ts @@ -42,12 +42,19 @@ async function downloadFn(option: AxiosConfig): Promise { return res as unknown as Promise } +async function uploadFn(option: AxiosConfig): Promise { + option.headersType = 'multipart/form-data' + const res = await request({ method: 'PUT', ...option }) + return res as unknown as Promise +} + export const useAxios = () => { return { get: getFn, post: postFn, delete: deleteFn, put: putFn, - download: downloadFn + download: downloadFn, + upload: uploadFn } } diff --git a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue index e65e0ca22..bb876e0a3 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue +++ b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue @@ -47,12 +47,17 @@ const iconHouse = useIcon({ icon: 'ep:house' }) const iconAvatar = useIcon({ icon: 'ep:avatar' }) const iconLock = useIcon({ icon: 'ep:lock' }) const iconCircleCheck = useIcon({ icon: 'ep:circle-check' }) -const LoginRules = { +const LoginCaptchaRules = { tenantName: [required], username: [required], password: [required], code: [required] } +const LoginRules = { + tenantName: [required], + username: [required], + password: [required] +} const loginLoading = ref(false) const loginData = reactive({ codeImg: '', @@ -76,8 +81,11 @@ const loginData = reactive({ // 获取验证码 const getCode = async () => { const res = await LoginApi.getCodeImgApi() - loginData.codeImg = 'data:image/gif;base64,' + res.img - loginData.loginForm.uuid = res.uuid + loginData.captchaEnable = res.enable + if (res.enable) { + loginData.codeImg = 'data:image/gif;base64,' + res.img + loginData.loginForm.uuid = res.uuid + } } //获取租户ID const getTenantId = async () => { @@ -159,7 +167,7 @@ onMounted(async () => {