redux 加入

This commit is contained in:
mmc
2026-04-21 10:33:48 +08:00
parent fc23b6fa22
commit 79f8252b08
8 changed files with 138 additions and 68 deletions

View File

@@ -1,12 +1,15 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { Navigate, Outlet } from 'react-router-dom';
export default function ProtectedRoute() {
const isAuthenticated = localStorage.getItem('isAuthenticated') === 'true';
const isAuthenticated = localStorage.getItem('isAuthenticated') === 'true';
//const { isAuthenticated } = useSelector(state => state.user);
if (!isAuthenticated) {
return <Navigate to="/login" replace />;
}
return <Outlet />;
if (!isAuthenticated) {
return <Navigate to="/login" replace />;
}
return <Outlet />;
}