私域操盘手 - 修复退出登录后页面在登录页和首页反复横跳的问题
This commit is contained in:
@@ -148,6 +148,9 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
||||
|
||||
const handleLogout = () => {
|
||||
safeLocalStorage.removeItem("token")
|
||||
safeLocalStorage.removeItem("token_expired")
|
||||
safeLocalStorage.removeItem("s2_accountId")
|
||||
safeLocalStorage.removeItem("userInfo")
|
||||
safeLocalStorage.removeItem("user")
|
||||
setToken(null)
|
||||
setUser(null)
|
||||
|
||||
@@ -154,8 +154,8 @@ export default function LoginPage() {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// 检查是否已登录,如果已登录则跳转到首页
|
||||
if (isAuthenticated) {
|
||||
// 检查是否已登录,如果已登录且不在登录页面,则跳转到首页
|
||||
if (isAuthenticated && window.location.pathname === '/login') {
|
||||
router.push("/")
|
||||
}
|
||||
}, [isAuthenticated, router])
|
||||
|
||||
Reference in New Issue
Block a user