侧边栏选中效果修复
This commit is contained in:
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { Navigate, useLocation } from "react-router-dom";
|
||||
import { useAuth } from "@/contexts/AuthContext";
|
||||
|
||||
const PUBLIC_PATHS = ['login', '404'];
|
||||
const PUBLIC_PATHS = ['login', '404','home'];
|
||||
export const ProtectedRoute = ({ children }) => {
|
||||
const { user } = useAuth();
|
||||
const location = useLocation();
|
||||
@@ -15,13 +15,12 @@ export const ProtectedRoute = ({ children }) => {
|
||||
return currentPath === key || currentPath.startsWith(`${key}/`);
|
||||
});
|
||||
|
||||
if (!hasPermission ) {
|
||||
return <Navigate to="/404" replace />;
|
||||
if (!hasPermission) {
|
||||
return <Navigate to="/home" replace />;
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
// 如果用户未登录,重定向到登录页
|
||||
return <Navigate to="/login" state={{ from: location }} replace />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user