Commit a476d46e authored by 张俊's avatar 张俊

菜单处理

parent 298b81c6
<template>
<ul class="nav-list" v-if="list&&list.length">
<li v-for="(item, index) in list" v-show="item.show" :key="'nav_' + index">
<template v-if="item.children && item.children.length">
<li v-for="(item, index) in list" v-show="item.menuType!==2" :key="'nav_' + index">
<template v-if="item.children && item.children.length&&item.menuType==0">
<div
class="nav-item nav-more text-clip"
:class="{ current: isCurrent([item.path]) }"
......@@ -9,8 +9,10 @@
>
<span :style="{ paddingLeft: `${deep*2}em` }">
<!-- <img v-if="item.icon" :src="item.icon" alt=""> -->
<bg-icon v-if="item.icon" :icon="item.icon"></bg-icon>
<bg-icon v-if="item.icon" style="color:#7c8292;" :icon="'#'+item.icon"></bg-icon>
{{ item.menuName }}
<bg-icon v-show="showMore[index] !== false" style="font-size:8px;position: absolute;right: 10px;top: 20px;" icon="#bg-ic-arrow-up"></bg-icon>
<bg-icon v-show="showMore[index] == false" style="font-size:8px;position: absolute;right: 10px;top: 20px;" icon="#bg-ic-arrow-down"></bg-icon>
</span>
&ensp;
</div>
......@@ -26,7 +28,7 @@
<template v-else>
<div
class="nav-item text-clip"
:class="{current:isCurrent(item.linkPath&&item.linkPath.length?[...item.linkPath,item.path]:[item.path])}"
:class="{current:isCurrent(item.children&&item.children.length?[...getChildrenPath(item.children),item.path]:[item.path])}"
@click="$router.push(item.path)"
>
<span :style="{ paddingLeft: `${deep*2}em` }">{{ item.menuName }}</span>
......@@ -67,6 +69,15 @@ export default {
this.showMore[index] = !flag
},
getChildrenPath(arr,temp=[]){
arr.forEach(e => {
temp.push(e.path)
if(e.children&&e.children.length){
this.getChildrenPath(e.children,temp)
}
});
return temp
},
isCurrent(path) {
return (
(this.highlightParentRule && this.highlightParentRule(path)) || false
......
......@@ -8,36 +8,36 @@
>
<!-- LOGO -->
<div class="bg-logo" @click="gotoPage">
<router-link to="/" class="bg-logo">
<img style="width:140px;height:22px;" src="../assets/imgs/img_logo.png"/>
</div>
</router-link>
<!-- 菜单 -->
<div class="main-menu" v-if="userInfo&& userInfo.system_id">
<!-- 前台菜单 -->
<div class="font-menu" v-if="fontMenu&&fontMenu.length">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.show" v-for="(item,index) in fontMenu" :key="'font'+index">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.menuType!==2" v-for="(item,index) in fontMenu" :key="'font'+index">
<span @click="menuAction(item.path,item)">
{{item.menuName}}
<bg-icon v-if="item.children&&item.children.length" icon="#bg-ic-arrow-down" style="font-size:8px;margin-left: 3px;"></bg-icon>
</span>
<div class="menu-virtual"></div>
<div class="menu-list" v-if="item.children&&item.children.length">
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.show" v-for="(it,idx) in item.children" :key="'font-children'+idx">{{it.menuName}}</div>
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.menuType!==2" v-for="(it,idx) in item.children" :key="'font-children'+idx">{{it.menuName}}</div>
</div>
</div>
</div>
<!-- 后管菜单 -->
<div class="manager-menu" v-if="managerMenu&&managerMenu.length">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.show" v-for="(item,index) in managerMenu" :key="'manager'+index">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.menuType!==2" v-for="(item,index) in managerMenu" :key="'manager'+index">
<span @click="menuAction(item.path,item)">
{{item.menuName}}
<bg-icon v-if="item.children&&item.children.length" icon="#bg-ic-arrow-down" style="font-size:8px;margin-left: 3px;"></bg-icon>
</span>
<div class="menu-virtual"></div>
<div class="menu-list" v-if="item.children&&item.children.length">
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.show" v-for="(it,idx) in item.children" :key="'manager-children'+idx">{{it.menuName}}</div>
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.menuType!==2" v-for="(it,idx) in item.children" :key="'manager-children'+idx">{{it.menuName}}</div>
</div>
</div>
</div>
......@@ -129,7 +129,7 @@ export default {
fontMenu (state) {
let temp = []
// state.menu.forEach(e => {
// if(e.menuType=='font'){
// if(e.dict_group_id=='2cb4f767-fad7-44f2-afa3-f055e15dd2b6'){//font
// temp.push(e)
// }
// });
......@@ -138,7 +138,7 @@ export default {
managerMenu(state){
let temp = []
// state.menu.forEach(e => {
// if(e.menuType=='system'){
// if(e.dict_group_id=='64c156e0-bfff-4bfc-a63a-56effe130a25'){//system
// temp.push(e)
// }
// });
......@@ -147,7 +147,7 @@ export default {
systemMenu(state){
let temp = []
state.menu.forEach(e => {
if(e.menuType=='manager'){
if(e.dict_group_id=='09938937-3db9-47de-b967-7777ea4ebb2d'){//manager
temp.push(e)
}
});
......@@ -192,14 +192,10 @@ export default {
// })
},
menuAction(n,parent) {
//不存在则不跳转
if(!n){
return
}
if (n == "logout") {
this.$axios.post(`/apaas/system/v5/user/logout`).then(res=>{
if(res.data.code=='200'){
this.$router.push('/login')
window.location.href = `/apaas/manage/ui/#/login`;
this.$store.commit('setUserInfo',null)
clearCookie('bgToken')
this.$message.success('退出成功')
......@@ -210,7 +206,7 @@ export default {
})
} else if (n == "login") {
let path = this.$route.path;
window.location.href = `/login?redirect=${path}`;
window.location.href = `/apaas/manage/ui/#/login?redirect=${path}`;
} else {
//是否有子路由,有则寻找子路由的第一个进行跳转,无则直接进行跳转
//使用childMenuAction是模拟template中,子路径点击跳转使用childMenuAction,
......@@ -223,18 +219,17 @@ export default {
}
},
childMenuAction(v,parent) {
//最多只有2层目录,childMenuAction已经进入第一层,只需判断是否还有第二层即可
//有第二层则继续找第二层的第一个跳转
//无第二层则直接跳转
if(v.children&&v.children.length){
if(v.children[0].children){
this.pathToUrl(v.children[0].children[0].path,parent)
}else{
for (let index = 0; index < v.children.length; index++) {
const e = v.children[index];
if(e.show){
if(e.menuType!==2){
this.pathToUrl(e.path,parent)
break
}
}
}
}else{
this.pathToUrl(v.path,parent)
}
......@@ -246,22 +241,19 @@ export default {
}else{
//判断是否是同区域内跳转
//非同区域跳转需要改前缀,如apaas/portal/ui跳转到apaas/manage/ui
if(this.$store.state.menuObj[this.path]&&(parent.menuType==this.$store.state.menuObj[this.path].menuType||(['font','system'].includes(parent.menuType)&&['font','system'].includes(this.$store.state.menuObj[this.path].menuType)))){
if(this.$store.state.menuObj[this.path]&&(parent.dict_group_id==this.$store.state.menuObj[this.path].dict_group_id||(['2cb4f767-fad7-44f2-afa3-f055e15dd2b6','64c156e0-bfff-4bfc-a63a-56effe130a25'].includes(parent.dict_group_id)&&['2cb4f767-fad7-44f2-afa3-f055e15dd2b6','64c156e0-bfff-4bfc-a63a-56effe130a25'].includes(this.$store.state.menuObj[this.path].dict_group_id)))){
this.$router.push(path);
}else{
let temp = ''
if(this.$store.state.menuObj[path].menuType=='font'||this.$store.state.menuObj[path].menuType=='system'){
if(this.$store.state.menuObj[path].dict_group_id=='2cb4f767-fad7-44f2-afa3-f055e15dd2b6'||this.$store.state.menuObj[path].dict_group_id=='64c156e0-bfff-4bfc-a63a-56effe130a25'){
temp = '/apaas/portal/ui/#'
}else if(this.$store.state.menuObj[path].menuType=='manager'){
}else if(this.$store.state.menuObj[path].dict_group_id=='09938937-3db9-47de-b967-7777ea4ebb2d'){
temp = '/apaas/manage/ui/#'
}
window.open(temp+path)
}
}
},
gotoPage(){
window.open(`/apaas/portal/ui/#/`)
},
intoCartDetail() {
this.$router.push({ name: "shopCart" });
},
......@@ -458,7 +450,6 @@ export default {
line-height: 1;
margin: 0 50px 0 20px;
text-decoration: none;
cursor: pointer;
> span {
font-size: 24px;
......
var adminMenu = [
{
menuName: "工作台",
path: "/workspace1",
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25", //0目录1菜单2子页面
menuType: 0, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
children: [
{
menuName: "工作台首页",
path: "/workspace",
parentPath:null,
name:"workspace",
menuType:'system', //system:apaas后管,能力注册页等 font:apaas前台页 manager:apaas管理中心
show:true,
children:[{
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 1, //system:apaas后管,能力注册页等 font:apaas前台页 manager:apaas管理中心
},
{
menuName: "能力管理",
path: "/ability-manage",
show:true,
menuType:'system',
icon: "#bg-ic-ability",
parentPath:'/workspace',
children:[
{
name: "ui-service-test",
menuName: "ui服务测试",
path: "/ui-example",
menuType:'system',
parentPath:null,
},
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 0,
icon: "bg-ic-ability",
children: [
{
name: "register-valid",
menuName: "注册认证",
path: "/register-valid",
menuType:'system',
parentPath:null,
},
menuName: "能力注册",
path: "/ability-manage/real-list",
children: [
{
name: "ability-register-step",
menuName:'能力注册',
menuName: "能力注册",
path: "/ability-register/step",
parentPath:'/ability-manage',
menuType:'system',
},
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
children: [
{
name: "ability-register-desc",
menuName:'服务注册说明',
menuName: "服务注册说明",
path: "/ability-register/desc",
linkPath:["/ability-register/desc"],
parentPath:'/ability-manage',
menuType:'system',
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
{
name: "ability-register-preview",
menuName:'服务注册说明',
menuName: "服务注册说明",
path: "/ability-register/preview",
linkPath:["/ability-register/preview"],
parentPath:'/ability-manage',
menuType:'system',
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
{
name: "ability-register-set-mock",
menuName:'配置mock服务',
path: "/ability-register/set-mock",
parentPath:'/ability-manage',
menuType:'system',
menuName: "ui服务测试",
path: "/ui-example",
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
{
name: "real-list",
menuName:'能力注册',
path: "/ability-manage/real-list",
parentPath:'/ability-manage',
linkPath:["/ability-register/step","/ability-register/set-mock"],
menuType:'system',
show:true,
menuName: "注册认证",
path: "/register-valid",
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
],
},
{
menuName: "配置mock服务",
path: "/ability-register/set-mock",
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
{
name: "real-detail",
menuName:'能力注册详情',
menuName: "能力注册详情",
path: "/ability-manage/real-list/detail",
parentPath:'/ability-manage',
menuType:'system',
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
],
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 1,
},
{
name: "mock-list",
menuName:'mock能力',
menuName: "mock能力",
path: "/ability-manage/mock-list",
parentPath:'/ability-manage',
linkPath:["/mock-register/step"],
show:true,
menuType:'system',
},
children: [
{
path:"/mock-register/step",
parentPath:'/ability-manage',
name:"mock-register-step",
menuName:"mock注册",
menuType:'system',
path: "/mock-register/step",
menuName: "mock注册",
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
{
name: "mock-detail",
menuName:'mock能力详情',
menuName: "mock能力详情",
path: "/ability-manage/mock-list/detail",
parentPath:'/ability-manage',
menuType:'system',
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
],
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 1,
},
{
name: "sold-list",
menuName:'能力上下架管理',
menuName: "能力上下架管理",
path: "/ability-manage/sold-list",
parentPath:'/ability-manage',
linkPath:["/ability-manage/sold-list/service-test"],
show: true,
menuType:'system',
},
children: [
{
name: "service-test",
menuName:'服务测试',
menuName: "服务测试",
path: "/ability-manage/sold-list/service-test",
parentPath:'/ability-manage',
menuType:'system',
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 2,
},
]
],
dict_group_id: "64c156e0-bfff-4bfc-a63a-56effe130a25",
menuType: 1,
},
{
name: "dict-config",
menuName:'字典配置',
path: "/dict-config",
parentPath:'/workspace',
menuType:'system',
icon: "#bg-ic-log",
show:true,
children: [
{
name: "business-list",
menuName:'业务分类',
path: "/dict-config/business-list",
parentPath:'/dict-config',
menuType:'system',
show:true,
],
},
{
name: "sectors-list",
menuName:'业务领域',
path: "/dict-config/sectors-list",
parentPath:'/dict-config',
menuType:'system',
show:true,
],
},
{
name: "openness-list",
menuName:'开放程度',
path: "/dict-config/openness-list",
parentPath:'/dict-config',
menuType:'system',
show:true,
}
]
}
]
},
{
name:"index",
menuName:"首页",
menuName: "首页",
path: "/",
parentPath:null,
menuType:'font',
show:true,
},
{
dict_group_id: "2cb4f767-fad7-44f2-afa3-f055e15dd2b6",
menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
},
{
menuName: "管理中心",
path: "/manage",
name:"manage",
parentPath:null,
menuType:'manager',
show: true,
children:[{
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 0, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
children: [
{
menuName: "开发管理",
path: "/develop",
parentPath:null,
menuType:'manager',
show:true,
icon: "#bg-ic-ability",
children:[
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 0, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
icon: "bg-ic-ability",
children: [
{
name: "account-manage",
menuName:'系统账号管理',
parentPath:null,
menuType:'manager',
show:true,
menuName: "系统账号管理",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
path: "/develop/account",
linkPath: ["/develop/account/add"]
},
children: [
{
name: "account-add-manage",
menuName:'新建账号',
parentPath:'/develop/account',
menuType:'manager',
menuName: "新建账号",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 2, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
path: "/develop/account/add",
},
{
name: "account-detail-manage",
menuName:'账号详情',
parentPath: '/develop/account',
menuType:'manager',
menuName: "账号详情",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 2, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
path: "/develop/account/detail",
},
],
},
{
name: "menu-manage",
menuName:'菜单管理',
parentPath:null,
menuType:'manager',
show:true,
menuName: "菜单管理",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
path: "/develop/menu",
},
]
],
},
{
menuName: "系统管理",
path: "/system",
parentPath:null,
menuType:'manager',
show:true,
icon: "#bg-ic-ability",
children:[
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 0, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
icon: "bg-ic-ability",
children: [
{
name: "system-manage",
menuName:'组织管理',
parentPath:null,
menuType:'manager',
show:true,
menuName: "组织管理",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
path: "/system/organization",
},
children:[
{
name: "paltform-user-manage",
menuName:'新增平台用户',
parentPath: '/system/organization',
menuType:'manager',
show:false,
menuName: "新增平台用户",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 2, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
show: false,
path: "/system/organization/platform-user",
},
{
name: "system-user-manage",
menuName:'新增组织用户',
parentPath: '/system/organization',
menuType:'manager',
menuName: "新增组织用户",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 2, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
show: false,
path: "/system/organization/system-user",
},
{
name: "user-detail-manage",
menuName:'用户详情',
parentPath: '/system/organization',
menuType:'manager',
menuName: "用户详情",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 2, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
show: false,
path: "/system/organization/user-detail",
},
{
name: "org-detail-manage",
menuName:'组织详情',
parentPath: '/system/organization',
menuType:'manager',
menuName: "组织详情",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 2, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
show: false,
path: "/system/organization/org-detail",
},
]
},
{
name: "role-manage",
menuName:'角色管理',
parentPath:null,
menuType:'manager',
show:true,
menuName: "角色管理",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
path: "/system/role",
},
]
],
},
{
menuName: "配置管理",
path: "/config",
parentPath:null,
menuType:'manager',
show:true,
icon: "#bg-ic-ability",
children:[
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 0, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
icon: "bg-ic-ability",
children: [
{
name: "dict-manage",
menuName:'字典管理',
parentPath:null,
menuType:'manager',
show:true,
menuName: "字典管理",
dict_group_id: "09938937-3db9-47de-b967-7777ea4ebb2d",
menuType: 1, //system:64c156e0-bfff-4bfc-a63a-56effe130a25:apaas后管,能力注册页等 font:2cb4f767-fad7-44f2-afa3-f055e15dd2b6:apaas前台页 manager:09938937-3db9-47de-b967-7777ea4ebb2d:apaas管理中心 知识中心:26d3903a-863e-4efc-b53e-0fb8772ddaa4
path: "/config/dict",
},
]
],
},
],
},
]
},
]
];
function getName(str){
if(str=='/'){
return 'index'
}
let temp = str.slice(1)
temp = temp.replaceAll('/','-')
return temp
}
function getViews(path) {
// 首先把你需要动态路由的组件地址全部获取,示例项目主项目放入了main,如果直接放入page,需要去掉/main
let pathArr = path.split('/')
let modules = {}
switch (pathArr.length) {
case 2:
modules = import.meta.glob('../page/main/**/*.vue')
// 首先把你需要动态路由的组件地址全部获取,示例项目主项目放入了main,如果直接放入page,需要去掉/main
let pathArr = path.split("/");
let modules = {};
switch (pathArr.length) {
case 2:
modules = import.meta.glob("../page/main/**/*.vue");
break;
case 3:
modules = import.meta.glob('../page/main/**/*/*.vue')
case 3:
modules = import.meta.glob("../page/main/**/*/*.vue");
break;
case 4:
modules = import.meta.glob('../page/main/**/**/*/*.vue')
case 4:
modules = import.meta.glob("../page/main/**/**/*/*.vue");
break;
case 5:
modules = import.meta.glob('../page/main/**/**/**/*/*.vue')
case 5:
modules = import.meta.glob("../page/main/**/**/**/*/*.vue");
break;
default:
default:
break;
}
// 然后动态路由的时候这样来取
console.log(modules['../page/main' + path + '/index.vue']);
return modules['../page/main' + path + '/index.vue']
}
// 然后动态路由的时候这样来取
console.log(modules["../page/main" + path + "/index.vue"]);
return modules["../page/main" + path + "/index.vue"];
}
//处理路由方法
var menuToRouter = (menu)=>{
menu.forEach(e => {
if(e.children){
var menuToRouter = (menu) => {
menu.forEach((e) => {
e.name = getName(e.path)
if (e.children && e.menuType == 0) {
// 其他层级作为文件夹,只提供父级
e.component = () => import('../page/parent/parent.vue')
menuToRouter(e.children)
}else{
e.component = () => import("../page/parent/parent.vue");
menuToRouter(e.children);
} else if (e.children && e.menuType !== 0) {
console.log(`@/page/main${e.path}/index.vue`);
//叶子层级需要加载到对应文件
//对首页做兼容
if(e.path=='/'){
e.component = () => import('../page/main/index/index.vue')
}else{
e.component= getViews(e.path)
if (e.path == "/") {
e.component = () => import("../page/main/index/index.vue");
} else {
e.component = getViews(e.path);
}
}
});
}
menuToRouter(e.children);
} else {
console.log(`@/page/main${e.path}/index.vue`);
//叶子层级需要加载到对应文件
//对首页做兼容
if (e.path == "/") {
e.component = () => import("../page/main/index/index.vue");
} else {
e.component = getViews(e.path);
}
}
});
};
export default {
adminMenu,
menuToRouter
}
\ No newline at end of file
adminMenu,
menuToRouter,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment