1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import { createRouter, createWebHistory } from 'vue-router'
- import { registerBeforeRouter, registerAfterRouter } from './guard'
- export const homeIndex = () => import('@/views/home/index.vue')
- export const Layout = () => import('@/layout/index.vue')
- import { routes as systemRoutes } from './modules/system'
- import { routes as userRoutes } from './modules/user'
- // 静态路由
- export const constantRoutes = [
- {
- path: '/redirect',
- component: Layout,
- meta: { hidden: true },
- children: [
- {
- path: '/redirect/:path(.*)',
- component: () => import('@/views/redirect/index.vue')
- }
- ]
- },
- {
- path: '/login',
- name: 'Login',
- meta: { title: '系统登录' },
- component: () => import('@/views/login/index.vue')
- },
- {
- path: '/',
- name: 'Layout',
- component: Layout,
- children: [
- ...systemRoutes,
- ...userRoutes,
- {
- path: '/',
- name: 'home',
- meta: {
- title: '首页',
- affix: true,
- keepAlive: true,
- alwaysShow: false
- },
- component: () => import('@/views/home/index.vue')
- },
- {
- path: '401',
- component: () => import('@/views/error-page/401.vue'),
- meta: { hidden: true }
- },
- {
- path: '404',
- component: () => import('@/views/error-page/404.vue'),
- meta: { hidden: true }
- },
- {
- path: '/acccount',
- name: 'acccount',
- meta: {
- title: '账号管理',
- affix: true,
- keepAlive: true,
- alwaysShow: false
- },
- component: () => import('@/views/account/index.vue')
- }
- ]
- }
- ]
- /**
- * 创建路由
- */
- const router = createRouter({
- history: createWebHistory(),
- routes: constantRoutes,
- // 刷新时,滚动条位置还原
- scrollBehavior: () => ({ left: 0, top: 0 })
- })
- registerBeforeRouter(router)
- registerAfterRouter(router)
- export default router
|