门店账户多账号

This commit is contained in:
2026-07-12 12:24:34 +08:00
parent 06b1cb22e0
commit 54a15d6da7
39 changed files with 1962 additions and 311 deletions
+7 -2
View File
@@ -3,9 +3,10 @@ import { getStoreProfile, hasShopWxSession } from '../lib/api';
import { useStoreSession } from '../contexts/StoreSessionContext';
const PUBLIC_PATHS = new Set(['/login']);
const SELECT_STORE_PATH = '/select-store';
export default function AuthGate({ children }: { children: React.ReactNode }) {
const { ready, authenticated } = useStoreSession();
const { ready, authenticated, needsSelectStore } = useStoreSession();
const location = useLocation();
if (!ready) {
@@ -17,7 +18,11 @@ export default function AuthGate({ children }: { children: React.ReactNode }) {
}
if (authenticated && location.pathname === '/login') {
return <Navigate to="/" replace />;
return <Navigate to={needsSelectStore ? SELECT_STORE_PATH : '/'} replace />;
}
if (authenticated && needsSelectStore && location.pathname !== SELECT_STORE_PATH) {
return <Navigate to={SELECT_STORE_PATH} replace />;
}
if (!authenticated && !PUBLIC_PATHS.has(location.pathname)) {