From d88195fa517e9dd79e03cab442c3d759b8aa2ff4 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Tue, 24 Feb 2026 20:03:40 +0800 Subject: [PATCH] feat(auth): enhance authentication flow with login page configuration and navigation updates --- src/pages/auth/index.tsx | 15 +++++----- src/pages/auth/modules/BaseHeader.tsx | 8 ++--- src/pages/auth/page.tsx | 42 +++++++++++++++++++++++---- src/pages/auth/store.ts | 25 ++++++++++++++-- 4 files changed, 70 insertions(+), 20 deletions(-) diff --git a/src/pages/auth/index.tsx b/src/pages/auth/index.tsx index e02d241..ac827c7 100644 --- a/src/pages/auth/index.tsx +++ b/src/pages/auth/index.tsx @@ -4,10 +4,8 @@ import { useShallow } from "zustand/shallow" import { LogIn, LockKeyhole } from "lucide-react" export { BaseHeader } from './modules/BaseHeader' import { useMemo } from 'react'; -import { useLocation } from '@tanstack/react-router'; -const openLinkList = [ - '/login' -] +import { useLocation, useNavigate } from '@tanstack/react-router'; + type Props = { children?: React.ReactNode, @@ -17,16 +15,16 @@ export const AuthProvider = ({ children, mustLogin }: Props) => { const store = useLayoutStore(useShallow(state => ({ init: state.init, me: state.me, + openLinkList: state.openLinkList, }))); useEffect(() => { store.init() }, []) const location = useLocation() + const navigate = useNavigate(); const isOpen = useMemo(() => { - console.log('location.pathname', location.pathname, openLinkList) - return openLinkList.some(item => location.pathname.startsWith(item)) + return store.openLinkList.some(item => location.pathname.startsWith(item)) }, [location.pathname]) - console.log('AuthProvider', { location, isOpen, me: store.me }) const loginUrl = '/root/login/?redirect=' + encodeURIComponent(window.location.href); if (mustLogin && !store.me && !isOpen) { return ( @@ -42,7 +40,8 @@ export const AuthProvider = ({ children, mustLogin }: Props) => {
{ - window.open(loginUrl, '_self') + // window.open(loginUrl, '_blank'); + navigate({ to: '/login' }); }} > diff --git a/src/pages/auth/modules/BaseHeader.tsx b/src/pages/auth/modules/BaseHeader.tsx index be65de6..bf2e3ea 100644 --- a/src/pages/auth/modules/BaseHeader.tsx +++ b/src/pages/auth/modules/BaseHeader.tsx @@ -1,5 +1,5 @@ import { Home, User, LogIn, LogOut } from 'lucide-react'; -import { Link } from '@tanstack/react-router' +import { Link, useNavigate } from '@tanstack/react-router' import { useLayoutStore } from '../store'; import { useShallow } from 'zustand/shallow'; import { useMemo } from 'react'; @@ -9,12 +9,12 @@ export const BaseHeader = (props: { main?: React.ComponentType | null }) => { me: state.me, clearMe: state.clearMe, }))); - + const navigate = useNavigate(); const meInfo = useMemo(() => { if (!store.me) { return (