route 修改
This commit is contained in:
parent
5d89acd012
commit
ea1cffeff6
|
@ -43,7 +43,6 @@ const routes = [
|
|||
"title": "控制台",
|
||||
"icon": "el-icon-monitor",
|
||||
"affix": true,
|
||||
|
||||
},
|
||||
"component": "home"
|
||||
},
|
||||
|
@ -656,7 +655,8 @@ const routes = [
|
|||
"meta": {
|
||||
"title": "运维",
|
||||
"icon": "el-icon-wallet-filled",
|
||||
"type": "menu"
|
||||
"type": "menu",
|
||||
"perms": ["ops"]
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
|
@ -665,6 +665,7 @@ const routes = [
|
|||
"meta": {
|
||||
"title": "菜单管理",
|
||||
"icon": "el-icon-fold",
|
||||
"perms": ["menu"]
|
||||
},
|
||||
"component": "ops/menu"
|
||||
},
|
||||
|
@ -674,6 +675,7 @@ const routes = [
|
|||
"meta": {
|
||||
"title": "请求日志",
|
||||
"icon": "el-icon-fold",
|
||||
"perms": ["log"]
|
||||
},
|
||||
"component": "ops/log_request"
|
||||
},
|
||||
|
@ -683,6 +685,7 @@ const routes = [
|
|||
"meta": {
|
||||
"title": "第三方日志",
|
||||
"icon": "el-icon-fold",
|
||||
"perms": ["third_log"]
|
||||
},
|
||||
"component": "ops/thirdLogs"
|
||||
},
|
||||
|
@ -692,6 +695,7 @@ const routes = [
|
|||
"meta": {
|
||||
"title": "文件日志",
|
||||
"icon": "el-icon-fold",
|
||||
"perms": ["file_log"]
|
||||
},
|
||||
"component": "ops/files"
|
||||
},
|
||||
|
|
|
@ -69,7 +69,7 @@ router.beforeEach(async (to, from, next) => {
|
|||
// let apiMenu = tool.data.get("MENU") || []
|
||||
let permissions = tool.data.get("PERMISSIONS");
|
||||
let userMenu = userRoutes;
|
||||
if(permissions.indexOf('superuser')==-1){
|
||||
if (permissions.indexOf('superuser') == -1) {
|
||||
userMenu = treeFilter(userRoutes, node => {
|
||||
return node.meta.perms ? node.meta.perms.filter(item => permissions.indexOf(item) > -1).length > 0 : true
|
||||
});
|
||||
|
@ -109,7 +109,7 @@ router.sc_getMenu = () => {
|
|||
// var apiMenu = tool.data.get("MENU") || []
|
||||
let permissions = tool.data.get("PERMISSIONS");
|
||||
let userMenu = userRoutes;
|
||||
if(permissions.indexOf('superuser')==-1){
|
||||
if (permissions.indexOf('superuser') == -1) {
|
||||
userMenu = treeFilter(userRoutes, node => {
|
||||
return node.meta.perms ? node.meta.perms.filter(item => permissions.indexOf(item) > -1).length > 0 : true
|
||||
});
|
||||
|
@ -187,8 +187,8 @@ function treeFilter(tree, func) {
|
|||
|
||||
function hasPerm(perms_need, perms_have) {
|
||||
let has = false
|
||||
for(var m=0;m<perms_need.length;m++){
|
||||
if(perms_have.indexOf(perms_need[m])>-1){
|
||||
for (var m = 0; m < perms_need.length; m++) {
|
||||
if (perms_have.indexOf(perms_need[m]) > -1) {
|
||||
has = true
|
||||
}
|
||||
}
|
||||
|
@ -196,35 +196,35 @@ function hasPerm(perms_need, perms_have) {
|
|||
}
|
||||
|
||||
function checkRoute(routes, perms) {
|
||||
if(perms.indexOf('superuser')>-1){
|
||||
if (perms.indexOf('superuser') > -1) {
|
||||
return routes
|
||||
}
|
||||
for (var i = 0; i < routes.length; i++) {
|
||||
if (routes[i].meta && routes[i].meta.perms) {
|
||||
let has = hasPerm(routes[i].meta.perms, perms)
|
||||
if(!has){
|
||||
routes.splice(i,1)
|
||||
if (!has) {
|
||||
routes.splice(i, 1)
|
||||
}
|
||||
else if (routes[i].children){
|
||||
for (var m = 0; m < routes[i].children.length; m++){
|
||||
else if (routes[i].children) {
|
||||
for (var m = 0; m < routes[i].children.length; m++) {
|
||||
let child = routes[i].children[m]
|
||||
if (child.meta && child.meta.perms) {
|
||||
let has = hasPerm(child.meta.perms, perms)
|
||||
if(!has){
|
||||
routes[i].children.splice(m,1)
|
||||
if (!has) {
|
||||
routes[i].children.splice(m, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (routes[i].children){
|
||||
for (var m = 0; m < routes[i].children.length; m++){
|
||||
else if (routes[i].children) {
|
||||
for (var m = 0; m < routes[i].children.length; m++) {
|
||||
let child = routes[i].children[m]
|
||||
console.log(m, child)
|
||||
if (child.meta && child.meta.perms) {
|
||||
let has = hasPerm(child.meta.perms, perms)
|
||||
if(!has){
|
||||
routes[i].children.splice(m,1)
|
||||
if (!has) {
|
||||
routes[i].children.splice(m, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue