mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
perf: login
This commit is contained in:
parent
b908076a8b
commit
b7587db059
@ -155,22 +155,7 @@ import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
|||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useIcon } from '@/hooks/web/useIcon'
|
import { useIcon } from '@/hooks/web/useIcon'
|
||||||
import { required } from '@/utils/formRules'
|
import { required } from '@/utils/formRules'
|
||||||
import {
|
import * as authUtil from '@/utils/auth'
|
||||||
setToken,
|
|
||||||
setTenantId,
|
|
||||||
setUsername,
|
|
||||||
setPassword,
|
|
||||||
setRememberMe,
|
|
||||||
setTenantName,
|
|
||||||
removeUsername,
|
|
||||||
removePassword,
|
|
||||||
removeRememberMe,
|
|
||||||
removeTenantName,
|
|
||||||
getUsername,
|
|
||||||
getPassword,
|
|
||||||
getRememberMe,
|
|
||||||
getTenantName
|
|
||||||
} from '@/utils/auth'
|
|
||||||
import { decrypt } from '@/utils/jsencrypt'
|
import { decrypt } from '@/utils/jsencrypt'
|
||||||
import { Icon } from '@/components/Icon'
|
import { Icon } from '@/components/Icon'
|
||||||
import { Verify } from '@/components/Verifition'
|
import { Verify } from '@/components/Verifition'
|
||||||
@ -230,14 +215,16 @@ const getCode = async () => {
|
|||||||
//获取租户ID
|
//获取租户ID
|
||||||
const getTenantId = async () => {
|
const getTenantId = async () => {
|
||||||
const res = await LoginApi.getTenantIdByNameApi(loginData.loginForm.tenantName)
|
const res = await LoginApi.getTenantIdByNameApi(loginData.loginForm.tenantName)
|
||||||
setTenantId(res)
|
authUtil.setTenantId(res)
|
||||||
}
|
}
|
||||||
// 记住我
|
// 记住我
|
||||||
const getCookie = () => {
|
const getCookie = () => {
|
||||||
const username = getUsername()
|
const username = authUtil.getUsername()
|
||||||
const password = getPassword() ? decrypt(getPassword() as unknown as string) : undefined
|
const password = authUtil.getPassword()
|
||||||
const rememberMe = getRememberMe()
|
? decrypt(authUtil.getPassword() as unknown as string)
|
||||||
const tenantName = getTenantName()
|
: undefined
|
||||||
|
const rememberMe = authUtil.getRememberMe()
|
||||||
|
const tenantName = authUtil.getTenantName()
|
||||||
loginData.loginForm = {
|
loginData.loginForm = {
|
||||||
...loginData.loginForm,
|
...loginData.loginForm,
|
||||||
username: username ? username : loginData.loginForm.username,
|
username: username ? username : loginData.loginForm.username,
|
||||||
@ -266,17 +253,17 @@ const handleLogin = async (params) => {
|
|||||||
background: 'rgba(0, 0, 0, 0.7)'
|
background: 'rgba(0, 0, 0, 0.7)'
|
||||||
})
|
})
|
||||||
if (loginData.loginForm.rememberMe) {
|
if (loginData.loginForm.rememberMe) {
|
||||||
setUsername(loginData.loginForm.username)
|
authUtil.setUsername(loginData.loginForm.username)
|
||||||
setPassword(loginData.loginForm.password)
|
authUtil.setPassword(loginData.loginForm.password)
|
||||||
setRememberMe(loginData.loginForm.rememberMe)
|
authUtil.setRememberMe(loginData.loginForm.rememberMe)
|
||||||
setTenantName(loginData.loginForm.tenantName)
|
authUtil.setTenantName(loginData.loginForm.tenantName)
|
||||||
} else {
|
} else {
|
||||||
removeUsername()
|
authUtil.removeUsername()
|
||||||
removePassword()
|
authUtil.removePassword()
|
||||||
removeRememberMe()
|
authUtil.removeRememberMe()
|
||||||
removeTenantName()
|
authUtil.removeTenantName()
|
||||||
}
|
}
|
||||||
setToken(res)
|
authUtil.setToken(res)
|
||||||
if (!redirect.value) {
|
if (!redirect.value) {
|
||||||
redirect.value = '/'
|
redirect.value = '/'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user