perf: login

pull/2/head
xingyu4j 2022-11-23 11:45:57 +08:00
parent 266a132565
commit bf12cb89df
1 changed files with 34 additions and 28 deletions

View File

@ -104,29 +104,29 @@
<div class="flex justify-between w-[100%]"> <div class="flex justify-between w-[100%]">
<Icon <Icon
icon="ant-design:github-filled" icon="ant-design:github-filled"
:size="iconSize" :size="30"
class="cursor-pointer anticon" class="cursor-pointer anticon"
:color="iconColor" color="#999"
@click="doSocialLogin('github')" @click="doSocialLogin('github')"
/> />
<Icon <Icon
icon="ant-design:wechat-filled" icon="ant-design:wechat-filled"
:size="iconSize" :size="30"
class="cursor-pointer anticon" class="cursor-pointer anticon"
:color="iconColor" color="#999"
@click="doSocialLogin('wechat')" @click="doSocialLogin('wechat')"
/> />
<Icon <Icon
icon="ant-design:alipay-circle-filled" icon="ant-design:alipay-circle-filled"
:size="iconSize" :size="30"
:color="iconColor" color="#999"
class="cursor-pointer anticon" class="cursor-pointer anticon"
@click="doSocialLogin('alipay')" @click="doSocialLogin('alipay')"
/> />
<Icon <Icon
icon="ant-design:dingtalk-circle-filled" icon="ant-design:dingtalk-circle-filled"
:size="iconSize" :size="30"
:color="iconColor" color="#999"
class="cursor-pointer anticon" class="cursor-pointer anticon"
@click="doSocialLogin('dingtalk')" @click="doSocialLogin('dingtalk')"
/> />
@ -165,19 +165,21 @@ import * as LoginApi from '@/api/login'
import { LoginStateEnum, useLoginState, useFormValid } from './useLogin' import { LoginStateEnum, useLoginState, useFormValid } from './useLogin'
const { t } = useI18n() const { t } = useI18n()
const iconHouse = useIcon({ icon: 'ep:house' })
const iconAvatar = useIcon({ icon: 'ep:avatar' })
const iconLock = useIcon({ icon: 'ep:lock' })
const { currentRoute, push } = useRouter()
const permissionStore = usePermissionStore()
const formLogin = ref() const formLogin = ref()
const { validForm } = useFormValid(formLogin) const { validForm } = useFormValid(formLogin)
const { setLoginState, getLoginState } = useLoginState() const { setLoginState, getLoginState } = useLoginState()
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) const { currentRoute, push } = useRouter()
const iconSize = 30 const permissionStore = usePermissionStore()
const iconColor = '#999'
const redirect = ref<string>('') const redirect = ref<string>('')
const loginLoading = ref(false) const loginLoading = ref(false)
const iconHouse = useIcon({ icon: 'ep:house' })
const iconAvatar = useIcon({ icon: 'ep:avatar' })
const iconLock = useIcon({ icon: 'ep:lock' })
const verify = ref()
const captchaType = ref('blockPuzzle') // blockPuzzle clickWord
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN)
const LoginRules = { const LoginRules = {
tenantName: [required], tenantName: [required],
username: [required], username: [required],
@ -192,26 +194,26 @@ const loginData = reactive({
signIn: false signIn: false
}, },
loginForm: { loginForm: {
tenantName: '芋道源码', tenantName: Cookies.get('tenantName') ? Cookies.get('tenantName') : '芋道源码',
username: 'admin', username: Cookies.get('username') ? Cookies.get('username') : 'admin',
password: 'admin123', password: Cookies.get('password')
? (decrypt(Cookies.get('password')) as unknown as string)
: 'admin123',
captchaVerification: '', captchaVerification: '',
rememberMe: false rememberMe: false
} }
}) })
// blockPuzzle clickWord
const verify = ref()
const captchaType = ref('blockPuzzle')
// //
const getCode = async () => { const getCode = async () => {
// //
if (loginData.captchaEnable === 'false') { if (loginData.captchaEnable === 'false') {
await handleLogin({}) await handleLogin({})
return } else {
}
// //
// //
verify.value.show() verify.value.show()
}
} }
//ID //ID
const getTenantId = async () => { const getTenantId = async () => {
@ -221,7 +223,9 @@ const getTenantId = async () => {
// //
const getCookie = () => { const getCookie = () => {
const username = Cookies.get('username') const username = Cookies.get('username')
const password = Cookies.get('password') ? decrypt(Cookies.get('password')) : undefined const password = Cookies.get('password')
? (decrypt(Cookies.get('password')) as unknown as string)
: undefined
const rememberMe = Cookies.get('rememberMe') const rememberMe = Cookies.get('rememberMe')
const tenantName = Cookies.get('tenantName') const tenantName = Cookies.get('tenantName')
loginData.loginForm = { loginData.loginForm = {
@ -253,7 +257,9 @@ const handleLogin = async (params) => {
}) })
if (loginData.loginForm.rememberMe) { if (loginData.loginForm.rememberMe) {
Cookies.set('username', loginData.loginForm.username, { expires: 30 }) Cookies.set('username', loginData.loginForm.username, { expires: 30 })
Cookies.set('password', encrypt(loginData.loginForm.password), { expires: 30 }) Cookies.set('password', encrypt(loginData.loginForm.password as unknown as string), {
expires: 30
})
Cookies.set('rememberMe', loginData.loginForm.rememberMe, { expires: 30 }) Cookies.set('rememberMe', loginData.loginForm.rememberMe, { expires: 30 })
Cookies.set('tenantName', loginData.loginForm.tenantName, { expires: 30 }) Cookies.set('tenantName', loginData.loginForm.tenantName, { expires: 30 })
} else { } else {