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 () => {