|
|
@ -178,6 +178,10 @@ declare module '@tanstack/react-router' { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const modules = import.meta.glob('./pages/**/*.{jsx,tsx}') |
|
|
|
|
|
|
|
console.log(modules) |
|
|
|
|
|
|
|
const generateDynamicRoutes = (menuData: MenuItem[], parentRoute: AnyRoute) => { |
|
|
|
// 递归生成路由,如果有routes则递归生成子路由
|
|
|
|
|
|
|
@ -223,7 +227,8 @@ const generateDynamicRoutes = (menuData: MenuItem[], parentRoute: AnyRoute) => { |
|
|
|
|
|
|
|
return createRoute({ |
|
|
|
...options, |
|
|
|
component: lazyRouteComponent(() => import(`./pages/${component}`)), |
|
|
|
// @ts-ignore fix import
|
|
|
|
component: lazyRouteComponent(() => (modules[`./pages/${component}/index.tsx`] || modules[`./pages/${component}/index.jsx`])?.()), |
|
|
|
notFoundComponent: NotFound, |
|
|
|
}) |
|
|
|
} |
|
|
|