Skip to content

Commit 863e48d

Browse files
committed
perf: lazy load components
1 parent bcc500f commit 863e48d

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

src/routes/web.js

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
import { GITHUB } from '@/config'
22
import Layout from '@/layout/web'
3-
import Home from '@/views/web/home'
4-
import Article from '@/views/web/article'
5-
import Archives from '@/views/web/archives'
6-
import Categories from '@/views/web/categories'
7-
import List from '@/views/web/tag'
8-
import About from '@/views/web/about'
9-
103
import lazy from '@/components/Lazy'
11-
const PageNotFound = lazy(() => import('@/components/404'))
12-
const GithubLogining = lazy(() => import('@/components/GithubLogining'))
134

145
export default {
156
path: '/',
167
name: 'home',
178
component: Layout,
189
childRoutes: [
19-
{ path: '', component: Home },
20-
{ path: 'article/:id', component: Article },
21-
{ path: 'archives', component: Archives },
22-
{ path: 'categories', component: Categories },
23-
{ path: 'categories/:name', component: List },
24-
{ path: 'tags/:name', component: List },
25-
{ path: '/github', component: GITHUB.enable && GithubLogining },
26-
{ path: '/about', component: About },
27-
{ path: '*', component: PageNotFound }
28-
]
10+
{ path: '', component: lazy(() => import('@/views/web/home')) },
11+
{ path: 'article/:id', component: lazy(() => import('@/views/web/article')) },
12+
{ path: 'archives', component: lazy(() => import('@/views/web/archives')) },
13+
{ path: 'categories', component: lazy(() => import('@/views/web/categories')) },
14+
{ path: 'categories/:name', component: lazy(() => import('@/views/web/tag')) },
15+
{ path: 'tags/:name', component: lazy(() => import('@/views/web/tag')) },
16+
{ path: '/github', component: GITHUB.enable && lazy(() => import('@/components/GithubLogining')) },
17+
{ path: '/about', component: lazy(() => import('@/views/web/home')) },
18+
{ path: '*', component: lazy(() => import('@/components/404')) },
19+
],
2920
}

0 commit comments

Comments
 (0)