Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
6651bc71
Commit
6651bc71
authored
May 11, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
df38594c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
38 deletions
+50
-38
iview-admin/src/libs/util.js
+49
-37
iview-admin/src/store/module/app.js
+1
-1
No files found.
iview-admin/src/libs/util.js
View file @
6651bc71
...
...
@@ -6,36 +6,36 @@ const { title, cookieExpires, useI18n } = config
export
const
TOKEN_KEY
=
'token'
export
const
btnAuthFilter
=
(
metainfo
,
user
)
=>
{
// console.log(".................................................",metainfo.list)
// let authbtns=[]
// let keyswithauth=Object.keys(metainfo.auths).filter(authname=>{
// let hasAuth=user.access.some(authitem=>{
// return authitem.auths.indexOf(authname)>=0
// })
// return hasAuth
// })
// if(keyswithauth){
// keyswithauth.forEach(k=>{
// metainfo.auths[k].forEach(bt=>{
// authbtns.push(bt)
// })
// })
// }
// metainfo.auths=authbtns
let
authbtns
=
[]
let
keyswithauth
=
Object
.
keys
(
metainfo
.
auths
).
filter
(
authname
=>
{
export
const
btnAuthFilter
=
(
metainfo
,
user
)
=>
{
// console.log(".................................................",metainfo.list)
// let authbtns=[]
// let keyswithauth=Object.keys(metainfo.auths).filter(authname=>{
// let hasAuth=user.access.some(authitem=>{
// return authitem.auths.indexOf(authname)>=0
// })
// return hasAuth
// })
// if(keyswithauth){
// keyswithauth.forEach(k=>{
// metainfo.auths[k].forEach(bt=>{
// authbtns.push(bt)
// })
// })
// }
// metainfo.auths=authbtns
let
authbtns
=
[]
let
keyswithauth
=
Object
.
keys
(
metainfo
.
auths
).
filter
(
authname
=>
{
return
true
})
if
(
keyswithauth
)
{
keyswithauth
.
forEach
(
k
=>
{
metainfo
.
auths
[
k
].
forEach
(
bt
=>
{
if
(
keyswithauth
)
{
keyswithauth
.
forEach
(
k
=>
{
metainfo
.
auths
[
k
].
forEach
(
bt
=>
{
authbtns
.
push
(
bt
)
})
})
}
metainfo
.
auths
=
authbtns
return
metainfo
metainfo
.
auths
=
authbtns
return
metainfo
}
export
const
setToken
=
(
token
)
=>
{
...
...
@@ -52,22 +52,34 @@ export const hasChild = (item) => {
return
item
.
children
&&
item
.
children
.
length
!==
0
}
const
showThisMenuEle
=
(
item
,
access
,
user
)
=>
{
if
(
item
.
name
==
"sysmg"
&&
!
user
.
isSuper
&&
user
.
isAdmin
){
if
(
!
config
.
fromappkey
){
return
false
const
showThisMenuEle
=
(
item
,
access
,
user
)
=>
{
//如果是系统管理菜单,如果当前不是超级管理员,并且是租户
if
(
item
.
name
==
"sysmg"
&&
!
user
.
isSuper
&&
user
.
isAdmin
)
{
if
(
config
.
fromappkey
!=
config
.
appkey
)
{
//表示当前是外部应用跳转进入平台管理
return
true
}
else
{
// 否则是在平台应用,非跳转进入,那么就默认不显示
return
false
}
}
let
fts
=
user
.
access
.
filter
(
it
=>
{
return
it
.
codepath
.
indexOf
(
item
.
name
)
>=
0
})
if
(
fts
.
length
>
0
)
{
return
true
}
else
{
if
(
!
user
.
isSuper
&&
!
user
.
isAdmin
)
{
return
false
}
else
{
return
true
}
}
if
(
item
.
meta
&&
item
.
meta
.
access
&&
item
.
meta
.
access
.
length
)
{
if
(
hasOneOf
(
item
.
meta
.
access
,
access
))
return
true
else
return
false
}
else
return
true
}
/**
* @param {Array} list 通过路由列表得到菜单列表
* @returns {Array}
*/
export
const
getMenuByRouter
=
(
list
,
access
,
user
)
=>
{
export
const
getMenuByRouter
=
(
list
,
access
,
user
)
=>
{
let
res
=
[]
forEach
(
list
,
item
=>
{
if
(
!
item
.
meta
||
(
item
.
meta
&&
!
item
.
meta
.
hideInMenu
))
{
...
...
@@ -76,11 +88,11 @@ export const getMenuByRouter = (list, access,user) => {
name
:
item
.
name
,
meta
:
item
.
meta
}
if
((
hasChild
(
item
)
||
(
item
.
meta
&&
item
.
meta
.
showAlways
))
&&
showThisMenuEle
(
item
,
access
,
user
))
{
obj
.
children
=
getMenuByRouter
(
item
.
children
,
access
)
if
((
hasChild
(
item
)
||
(
item
.
meta
&&
item
.
meta
.
showAlways
))
&&
showThisMenuEle
(
item
,
access
,
user
))
{
obj
.
children
=
getMenuByRouter
(
item
.
children
,
access
,
user
)
}
if
(
item
.
meta
&&
item
.
meta
.
href
)
obj
.
href
=
item
.
meta
.
href
if
(
showThisMenuEle
(
item
,
access
,
user
))
res
.
push
(
obj
)
if
(
showThisMenuEle
(
item
,
access
,
user
))
res
.
push
(
obj
)
}
})
return
res
...
...
@@ -115,7 +127,7 @@ export const getBreadCrumbList = (route, homeRoute) => {
res
=
res
.
filter
(
item
=>
{
return
!
item
.
meta
.
hideInMenu
})
let
rtn
=
[{
...
homeItem
,
to
:
homeRoute
.
path
},
...
res
]
let
rtn
=
[{
...
homeItem
,
to
:
homeRoute
.
path
},
...
res
]
return
rtn
}
...
...
iview-admin/src/store/module/app.js
View file @
6651bc71
...
...
@@ -36,7 +36,7 @@ export default {
hasReadErrorPage
:
false
},
getters
:
{
menuList
:
(
state
,
getters
,
rootState
)
=>
getMenuByRouter
(
routers
,
rootState
.
user
.
access
,
rootState
.
user
),
menuList
:
(
state
,
getters
,
rootState
)
=>
getMenuByRouter
(
routers
,
rootState
.
user
.
access
,
rootState
.
user
.
userobj
),
errorCount
:
state
=>
state
.
errorList
.
length
},
mutations
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment