门店账号管理修改

This commit is contained in:
2026-07-07 00:01:16 +08:00
parent e85c4b9bcb
commit 7ca9fc8a35
25 changed files with 599 additions and 134 deletions
+27
View File
@@ -0,0 +1,27 @@
import { Navigate, useLocation } from 'react-router-dom';
import { useStoreSession } from '../contexts/StoreSessionContext';
const PUBLIC_PATHS = new Set(['/login']);
export default function AuthGate({ children }: { children: React.ReactNode }) {
const { ready, authenticated } = useStoreSession();
const location = useLocation();
if (!ready) {
return (
<div className="session-boot">
<p className="session-boot-text"></p>
</div>
);
}
if (authenticated && location.pathname === '/login') {
return <Navigate to="/" replace />;
}
if (!authenticated && !PUBLIC_PATHS.has(location.pathname)) {
return <Navigate to="/login" replace state={{ from: location }} />;
}
return <>{children}</>;
}