From 3cdcf5303f3c5c818a202e5f5e05e3ac791f88c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Tue, 26 Apr 2022 08:46:26 +0800 Subject: [PATCH] update router/index.js --- src/router/index.js | 122 +++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 53 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 5b20d3b..1bd9229 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -23,64 +23,80 @@ import Layout from '@/layout' // 公共路由 export const constantRoutes = [ -{ - path: '/redirect', - component: Layout, - hidden: true, - children: [ { - path: '/redirect/:path(.*)', - component: () => import('@/views/redirect/index.vue') - }] -}, -{ - path: '/login', - component: () => import('@/views/login'), - hidden: true -}, -// { -// path: '/register', -// component: () => import('@/views/register'), -// hidden: true -// }, -{ - path: "/:pathMatch(.*)*", - component: () => import('@/views/error/404'), - hidden: true -}, -{ - path: '/401', - component: () => import('@/views/error/401'), - hidden: true -}, -{ - path: '', - component: Layout, - redirect: '/index', - children: [ + path: '/redirect', + component: Layout, + hidden: true, + children: [ + { + path: '/redirect/:path(.*)', + component: () => import('@/views/redirect/index.vue') + }] + }, { - path: '/index', - component: () => import('@/views/index'), - name: 'Index', - meta: { title: '首页', icon: 'dashboard', affix: true } - }] -}, -{ - path: '/user', - component: Layout, - hidden: true, - redirect: 'noredirect', - children: [ + path: '/login', + component: () => import('@/views/login'), + hidden: true + }, + // { + // path: '/register', + // component: () => import('@/views/register'), + // hidden: true + // }, { - path: 'profile', - component: () => import('@/views/system/user/profile/index'), - name: 'Profile', - meta: { title: '个人中心', icon: 'user' } - }] -}]; + path: "/:pathMatch(.*)*", + component: () => import('@/views/error/404'), + hidden: true + }, + { + path: '/401', + component: () => import('@/views/error/401'), + hidden: true + }, + { + path: '', + component: Layout, + redirect: '/index', + children: [ + { + path: '/index', + component: () => import('@/views/index'), + name: 'Index', + meta: { title: '首页', icon: 'dashboard', affix: true } + }] + }, + { + path: '/user', + component: Layout, + hidden: true, + redirect: 'noredirect', + children: [ + { + path: 'profile', + component: () => import('@/views/system/user/profile/index'), + name: 'Profile', + meta: { title: '个人中心', icon: 'user' } + }] + }, + // 不用可删掉 + { + path: '', + component: Layout, + hidden: false, + meta: { title: '组件示例', icon: 'icon', noCache: 'fasle' }, + children: [ + { + path: 'icon', + component: () => import('@/views/components/icons/index'), + name: 'icon', + meta: { title: '图标icon', icon: 'icon1', noCache: 'fasle' } + }] + }, +]; const router = createRouter({ - history: createWebHistory(import.meta.env.VITE_APP_ROUTER_PREFIX), + history: createWebHistory( + import.meta.env.VITE_APP_ROUTER_PREFIX), routes: constantRoutes, // scrollBehavior(to, from, savedPosition) { // if (savedPosition) {