mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
feat:实现单路由规则但有多个后台菜单
This commit is contained in:
parent
58a65b01e6
commit
4f299c4137
@ -8,7 +8,6 @@ import { useRoute } from 'vue-router'
|
||||
import Default from '/@/layouts/container/default.vue'
|
||||
import Classic from '/@/layouts/container/classic.vue'
|
||||
import Streamline from '/@/layouts/container/streamline.vue'
|
||||
import menus from '/@/mock/router.json' // 模拟api请求数据
|
||||
import { computed, onBeforeMount, onUnmounted } from 'vue'
|
||||
import { Session } from '/@/utils/storage'
|
||||
import { index } from '/@/api/backend'
|
||||
|
@ -1,164 +0,0 @@
|
||||
[
|
||||
{
|
||||
"title": "控制台",
|
||||
"path": "/admin/dashboard",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-tachometer",
|
||||
"keepAlive": "dashboard"
|
||||
},
|
||||
{
|
||||
"title": "常规管理",
|
||||
"path": "/admin/routine",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-cogs",
|
||||
"keepAlive": false,
|
||||
"children": [
|
||||
{
|
||||
"title": "系统设置",
|
||||
"path": "/admin/routine/config",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-cogs",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "个人资料",
|
||||
"path": "/admin/routine/adminInfo",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-user",
|
||||
"keepAlive": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "菜单管理",
|
||||
"path": "/admin/auth/menu",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-cogs",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "表格示例",
|
||||
"path": "/admin/table",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-cogs",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "百度",
|
||||
"path": "https://baidu.com",
|
||||
"type": "link",
|
||||
"children": [
|
||||
{
|
||||
"title": "系统设置1",
|
||||
"path": "/admin/routine/config/111",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-cogs",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置2",
|
||||
"path": "/admin/routine/config/222",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-cogs",
|
||||
"keepAlive": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "简书",
|
||||
"path": "https://www.jianshu.com/p/120eaf50331c",
|
||||
"type": "iframe",
|
||||
"icon": "fa fa-address-book"
|
||||
},
|
||||
{
|
||||
"title": "系统设置3",
|
||||
"path": "/admin/routine/config/3",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置4",
|
||||
"path": "/admin/routine/config/4",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置5",
|
||||
"path": "/admin/routine/config/5",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置6",
|
||||
"path": "/admin/routine/config/6",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置7",
|
||||
"path": "/admin/routine/config/7",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置8",
|
||||
"path": "/admin/routine/config/8",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置9",
|
||||
"path": "/admin/routine/config/9",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置10",
|
||||
"path": "/admin/routine/config/10",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置11",
|
||||
"path": "/admin/routine/config/11",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置12",
|
||||
"path": "/admin/routine/config/12",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置13",
|
||||
"path": "/admin/routine/config/13",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置14",
|
||||
"path": "/admin/routine/config/14",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
},
|
||||
{
|
||||
"title": "系统设置15",
|
||||
"path": "/admin/routine/config/15",
|
||||
"type": "tab",
|
||||
"icon": "fa fa-address-book",
|
||||
"keepAlive": false
|
||||
}
|
||||
]
|
@ -110,6 +110,9 @@ export const handleAdminRoute = (routes: any) => {
|
||||
const handleMenuRule = (routes: any, pathPrefix = '/') => {
|
||||
let menuRule = []
|
||||
for (const key in routes) {
|
||||
if (routes[key].extend == 'add_rules_only') {
|
||||
continue
|
||||
}
|
||||
if (routes[key].type == 'menu' || routes[key].type == 'menu_dir') {
|
||||
routes[key].type = routes[key].menu_type
|
||||
routes[key].keepAlive = routes[key].name
|
||||
@ -131,6 +134,9 @@ const handleMenuRule = (routes: any, pathPrefix = '/') => {
|
||||
|
||||
export const addRouteAll = (viewsComponent: Record<string, { [key: string]: any }>, routes: any, parentName: string) => {
|
||||
for (const idx in routes) {
|
||||
if (routes[idx].extend == 'add_menu_only') {
|
||||
continue
|
||||
}
|
||||
if (routes[idx].type == 'menu' && routes[idx].menu_type == 'tab' && viewsComponent[routes[idx].component].default) {
|
||||
addRouteItem(viewsComponent, routes[idx], parentName)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user