perf: login
parent
266a132565
commit
bf12cb89df
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue