perf: login

This commit is contained in:
xingyu4j 2022-11-23 11:45:57 +08:00
parent 266a132565
commit bf12cb89df

View File

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