|
1 | | -import Login from "@/pages/login"; |
2 | 1 | import NotFound from "@/layout/NotFound"; |
3 | | -import Layout from "@/layout"; |
4 | | -import HomePage from "@/pages/home"; |
5 | 2 | import {Route} from "react-router"; |
6 | 3 | import {RouteObject} from "react-router/dist/lib/context"; |
7 | 4 | import React from "react"; |
8 | | -import LeaveListPage from "@/pages/leave"; |
9 | | -import LeaveCreatePage from "@/pages/leave/create"; |
10 | | -import FlowListPage from "@/pages/flow"; |
11 | | -import FlowDetailPage from "@/pages/flow/detail"; |
12 | | -import LeaveDetailPage from "@/pages/leave/detail"; |
13 | | -import FormPage from "@/pages/form"; |
14 | | -import MircoPage from "@/pages/mirco"; |
15 | | - |
| 5 | +import LazyComponent from "@/components/LazyComponent"; |
16 | 6 |
|
17 | 7 | export const routes: RouteObject[] = [ |
18 | 8 | { |
19 | 9 | path: "/login", |
20 | | - element: <Login/>, |
| 10 | + element: ( |
| 11 | + <LazyComponent |
| 12 | + lazy={() => { |
| 13 | + return import('@/pages/login'); |
| 14 | + }} |
| 15 | + /> |
| 16 | + ), |
21 | 17 | }, |
22 | 18 | { |
23 | 19 | path: '/', |
24 | | - element: <Layout/>, |
| 20 | + element: ( |
| 21 | + <LazyComponent |
| 22 | + lazy={() => { |
| 23 | + return import('@/layout/index'); |
| 24 | + }} |
| 25 | + /> |
| 26 | + ), |
25 | 27 | children: [ |
26 | 28 | { |
27 | 29 | path: "/", |
28 | | - element: <HomePage/>, |
| 30 | + element: ( |
| 31 | + <LazyComponent |
| 32 | + lazy={() => { |
| 33 | + return import('@/pages/home'); |
| 34 | + }} |
| 35 | + /> |
| 36 | + ), |
29 | 37 | }, |
30 | 38 | { |
31 | 39 | path: "/form", |
32 | | - element: <FormPage/>, |
| 40 | + element: ( |
| 41 | + <LazyComponent |
| 42 | + lazy={() => { |
| 43 | + return import('@/pages/form'); |
| 44 | + }} |
| 45 | + /> |
| 46 | + ), |
33 | 47 | }, |
34 | 48 | { |
35 | 49 | path: "/mirco", |
36 | | - element: <MircoPage/>, |
| 50 | + element: ( |
| 51 | + <LazyComponent |
| 52 | + lazy={() => { |
| 53 | + return import('@/pages/mirco'); |
| 54 | + }} |
| 55 | + /> |
| 56 | + ), |
37 | 57 | }, |
38 | 58 | { |
39 | 59 | path: "/leave/index", |
40 | | - element: <LeaveListPage/>, |
| 60 | + element: ( |
| 61 | + <LazyComponent |
| 62 | + lazy={() => { |
| 63 | + return import('@/pages/leave'); |
| 64 | + }} |
| 65 | + /> |
| 66 | + ), |
41 | 67 | }, |
42 | 68 | { |
43 | 69 | path: "/leave/create", |
44 | | - element: <LeaveCreatePage/>, |
| 70 | + element: ( |
| 71 | + <LazyComponent |
| 72 | + lazy={() => { |
| 73 | + return import('@/pages/leave/create'); |
| 74 | + }} |
| 75 | + /> |
| 76 | + ), |
45 | 77 | }, |
46 | 78 | { |
47 | 79 | path: "/leave/detail", |
48 | | - element: <LeaveDetailPage/>, |
| 80 | + element: ( |
| 81 | + <LazyComponent |
| 82 | + lazy={() => { |
| 83 | + return import('@/pages/leave/detail'); |
| 84 | + }} |
| 85 | + /> |
| 86 | + ), |
49 | 87 | }, |
50 | 88 | { |
51 | 89 | path: "/flow/list", |
52 | | - element: <FlowListPage/>, |
| 90 | + element: ( |
| 91 | + <LazyComponent |
| 92 | + lazy={() => { |
| 93 | + return import('@/pages/flow'); |
| 94 | + }} |
| 95 | + /> |
| 96 | + ), |
53 | 97 | }, |
54 | 98 | { |
55 | 99 | path: "/flow/detail", |
56 | | - element: <FlowDetailPage/>, |
| 100 | + element: ( |
| 101 | + <LazyComponent |
| 102 | + lazy={() => { |
| 103 | + return import('@/pages/flow/detail'); |
| 104 | + }} |
| 105 | + /> |
| 106 | + ), |
57 | 107 | }, |
58 | 108 | { |
59 | 109 | path: '/*', |
|
0 commit comments