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