Complete main UI #37

Merged
FatttSnake merged 192 commits from FatttSnake into dev 2024-02-23 16:31:17 +08:00
Showing only changes of commit e2d2710823 - Show all commits

View File

@@ -4,6 +4,7 @@ import { getLoginStatus, getVerifyStatus_async } from '@/util/auth'
import { Navigate } from 'react-router' import { Navigate } from 'react-router'
const AuthRoute = () => { const AuthRoute = () => {
const [searchParams] = useSearchParams()
const matches = useMatches() const matches = useMatches()
const lastMatch = matches.reduce((_, second) => second) const lastMatch = matches.reduce((_, second) => second)
const handle = lastMatch.handle as RouteHandle const handle = lastMatch.handle as RouteHandle
@@ -30,8 +31,12 @@ const AuthRoute = () => {
} }
} }
if (isLogin && ['/login', '/forget'].includes(lastMatch.pathname)) { if (isLogin && ['/login', '/forget'].includes(lastMatch.pathname)) {
if (searchParams.has('redirect')) {
return <Navigate to={searchParams.get('redirect') ?? '/'} />
} else {
return <Navigate to={'/'} /> return <Navigate to={'/'} />
} }
}
if (location.pathname.length > 1 && location.pathname.endsWith('/')) { if (location.pathname.length > 1 && location.pathname.endsWith('/')) {
return <Navigate to={location.pathname.substring(0, location.pathname.length - 1)} /> return <Navigate to={location.pathname.substring(0, location.pathname.length - 1)} />