2022-07-28 02:13:24 +00:00
|
|
|
|
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
|
2022-04-08 02:42:44 +00:00
|
|
|
|
import Layout from '@/layout/index.vue'
|
2022-06-23 03:41:08 +00:00
|
|
|
|
export const indexName = Symbol('index')
|
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
|
|
|
|
{
|
2022-06-23 03:41:08 +00:00
|
|
|
|
name: indexName,
|
2022-04-08 02:42:44 +00:00
|
|
|
|
path: '/',
|
2022-06-23 03:41:08 +00:00
|
|
|
|
redirect: '/workbench',
|
|
|
|
|
|
component: Layout
|
2022-04-20 04:10:22 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
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'),
|
2022-06-22 11:03:05 +00:00
|
|
|
|
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'),
|
2022-06-22 11:03:05 +00:00
|
|
|
|
meta: { title: '编辑菜单', activeMenu: '/permission/menu' },
|
2022-04-20 04:10:22 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'role/edit',
|
|
|
|
|
|
component: () => import('@/views/permission/role/edit.vue'),
|
2022-06-22 11:03:05 +00:00
|
|
|
|
meta: { title: '编辑角色', activeMenu: '/permission/role' },
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
2022-04-20 04:10:22 +00:00
|
|
|
|
},
|
2022-06-20 10:50:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
path: '/organize',
|
|
|
|
|
|
component: Layout,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'department/edit',
|
|
|
|
|
|
component: () => import('@/views/organize/department/edit.vue'),
|
2022-06-22 11:03:05 +00:00
|
|
|
|
meta: { title: '编辑部门', activeMenu: '/organize/department' },
|
2022-06-20 10:50:03 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'post/edit',
|
|
|
|
|
|
component: () => import('@/views/organize/post/edit.vue'),
|
2022-06-22 11:03:05 +00:00
|
|
|
|
meta: { title: '编辑岗位', activeMenu: '/organize/post' },
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/setting',
|
|
|
|
|
|
component: Layout,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'storage/edit',
|
|
|
|
|
|
component: () => import('@/views/setting/storage/edit.vue'),
|
|
|
|
|
|
meta: { title: '存储设置', activeMenu: '/setting/storage' },
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
2022-06-20 10:50:03 +00:00
|
|
|
|
},
|
2022-04-08 02:42:44 +00:00
|
|
|
|
{
|
|
|
|
|
|
path: '/login',
|
2022-06-22 11:03:05 +00:00
|
|
|
|
component: () => import('@/views/account/login.vue'),
|
2022-04-08 02:42:44 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-04-20 04:10:22 +00:00
|
|
|
|
path: '/500',
|
2022-06-22 11:03:05 +00:00
|
|
|
|
component: () => import('@/views/error/500.vue'),
|
2022-04-08 02:42:44 +00:00
|
|
|
|
},
|
2022-04-20 04:10:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
path: '/:pathMatch(.*)*',
|
2022-06-22 11:03:05 +00:00
|
|
|
|
component: () => import('@/views/error/404.vue'),
|
|
|
|
|
|
},
|
2022-04-08 02:42:44 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
2022-07-28 02:13:24 +00:00
|
|
|
|
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-06-22 11:03:05 +00:00
|
|
|
|
},
|
2022-04-08 02:42:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
export default router
|