Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyang
sts网站
Commits
c2a179e9
Commit
c2a179e9
authored
Oct 20, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增认证对象简化权限验证
parent
519ea854
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
auth.js
ruoyi-ui/src/plugins/auth.js
+60
-0
index.js
ruoyi-ui/src/plugins/index.js
+3
-0
No files found.
ruoyi-ui/src/plugins/auth.js
0 → 100644
View file @
c2a179e9
import
store
from
'@/store'
function
authPermission
(
permission
)
{
const
all_permission
=
"*:*:*"
;
const
permissions
=
store
.
getters
&&
store
.
getters
.
permissions
if
(
permission
&&
permission
.
length
>
0
)
{
return
permissions
.
some
(
v
=>
{
return
all_permission
===
v
||
v
===
permission
})
}
else
{
return
false
}
}
function
authRole
(
role
)
{
const
super_admin
=
"admin"
;
const
roles
=
store
.
getters
&&
store
.
getters
.
roles
if
(
role
&&
role
.
length
>
0
)
{
return
roles
.
some
(
v
=>
{
return
super_admin
===
v
||
v
===
role
})
}
else
{
return
false
}
}
export
default
{
// 验证用户是否具备某权限
hasPermi
(
permission
)
{
return
authPermission
(
permission
);
},
// 验证用户是否含有指定权限,只需包含其中一个
hasPermiOr
(
permissions
)
{
return
permissions
.
some
(
item
=>
{
return
authPermission
(
item
)
})
},
// 验证用户是否含有指定权限,必须全部拥有
hasPermiAnd
(
permissions
)
{
return
permissions
.
every
(
item
=>
{
return
authPermission
(
item
)
})
},
// 验证用户是否具备某角色
hasRole
(
role
)
{
return
authRole
(
role
);
},
// 验证用户是否含有指定角色,只需包含其中一个
hasRoleOr
(
roles
)
{
return
roles
.
some
(
item
=>
{
return
authRole
(
item
)
})
},
// 验证用户是否含有指定角色,必须全部拥有
hasRoleAnd
(
roles
)
{
return
roles
.
every
(
item
=>
{
return
authRole
(
item
)
})
}
}
ruoyi-ui/src/plugins/index.js
View file @
c2a179e9
import
auth
from
'./auth'
import
cache
from
'./cache'
import
modal
from
'./modal'
import
download
from
'./download'
export
default
{
install
(
Vue
)
{
// 认证对象
Vue
.
prototype
.
$auth
=
auth
// 缓存对象
Vue
.
prototype
.
$cache
=
cache
// 模态框对象
...
...
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