generated from Daydreamer-riri/starter-lib
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
App.tsx
32 lines (28 loc) · 748 Bytes
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react'
import type { RouteRecord } from 'vite-react-ssg'
import './App.css'
const Layout = React.lazy(() => import('./Layout'))
export const routes: RouteRecord[] = [
{
path: '/',
element: <Layout />,
children: [
{
path: 'a',
lazy: () => import('./pages/a'),
},
{
index: true,
lazy: () => defaultToComponent(import('./pages/index')),
},
{
path: 'nest/:b',
lazy: () => defaultToComponent(import('./pages/nest/[b]')),
},
],
},
]
async function defaultToComponent(routePromise: Promise<RouteRecord & { default: any }>) {
const routeModule = await routePromise
return { ...routeModule, Component: routeModule.default }
}