From bc88f12f25ec8a6290ef163a773aa0766c576210 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Fri, 13 Oct 2023 12:51:49 +0800 Subject: [PATCH] Chore: move home route to first --- gen-router.js | 6 ++++++ src/router.js | 12 ++++++------ src/views/dashboard/index.vue | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gen-router.js b/gen-router.js index effb98a..96806bf 100644 --- a/gen-router.js +++ b/gen-router.js @@ -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' diff --git a/src/router.js b/src/router.js index af0bbd1..20ad622 100644 --- a/src/router.js +++ b/src/router.js @@ -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', @@ -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', diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 9d7b7aa..5f2f2e9 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,4 +1,5 @@ - + +