fix: 关闭验证码功能前端控制显示

This commit is contained in:
xingyu 2022-07-28 10:28:03 +08:00
parent 62dc600c51
commit 30836b0797
5 changed files with 38 additions and 16 deletions

View File

@ -24,6 +24,6 @@ export const updateUserPwdApi = (oldPassword: string, newPassword: string) => {
} }
// 用户头像上传 // 用户头像上传
export const uploadAvatarApi = (data) => { export const uploadAvatarApi = (params) => {
return request.put({ url: '/system/user/profile/update-avatar', data: data }) return request.upload({ url: '/system/user/profile/update-avatar', params })
} }

View File

@ -42,12 +42,19 @@ async function downloadFn<T = any>(option: AxiosConfig): Promise<T> {
return res as unknown as Promise<T> return res as unknown as Promise<T>
} }
async function uploadFn<T = any>(option: AxiosConfig): Promise<T> {
option.headersType = 'multipart/form-data'
const res = await request({ method: 'PUT', ...option })
return res as unknown as Promise<T>
}
export const useAxios = () => { export const useAxios = () => {
return { return {
get: getFn, get: getFn,
post: postFn, post: postFn,
delete: deleteFn, delete: deleteFn,
put: putFn, put: putFn,
download: downloadFn download: downloadFn,
upload: uploadFn
} }
} }

View File

