Refactor(Navigate): Optimize navigate
Unified management navigation
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
PERMISSION_USER_NOT_FOUND,
|
||||
SYSTEM_INVALID_CAPTCHA_CODE
|
||||
} from '@/constants/common.constants'
|
||||
import { navigateToLogin } from '@/util/navigation'
|
||||
import { r_auth_forget, r_auth_retrieve } from '@/services/auth'
|
||||
import FitCenter from '@/components/common/FitCenter'
|
||||
import FlexBox from '@/components/common/FlexBox'
|
||||
@@ -272,7 +273,15 @@ const Forget = () => {
|
||||
|
||||
<div className={'footer'}>
|
||||
找到了?
|
||||
<a onClick={() => navigate(`/login`, { replace: true })}>登录</a>
|
||||
<a
|
||||
onClick={() =>
|
||||
navigateToLogin(navigate, undefined, undefined, {
|
||||
replace: true
|
||||
})
|
||||
}
|
||||
>
|
||||
登录
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</FlexBox>
|
||||
|
||||
@@ -12,6 +12,12 @@ import {
|
||||
} from '@/constants/common.constants'
|
||||
import { getUserInfo, setToken } from '@/util/auth'
|
||||
import { utcToLocalTime } from '@/util/datetime'
|
||||
import {
|
||||
navigateToForget,
|
||||
navigateToRedirect,
|
||||
navigateToRegister,
|
||||
navigateToRoot
|
||||
} from '@/util/navigation'
|
||||
import { r_auth_login } from '@/services/auth'
|
||||
import { AppContext } from '@/App'
|
||||
import FitCenter from '@/components/common/FitCenter'
|
||||
@@ -78,7 +84,7 @@ const SignIn = () => {
|
||||
setTimeout(() => {
|
||||
void getUserInfo().then((user) => {
|
||||
refreshRouter()
|
||||
navigate(searchParams.get('redirect') ?? '/repository')
|
||||
navigateToRedirect(navigate, searchParams, '/repository')
|
||||
|
||||
notification.success({
|
||||
message: '欢迎回来',
|
||||
@@ -255,14 +261,14 @@ const SignIn = () => {
|
||||
<FlexBox direction={'horizontal'} className={'addition'}>
|
||||
<a
|
||||
onClick={() => {
|
||||
navigate('/')
|
||||
navigateToRoot(navigate)
|
||||
}}
|
||||
>
|
||||
返回主页
|
||||
</a>
|
||||
<a
|
||||
onClick={() => {
|
||||
navigate(`/forget${location.search}`, { replace: true })
|
||||
navigateToForget(navigate, location.search, { replace: true })
|
||||
}}
|
||||
>
|
||||
忘记密码?
|
||||
@@ -283,7 +289,7 @@ const SignIn = () => {
|
||||
还没有账号?
|
||||
<a
|
||||
onClick={() =>
|
||||
navigate(`/register${location.search}`, { replace: true })
|
||||
navigateToRegister(navigate, location.search, { replace: true })
|
||||
}
|
||||
>
|
||||
注册
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
SYSTEM_MATCH_SENSITIVE_WORD
|
||||
} from '@/constants/common.constants'
|
||||
import { getLoginStatus, setToken } from '@/util/auth'
|
||||
import { navigateToLogin } from '@/util/navigation'
|
||||
import { r_auth_register, r_auth_resend } from '@/services/auth'
|
||||
import FitCenter from '@/components/common/FitCenter'
|
||||
import FlexBox from '@/components/common/FlexBox'
|
||||
@@ -49,9 +50,7 @@ const SignUp = () => {
|
||||
return
|
||||
}
|
||||
if (getLoginStatus()) {
|
||||
navigate(`/login${location.search}`, {
|
||||
replace: true
|
||||
})
|
||||
navigateToLogin(navigate, location.search, undefined, { replace: true })
|
||||
}
|
||||
}, [location.pathname])
|
||||
|
||||
@@ -245,7 +244,9 @@ const SignUp = () => {
|
||||
已有账号?
|
||||
<a
|
||||
onClick={() =>
|
||||
navigate(`/login${location.search}`, { replace: true })
|
||||
navigateToLogin(navigate, location.search, undefined, {
|
||||
replace: true
|
||||
})
|
||||
}
|
||||
>
|
||||
登录
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
SYSTEM_MATCH_SENSITIVE_WORD
|
||||
} from '@/constants/common.constants'
|
||||
import { getLoginStatus, getUserInfo, requestUserInfo } from '@/util/auth'
|
||||
import { getRedirectUrl } from '@/util/route'
|
||||
import { navigateToLogin, navigateToRedirect, navigateToRepository } from '@/util/navigation'
|
||||
import { r_auth_resend, r_auth_verify } from '@/services/auth'
|
||||
import { r_api_avatar_random_base64 } from '@/services/api/avatar'
|
||||
import { AppContext } from '@/App'
|
||||
@@ -32,7 +32,7 @@ const Verify = () => {
|
||||
}
|
||||
|
||||
if (!getLoginStatus()) {
|
||||
navigate(getRedirectUrl('/login', `${location.pathname}${location.search}`), {
|
||||
navigateToLogin(navigate, undefined, `${location.pathname}${location.search}`, {
|
||||
replace: true
|
||||
})
|
||||
return
|
||||
@@ -81,7 +81,7 @@ const Verify = () => {
|
||||
break
|
||||
case PERMISSION_NO_VERIFICATION_REQUIRED:
|
||||
void message.warning('账户已验证')
|
||||
navigate('/repository')
|
||||
navigateToRepository(navigate)
|
||||
break
|
||||
default:
|
||||
void message.error('出错了,请稍后重试')
|
||||
@@ -128,7 +128,7 @@ const Verify = () => {
|
||||
setTimeout(() => {
|
||||
void requestUserInfo().then(() => {
|
||||
refreshRouter()
|
||||
navigate(searchParams.get('redirect') ?? '/repository')
|
||||
navigateToRedirect(navigate, searchParams, '/repository')
|
||||
})
|
||||
}, 1500)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user