Jeecg-boot路由許可權結構
阿新 • • 發佈:2020-12-14
路由/選單說明
配置檔案路徑
@/config/router.config.js
格式和說明
/**
* 路由配置說明:
* 建議:sider menu 請不要超過三級選單,若超過三級選單,則應該設計為頂部主選單 配合左側次級選單
*
**/
{
redirect: noredirect,
name: 'router-name',
hidden: true,
meta: {
title: 'title',
icon: 'a-icon',
keepAlive: true,
hiddenHeaderContent: true,
}
}
{ Route }
引數 | 說明 | 型別 | 預設值 |
---|---|---|---|
hidden | 控制路由是否顯示在 sidebar | boolean | falase |
redirect | 重定向地址, 訪問這個路由時,自定進行重定向 | string | - |
name | 路由名稱, 建議設定,且不能重名 | string | - |
meta | 路由元資訊(路由附帶擴充套件資訊) | object | {} |
{ Meta }
路由元資訊物件
引數 | 說明 | 型別 | 預設值 |
---|---|---|---|
title | 路由標題, 用於顯示麵包屑, 頁面標題 *推薦設定 | string | - |
icon | 路由在 menu 上顯示的圖示 | string | - |
keepAlive | 快取該路由 | boolean | false |
hiddenHeaderContent | *特殊 隱藏PageHeader元件中的頁面帶的 麵包屑和頁面標題欄 | boolean | false |
permission | 與專案提供的許可權攔截匹配的許可權,如果不匹配,則會被禁止訪問該路由頁面 | array | [] |
路由例子
const asyncRouterMap = [ { path: '/', name: 'index', component: BasicLayout, meta: { title: '首頁' }, redirect: '/dashboard/analysis', children: [ { path: '/dashboard', component: Layout, name: 'dashboard', redirect: '/dashboard/workplace', meta: {title: '儀表盤', icon: 'dashboard', permission: ['dashboard']}, children: [ { path: '/dashboard/analysis', name: 'Analysis', component: () => import('@/views/dashboard/Analysis'), meta: {title: '分析頁', permission: ['dashboard']} }, { path: '/dashboard/monitor', name: 'Monitor', hidden: true, component: () => import('@/views/dashboard/Monitor'), meta: {title: '監控頁', permission: ['dashboard']} }, { path: '/dashboard/workplace', name: 'Workplace', component: () => import('@/views/dashboard/Workplace'), meta: {title: '工作臺', permission: ['dashboard']} } ] }, // result { path: '/result', name: 'result', component: PageView, redirect: '/result/success', meta: { title: '結果頁', icon: 'check-circle-o', permission: [ 'result' ] }, children: [ { path: '/result/success', name: 'ResultSuccess', component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'), // 該頁面隱藏麵包屑和頁面標題欄 meta: { title: '成功', hiddenHeaderContent: true, permission: [ 'result' ] } }, { path: '/result/fail', name: 'ResultFail', component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'), // 該頁面隱藏麵包屑和頁面標題欄 meta: { title: '失敗', hiddenHeaderContent: true, permission: [ 'result' ] } } ] }, ... ] }, ]
- 請注意
component: () => import('..')
方式引入路由的頁面元件為 懶載入模式。具體可以看Vue 官方文件- 增加新的路由應該增加在 '/' (index) 路由的
children
內permission
可以進行自定義修改,只需要對這個模組進行自定義修改即可src/store/modules/permission.js#L10