@ -47,12 +47,17 @@ const iconHouse = useIcon({ icon: 'ep:house' })
const iconAvatar = useIcon({ icon: 'ep:avatar' }) const iconAvatar = useIcon({ icon: 'ep:avatar' })
const iconLock = useIcon({ icon: 'ep:lock' }) const iconLock = useIcon({ icon: 'ep:lock' })
const iconCircleCheck = useIcon({ icon: 'ep:circle-check' }) const iconCircleCheck = useIcon({ icon: 'ep:circle-check' })
const LoginRules = { const LoginCaptchaRules = {
tenantName: [required], tenantName: [required],
username: [required], username: [required],
password: [required], password: [required],
code: [required] code: [required]
} }
const LoginRules = {
tenantName: [required],
username: [required],
password: [required]
}
const loginLoading = ref(false) const loginLoading = ref(false)
const loginData = reactive({ const loginData = reactive({
codeImg: '', codeImg: '',
@ -76,8 +81,11 @@ const loginData = reactive({
// //
const getCode = async () => { const getCode = async () => {
const res = await LoginApi.getCodeImgApi() const res = await LoginApi.getCodeImgApi()
loginData.codeImg = 'data:image/gif;base64,' + res.img loginData.captchaEnable = res.enable
loginData.loginForm.uuid = res.uuid if (res.enable) {
loginData.codeImg = 'data:image/gif;base64,' + res.img
loginData.loginForm.uuid = res.uuid
}
} }
//ID //ID
const getTenantId = async () => { const getTenantId = async () => {
@ -159,7 +167,7 @@ onMounted(async () => {
<template> <template>
<el-form <el-form
:model="loginData.loginForm" :model="loginData.loginForm"
:rules="LoginRules" :rules="loginData.captchaEnable ? LoginCaptchaRules : LoginRules"
label-position="top" label-position="top"
class="login-form" class="login-form"
label-width="120px" label-width="120px"
@ -205,7 +213,7 @@ onMounted(async () => {
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24" style="padding-left: 10px; padding-right: 10px"> <el-col :span="24" style="padding-left: 10px; padding-right: 10px">
<el-form-item prop="code"> <el-form-item prop="code" v-if="loginData.captchaEnable">
<el-row justify="space-between" style="width: 100%"> <el-row justify="space-between" style="width: 100%">
<el-col :span="14"> <el-col :span="14">
<el-input <el-input

View File

@ -2,7 +2,7 @@
import { getUserProfileApi } from '@/api/system/user/profile' import { getUserProfileApi } from '@/api/system/user/profile'
import { onMounted, reactive } from 'vue' import { onMounted, reactive } from 'vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { UserAvatarVue } from './' import UserAvatar from './UserAvatar.vue'
import { ProfileVO } from '@/api/system/user/profile/types' import { ProfileVO } from '@/api/system/user/profile/types'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n() const { t } = useI18n()
@ -43,7 +43,7 @@ onMounted(async () => {
<template> <template>
<div> <div>
<div class="text-center"> <div class="text-center">
<UserAvatarVue :img="userInfo.user.avatar" /> <UserAvatar :img="userInfo.user.avatar" />
</div> </div>
<ul class="list-group list-group-striped"> <ul class="list-group list-group-striped">
<li class="list-group-item"> <li class="list-group-item">

View File

@ -2,7 +2,7 @@
import { ref, reactive, watch } from 'vue' import { ref, reactive, watch } from 'vue'
import 'vue-cropper/dist/index.css' import 'vue-cropper/dist/index.css'
import { VueCropper } from 'vue-cropper' import { VueCropper } from 'vue-cropper'
import { ElRow, ElCol, ElUpload, ElMessage } from 'element-plus' import { ElRow, ElCol, ElUpload, ElMessage, ElDialog } from 'element-plus'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { uploadAvatarApi } from '@/api/system/user/profile' import { uploadAvatarApi } from '@/api/system/user/profile'
const cropper = ref() const cropper = ref()
@ -43,6 +43,8 @@ const changeScale = (num: number) => {
num = num || 1 num = num || 1
cropper.value.changeScale(num) cropper.value.changeScale(num)
} }
//
const requestUpload = () => {}
/** 上传预处理 */ /** 上传预处理 */
const beforeUpload = (file: Blob) => { const beforeUpload = (file: Blob) => {
if (file.type.indexOf('image/') == -1) { if (file.type.indexOf('image/') == -1) {
@ -84,7 +86,7 @@ watch(
<div class="user-info-head" @click="editCropper()"> <div class="user-info-head" @click="editCropper()">
<img :src="state.options.img" title="点击上传头像" class="img-circle img-lg" alt="" /> <img :src="state.options.img" title="点击上传头像" class="img-circle img-lg" alt="" />
</div> </div>
<Dialog <el-dialog
v-model="state.dialogVisible" v-model="state.dialogVisible"
:title="state.dialogTitle" :title="state.dialogTitle"
width="50%" width="50%"
@ -92,7 +94,7 @@ watch(
style="padding: 30px 20px" style="padding: 30px 20px"
> >
<el-row> <el-row>
<el-col :xs="24" :md="12" :style="{ height: '350px' }"> <el-col :xs="24" :md="12" style="height: 350px">
<VueCropper <VueCropper
ref="cropper" ref="cropper"
:img="state.options.img" :img="state.options.img"
@ -105,7 +107,7 @@ watch(
v-if="state.cropperVisible" v-if="state.cropperVisible"
/> />
</el-col> </el-col>
<el-col :xs="24" :md="12" :style="{ height: '350px' }"> <el-col :xs="24" :md="12" style="height: 350px">
<div class="avatar-upload-preview"> <div class="avatar-upload-preview">
<img <img
:src="state.previews.url" :src="state.previews.url"
@ -119,7 +121,12 @@ watch(
<template #footer> <template #footer>
<el-row> <el-row>
<el-col :lg="2" :md="2"> <el-col :lg="2" :md="2">
<el-upload action="#" :show-file-list="false" :before-upload="beforeUpload"> <el-upload
action="#"
:http-request="requestUpload"
:show-file-list="false"
:before-upload="beforeUpload"
>
<el-button size="small"> <el-button size="small">
<Icon icon="ep:upload-filled" class="mr-5px" /> <Icon icon="ep:upload-filled" class="mr-5px" />
选择 选择
@ -151,7 +158,7 @@ watch(
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
</Dialog> </el-dialog>
</template> </template>
<style scoped> <style scoped>
.user-info-head { .user-info-head {