私域操盘手 - 修复退出登录后页面在登录页和首页反复横跳的问题

This commit is contained in:
柳清爽
2025-05-19 12:05:35 +08:00
parent 92d455184a
commit d93c2d0416
2 changed files with 5 additions and 2 deletions

View File

@@ -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)

View File

@@ -154,8 +154,8 @@ export default function LoginPage() {
}
useEffect(() => {
// 检查是否已登录,如果已登录则跳转到首页
if (isAuthenticated) {
// 检查是否已登录,如果已登录且不在登录页面,则跳转到首页
if (isAuthenticated && window.location.pathname === '/login') {
router.push("/")
}
}, [isAuthenticated, router])