|
@ -1,14 +1,6 @@ |
|
|
<template> |
|
|
<template> |
|
|
<el-form |
|
|
<el-form v-show="getShow" ref="formLogin" :model="loginData.loginForm" :rules="LoginRules" class="login-form" |
|
|
v-show="getShow" |
|
|
label-position="top" label-width="120px" size="large"> |
|
|
ref="formLogin" |
|
|
|
|
|
:model="loginData.loginForm" |
|
|
|
|
|
:rules="LoginRules" |
|
|
|
|
|
class="login-form" |
|
|
|
|
|
label-position="top" |
|
|
|
|
|
label-width="120px" |
|
|
|
|
|
size="large" |
|
|
|
|
|
> |
|
|
|
|
|
<el-row style="margin-right: -10px; margin-left: -10px"> |
|
|
<el-row style="margin-right: -10px; margin-left: -10px"> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
@ -17,40 +9,53 @@ |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-form-item v-if="loginData.tenantEnable === 'true'" prop="tenantName"> |
|
|
<el-form-item v-if="loginData.tenantEnable === 'true'" prop="tenantName"> |
|
|
<el-input |
|
|
<el-input v-model="loginData.loginForm.tenantName" :placeholder="t('login.tenantNamePlaceholder')" |
|
|
v-model="loginData.loginForm.tenantName" |
|
|
:prefix-icon="iconHouse" link type="primary" /> |
|
|
:placeholder="t('login.tenantNamePlaceholder')" |
|
|
|
|
|
:prefix-icon="iconHouse" |
|
|
|
|
|
link |
|
|
|
|
|
type="primary" |
|
|
|
|
|
/> |
|
|
|
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-form-item prop="username"> |
|
|
<el-form-item prop="username"> |
|
|
<el-input |
|
|
<el-input v-model="loginData.loginForm.username" :placeholder="t('login.usernamePlaceholder')" |
|
|
v-model="loginData.loginForm.username" |
|
|
:prefix-icon="iconAvatar" /> |
|
|
:placeholder="t('login.usernamePlaceholder')" |
|
|
|
|
|
:prefix-icon="iconAvatar" |
|
|
|
|
|
/> |
|
|
|
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-form-item prop="password"> |
|
|
<el-form-item prop="password"> |
|
|
<el-input |
|
|
<el-input v-model="loginData.loginForm.password" :placeholder="t('login.passwordPlaceholder')" |
|
|
v-model="loginData.loginForm.password" |
|
|
:prefix-icon="iconLock" show-password type="password" @keyup.enter="getCode()" /> |
|
|
:placeholder="t('login.passwordPlaceholder')" |
|
|
|
|
|
:prefix-icon="iconLock" |
|
|
|
|
|
show-password |
|
|
|
|
|
type="password" |
|
|
|
|
|
@keyup.enter="getCode()" |
|
|
|
|
|
/> |
|
|
|
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<el-col |
|
|
<!-- <el-col :span="24" style="padding-right: 10px; padding-left: 10px; margin-top: -20px; margin-bottom: -20px"> |
|
|
:span="24" |
|
|
<el-form-item prop="code" v-if="captchaEnabled"> |
|
|
style="padding-right: 10px; padding-left: 10px; margin-top: -20px; margin-bottom: -20px" |
|
|
<div class="label"> |
|
|
> |
|
|
<svg-icon icon-class="icon_safe" class="el-input__icon input-icon" /> |
|
|
|
|
|
<div>验证码</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div> |
|
|
|
|
|
<el-input v-model="loginData.loginForm.password" :placeholder="t('login.passwordPlaceholder')" |
|
|
|
|
|
:prefix-icon="iconLock" show-password type="password" @keyup.enter="getCode()" /> |
|
|
|
|
|
<div class="login-code"> |
|
|
|
|
|
<img :src="codeUrl" @click="getCode" class="login-code-img" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-col> --> |
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
|
|
|
<el-form-item prop="code"> |
|
|
|
|
|
<div class="flex"> |
|
|
|
|
|
<el-input v-model="loginData.loginForm.code" placeholder="请输入验证码" style="width: 320px;" |
|
|
|
|
|
:prefix-icon="iconLock" show-password type="password" @keyup.enter="getCode()"/> |
|
|
|
|
|
<div class="login-code flex-1"> |
|
|
|
|
|
<img :src="codeUrl" @click="getCode" class="login-code-img" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-col> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px; margin-top: -20px; margin-bottom: -20px"> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<el-row justify="space-between" style="width: 100%"> |
|
|
<el-row justify="space-between" style="width: 100%"> |
|
|
<el-col :span="6"> |
|
|
<el-col :span="6"> |
|
@ -64,24 +69,20 @@ |
|
|
</el-row> |
|
|
</el-row> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
|
|
|
|
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<XButton |
|
|
<XButton :loading="loginLoading" :title="t('login.login')" class="w-[100%]" type="primary" |
|
|
:loading="loginLoading" |
|
|
@click="handleLogin()" /> |
|
|
:title="t('login.login')" |
|
|
|
|
|
class="w-[100%]" |
|
|
|
|
|
type="primary" |
|
|
|
|
|
@click="getCode()" |
|
|
|
|
|
/> |
|
|
|
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-col> |
|
|
</el-col> |
|
|
<Verify |
|
|
<!-- <Verify |
|
|
ref="verify" |
|
|
ref="verify" |
|
|
:captchaType="captchaType" |
|
|
:captchaType="captchaType" |
|
|
:imgSize="{ width: '400px', height: '200px' }" |
|
|
:imgSize="{ width: '400px', height: '200px' }" |
|
|
mode="pop" |
|
|
mode="pop" |
|
|
@success="handleLogin" |
|
|
@success="handleLogin" |
|
|
/> |
|
|
/> --> |
|
|
</el-row> |
|
|
</el-row> |
|
|
</el-form> |
|
|
</el-form> |
|
|
</template> |
|
|
</template> |
|
@ -96,6 +97,7 @@ import * as authUtil from '@/utils/auth' |
|
|
import { usePermissionStore } from '@/store/modules/permission' |
|
|
import { usePermissionStore } from '@/store/modules/permission' |
|
|
import * as LoginApi from '@/api/login' |
|
|
import * as LoginApi from '@/api/login' |
|
|
import { LoginStateEnum, useFormValid, useLoginState } from './useLogin' |
|
|
import { LoginStateEnum, useFormValid, useLoginState } from './useLogin' |
|
|
|
|
|
import { getCodeImg } from "@/api/login"; |
|
|
|
|
|
|
|
|
defineOptions({ name: 'LoginForm' }) |
|
|
defineOptions({ name: 'LoginForm' }) |
|
|
|
|
|
|
|
@ -115,6 +117,9 @@ const verify = ref() |
|
|
const captchaType = ref('blockPuzzle') // blockPuzzle 滑块 clickWord 点击文字 |
|
|
const captchaType = ref('blockPuzzle') // blockPuzzle 滑块 clickWord 点击文字 |
|
|
|
|
|
|
|
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) |
|
|
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) |
|
|
|
|
|
// 验证码开关 |
|
|
|
|
|
const captchaEnabled = ref(true); |
|
|
|
|
|
const codeUrl = ref(""); |
|
|
|
|
|
|
|
|
const LoginRules = { |
|
|
const LoginRules = { |
|
|
tenantName: [required], |
|
|
tenantName: [required], |
|
@ -130,7 +135,8 @@ const loginData = reactive({ |
|
|
username: 'admin', |
|
|
username: 'admin', |
|
|
password: 'admin123', |
|
|
password: 'admin123', |
|
|
captchaVerification: '', |
|
|
captchaVerification: '', |
|
|
rememberMe: false |
|
|
rememberMe: false, |
|
|
|
|
|
code:'' |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
@ -142,15 +148,24 @@ const socialList = [ |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
// 获取验证码 |
|
|
// 获取验证码 |
|
|
const getCode = async () => { |
|
|
// const getCode = async () => { |
|
|
// 情况一,未开启:则直接登录 |
|
|
// // 情况一,未开启:则直接登录 |
|
|
if (loginData.captchaEnable === 'false') { |
|
|
// if (loginData.captchaEnable === 'false') { |
|
|
await handleLogin({}) |
|
|
// await handleLogin({}) |
|
|
} else { |
|
|
// } else { |
|
|
// 情况二,已开启:则展示验证码;只有完成验证码的情况,才进行登录 |
|
|
// // 情况二,已开启:则展示验证码;只有完成验证码的情况,才进行登录 |
|
|
// 弹出验证码 |
|
|
// // 弹出验证码 |
|
|
verify.value.show() |
|
|
// verify.value.show() |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
function getCode() { |
|
|
|
|
|
getCodeImg().then(res => { |
|
|
|
|
|
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; |
|
|
|
|
|
if (captchaEnabled.value) { |
|
|
|
|
|
codeUrl.value = "data:image/gif;base64," + res.img; |
|
|
|
|
|
loginForm.value.uuid = res.uuid; |
|
|
} |
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
//获取租户ID |
|
|
//获取租户ID |
|
|
const getTenantId = async () => { |
|
|
const getTenantId = async () => { |
|
@ -243,6 +258,7 @@ watch( |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
|
|
|
getCode(); |
|
|
getCookie() |
|
|
getCookie() |
|
|
}) |
|
|
}) |
|
|
</script> |
|
|
</script> |
|
|