mirror of
https://github.com/PlayEdu/backend
synced 2025-12-23 03:39:34 +08:00
登录路由守卫组件一级学习进度整数化
This commit is contained in:
12
src/compenents/private-route/index.tsx
Normal file
12
src/compenents/private-route/index.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from "react";
|
||||
import { getToken } from "../../utils/index";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
interface PropInterface {
|
||||
Component: any;
|
||||
}
|
||||
|
||||
const PrivateRoute: React.FC<PropInterface> = ({ Component }) => {
|
||||
return getToken() ? Component : <Navigate to="/login" replace={true} />;
|
||||
};
|
||||
export default PrivateRoute;
|
||||
Reference in New Issue
Block a user