Files
helix/web/src/components/protected-route/index.tsx
T
siujamo 965b92b47d chore: restructure into monorepo and add open-source documentation
- Rename helix-server -> server and helix-web -> web
- Remove helix-api (bruno collection and docs site)
- Merge per-module .gitignore files into the root .gitignore
- Add README, AGENTS, CONTRIBUTING and MIT LICENCE
- Add full-stack docker-compose (postgres, redis, server, web via Caddy)
  with web Dockerfile, Caddyfile and Compose server config
- Keep the Gradle wrapper jar tracked after the .gitignore merge
- Copy gradle.properties into the server Docker build image
2026-09-01 10:48:45 +08:00

23 lines
560 B
TypeScript

import { Navigate, Outlet, useLocation } from "react-router"
import { useAppSelector } from "@/store"
import DashboardLayout from "@/layouts/dashboard-layout"
/**
* 需要身份验证的前置组件
* @constructor
*/
export default function ProtectedRoute() {
const isAuthenticated = useAppSelector((state) => state.auth.isAuthenticated)
const location = useLocation()
if (!isAuthenticated) {
return <Navigate to="/login" state={{ from: location }} replace />
}
return (
<DashboardLayout >
<Outlet />
</DashboardLayout>
)
}