2022-04-20 04:10:22 +00:00
|
|
|
|
|
2022-04-08 02:42:44 +00:00
|
|
|
|
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
|
|
|
|
|
|
import Layout from '@/layout/index.vue'
|
2022-04-20 04:10:22 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Note: 路由配置项
|
|
|
|
|
|
*
|
|
|
|
|
|
* name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
|
|
|
|
|
|
*
|
|
|
|
|
|
* meta : {
|
|
|
|
|
|
keepAlive: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
|
|
|
|
|
|
title: 'title' // 设置该路由在侧边栏的名字
|
|
|
|
|
|
icon: 'svg-name' // 设置该路由的图标
|
|
|
|
|
|
activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
|
|
|
|
|
|
query: '{"id": 1}' // 访问路由的默认传递参数
|
|
|
|
|
|
hidden: true // 当设置 true 的时候该路由不会再侧边栏出现
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// 公共路由
|
|
|
|
|
|
export const constantRoutes: Array<RouteRecordRaw> = [
|
2022-04-08 02:42:44 +00:00
|
|
|
|
{
|
|
|
|
|
|
path: '/',
|
|
|
|
|
|
redirect: 'workbench',
|
2022-04-20 04:10:22 +00:00
|
|
|
|
name: 'index',
|
|
|
|
|
|
component: Layout
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/permission',
|
2022-04-08 02:42:44 +00:00
|
|
|
|
component: Layout,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{
|
2022-04-20 04:10:22 +00:00
|
|
|
|
path: 'admin/edit',
|
|
|
|
|
|
component: () => import('@/views/permission/admin/edit.vue'),
|
|
|
|
|
|
meta: { title: '编辑管理员', activeMenu: '/permission/admin' }
|
2022-04-08 02:42:44 +00:00
|
|
|
|
},
|
2022-04-20 04:10:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
path: 'menu/edit',
|
|
|
|
|
|
component: () => import('@/views/permission/menu/edit.vue'),
|
|
|
|
|
|
meta: { title: '编辑菜单', activeMenu: '/permission/menu' }
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'role/edit',
|
|
|
|
|
|
component: () => import('@/views/permission/role/edit.vue'),
|
|
|
|
|
|
meta: { title: '编辑角色', activeMenu: '/permission/role' }
|
|
|
|
|
|
}
|
2022-04-08 02:42:44 +00:00
|
|
|
|
]
|
2022-04-20 04:10:22 +00:00
|
|
|
|
},
|
2022-04-08 02:42:44 +00:00
|
|
|
|
{
|
|
|
|
|
|
path: '/login',
|
|
|
|
|
|
component: () => import('@/views/account/login.vue')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-04-20 04:10:22 +00:00
|
|
|
|
path: '/500',
|
|
|
|
|
|
component: () => import('@/views/error/500.vue')
|
2022-04-08 02:42:44 +00:00
|
|
|
|
},
|
2022-04-20 04:10:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
path: '/:pathMatch(.*)*',
|
|
|
|
|
|
component: () => import('@/views/error/404.vue')
|
|
|
|
|
|
}
|
2022-04-08 02:42:44 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
2022-04-20 04:10:22 +00:00
|
|
|
|
routes: constantRoutes,
|
|
|
|
|
|
scrollBehavior(to, from, savedPosition) {
|
|
|
|
|
|
if (savedPosition) {
|
|
|
|
|
|
return savedPosition
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return { top: 0 }
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-04-08 02:42:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
export default router
|