edu/admin/src/router/index.ts

77 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'
/**
* 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> = [
{
path: '/',
redirect: 'workbench',
name: 'index',
component: Layout
},
{
path: '/permission',
component: Layout,
children: [
{
path: 'admin/edit',
component: () => import('@/views/permission/admin/edit.vue'),
meta: { title: '编辑管理员', activeMenu: '/permission/admin' }
},
{
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' }
}
]
},
{
path: '/login',
component: () => import('@/views/account/login.vue')
},
{
path: '/500',
component: () => import('@/views/error/500.vue')
},
{
path: '/:pathMatch(.*)*',
component: () => import('@/views/error/404.vue')
}
]
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: constantRoutes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { top: 0 }
}
},
})
export default router