mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
fix: 关闭验证码功能前端控制显示
This commit is contained in:
parent
62dc600c51
commit
30836b0797
@ -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 })
|
||||
}
|
||||
|
@ -42,12 +42,19 @@ async function downloadFn<T = any>(option: AxiosConfig): 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 = () => {
|
||||
return {
|
||||
get: getFn,
|
||||
post: postFn,
|
||||
delete: deleteFn,
|
||||
put: putFn,
|
||||
download: downloadFn
|
||||
download: downloadFn,
|
||||
upload: uploadFn
|
||||
}
|
||||
}
|
||||
|
@ -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 () => {
|
||||
<template>
|
||||
<el-form
|
||||
:model="loginData.loginForm"
|
||||
:rules="LoginRules"
|
||||
:rules="loginData.captchaEnable ? LoginCaptchaRules : LoginRules"
|
||||
label-position="top"
|
||||
class="login-form"
|
||||
label-width="120px"
|
||||
@ -205,7 +213,7 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<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-col :span="14">
|
||||
<el-input
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { getUserProfileApi } from '@/api/system/user/profile'
|
||||
import { onMounted, reactive } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
import { UserAvatarVue } from './'
|
||||
import UserAvatar from './UserAvatar.vue'
|
||||
import { ProfileVO } from '@/api/system/user/profile/types'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
const { t } = useI18n()
|
||||
@ -43,7 +43,7 @@ onMounted(async () => {
|
||||
<template>
|
||||
<div>
|
||||
<div class="text-center">
|
||||
<UserAvatarVue :img="userInfo.user.avatar" />
|
||||
<UserAvatar :img="userInfo.user.avatar" />
|
||||
</div>
|
||||
<ul class="list-group list-group-striped">
|
||||
<li class="list-group-item">
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { ref, reactive, watch } from 'vue'
|
||||
import 'vue-cropper/dist/index.css'
|
||||
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 { uploadAvatarApi } from '@/api/system/user/profile'
|
||||
const cropper = ref()
|
||||
@ -43,6 +43,8 @@ const changeScale = (num: number) => {
|
||||
num = num || 1
|
||||
cropper.value.changeScale(num)
|
||||
}
|
||||
// 覆盖默认的上传行为
|
||||
const requestUpload = () => {}
|
||||
/** 上传预处理 */
|
||||
const beforeUpload = (file: Blob) => {
|
||||
if (file.type.indexOf('image/') == -1) {
|
||||
@ -84,7 +86,7 @@ watch(
|
||||
<div class="user-info-head" @click="editCropper()">
|
||||
<img :src="state.options.img" title="点击上传头像" class="img-circle img-lg" alt="" />
|
||||
</div>
|
||||
<Dialog
|
||||
<el-dialog
|
||||
v-model="state.dialogVisible"
|
||||
:title="state.dialogTitle"
|
||||
width="50%"
|
||||
@ -92,7 +94,7 @@ watch(
|
||||
style="padding: 30px 20px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||
<el-col :xs="24" :md="12" style="height: 350px">
|
||||
<VueCropper
|
||||
ref="cropper"
|
||||
:img="state.options.img"
|
||||
@ -105,7 +107,7 @@ watch(
|
||||
v-if="state.cropperVisible"
|
||||
/>
|
||||
</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">
|
||||
<img
|
||||
:src="state.previews.url"
|
||||
@ -119,7 +121,12 @@ watch(
|
||||
<template #footer>
|
||||
<el-row>
|
||||
<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">
|
||||
<Icon icon="ep:upload-filled" class="mr-5px" />
|
||||
选择
|
||||
@ -151,7 +158,7 @@ watch(
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</Dialog>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<style scoped>
|
||||
.user-info-head {
|
||||
|
Loading…
Reference in New Issue
Block a user