Skip to content

Commit

Permalink
Chore: move home route to first
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Oct 13, 2023
1 parent cd02da1 commit bc88f12
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 6 additions & 0 deletions gen-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ function getDirRoutes(dir, subDir = '') {
}
}

// move home route to first
const homeIndex = routes.findIndex(route => route.indexOf('name: \'home\'') >= 0)
if (homeIndex > 0) {
routes.unshift(routes.splice(homeIndex, 1)[0])
}

const result =
`// This file is automatically generated by gen-router.js, please do not modify it manually!
import VueRouter from 'vue-router'
Expand Down
12 changes: 6 additions & 6 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import Vue from 'vue'
Vue.use(VueRouter)

const routes = [
{
path: '/',
name: 'home',
meta: { description: '首页' },
component: () => import(/* webpackChunkName: "home" */ '@/views/home'),
},
{
path: '/dashboard/index',
name: 'dashboardIndex',
Expand All @@ -23,12 +29,6 @@ const routes = [
meta: { description: 'driver.js demo' },
component: () => import(/* webpackChunkName: "guide" */ '@/views/guide'),
},
{
path: '/',
name: 'home',
meta: { description: '首页' },
component: () => import(/* webpackChunkName: "home" */ '@/views/home'),
},
{
path: '/icons',
name: 'icons',
Expand Down
3 changes: 2 additions & 1 deletion src/views/dashboard/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- 拖拽式仪表盘 -->
<!-- 拖拽式仪表盘-->
<!-- 文档:https://lruihao.cn/posts/draggable-dashboard/ -->
<script>
import Dashboard, { registerComponents } from '@/components/Dashboard'

Check warning on line 4 in src/views/dashboard/index.vue

View workflow job for this annotation

GitHub Actions / build

'registerComponents' is defined but never used
Expand Down

0 comments on commit bc88f12

Please sign in to comment.