fix(web): 冻结推迟模块路由守卫
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect, lazy, Suspense, useMemo } from 'react';
|
import { useEffect, lazy, Suspense, useMemo } from 'react';
|
||||||
import { HashRouter, Routes, Route, Navigate } from 'react-router-dom';
|
import { HashRouter, Routes, Route, Navigate } from 'react-router-dom';
|
||||||
import { ConfigProvider, theme as antdTheme, Spin } from 'antd';
|
import { ConfigProvider, theme as antdTheme, Spin, Result } from 'antd';
|
||||||
import zhCN from 'antd/locale/zh_CN';
|
import zhCN from 'antd/locale/zh_CN';
|
||||||
import MainLayout from './layouts/MainLayout';
|
import MainLayout from './layouts/MainLayout';
|
||||||
import Login from './pages/Login';
|
import Login from './pages/Login';
|
||||||
@@ -71,6 +71,19 @@ const ArticleEditor = lazy(() => import('./pages/health/ArticleEditor'));
|
|||||||
const ArticleCategoryManage = lazy(() => import('./pages/health/ArticleCategoryManage'));
|
const ArticleCategoryManage = lazy(() => import('./pages/health/ArticleCategoryManage'));
|
||||||
const ArticleTagManage = lazy(() => import('./pages/health/ArticleTagManage'));
|
const ArticleTagManage = lazy(() => import('./pages/health/ArticleTagManage'));
|
||||||
|
|
||||||
|
const FROZEN_ROUTES = [
|
||||||
|
'/health/care-plans',
|
||||||
|
'/health/shifts',
|
||||||
|
'/health/family-proxy',
|
||||||
|
'/health/medications',
|
||||||
|
'/health/dialysis',
|
||||||
|
'/health/schedules',
|
||||||
|
];
|
||||||
|
|
||||||
|
function FrozenRoute() {
|
||||||
|
return <Result status="info" title="功能暂未开放" subTitle="该功能正在优化中,敬请期待" />;
|
||||||
|
}
|
||||||
|
|
||||||
function PrivateRoute({ children }: { children: React.ReactNode }) {
|
function PrivateRoute({ children }: { children: React.ReactNode }) {
|
||||||
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
|
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
|
||||||
const permissions = useAuthStore((s) => s.permissions);
|
const permissions = useAuthStore((s) => s.permissions);
|
||||||
@@ -91,6 +104,11 @@ function PrivateRoute({ children }: { children: React.ReactNode }) {
|
|||||||
if (!hasAccess) return <Navigate to="/" replace />;
|
if (!hasAccess) return <Navigate to="/" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 冻结路由检查
|
||||||
|
if (FROZEN_ROUTES.some((frozen) => path.startsWith(frozen))) {
|
||||||
|
return <FrozenRoute />;
|
||||||
|
}
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user