diff --git a/src/routes.tsx b/src/routes.tsx index f334478..68d49d9 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -20,6 +20,7 @@ import { Outlet, redirect, RouterProvider, + createHashHistory, } from '@tanstack/react-router' // import { TanStackRouterDevtools } from '@tanstack/router-devtools' import { memo, useEffect, useRef } from 'react' @@ -47,12 +48,12 @@ export const queryClient = new QueryClient({ const rootRoute = createRootRouteWithContext()({ component: () => ( - <> - - - - {/**/} - + <> + + + + {/**/} + ), beforeLoad: ({ location }) => { if (location.pathname === '/') { @@ -251,31 +252,31 @@ const generateDynamicRoutes = (menuData: MenuItem[], parentRoute: AnyRoute) => { } const routeTree = rootRoute.addChildren( - [ - //非Layout - loginRoute, - emptyRoute, - - //不带权限Layout - layoutNormalRoute.addChildren([ - notAuthRoute, - ]), - - //带权限Layout - // dashboardRoute, - authRoute.addChildren( - [ - layoutAuthRoute - /*.addChildren( - [ - menusRoute, - departmentsRoute, - usersRoute, - rolesRoute, - ] - ),*/ - ]), - ] + [ + //非Layout + loginRoute, + emptyRoute, + + //不带权限Layout + layoutNormalRoute.addChildren([ + notAuthRoute, + ]), + + //带权限Layout + // dashboardRoute, + authRoute.addChildren( + [ + layoutAuthRoute + /*.addChildren( + [ + menusRoute, + departmentsRoute, + usersRoute, + rolesRoute, + ] + ),*/ + ]), + ] ) @@ -301,8 +302,11 @@ export const RootProvider = memo((props: { context: Partial }) => generateDynamicRoutes(menuData ?? [], layoutAuthRoute) + const hashHistory = createHashHistory() + const router = createRouter({ routeTree, + history: hashHistory, context: { queryClient, menuData: [] }, defaultPreload: 'intent', defaultPendingComponent: () => @@ -310,9 +314,9 @@ export const RootProvider = memo((props: { context: Partial }) => return ( - - - + + + ) })