mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
Merge branch 'v2' of https://github.com/maxkb-dev/maxkb into v2
This commit is contained in:
commit
b646163a62
|
|
@ -1,4 +1,4 @@
|
|||
import { hasPermission } from '@/utils/permission/index'
|
||||
import { hasPermission, set_next_route } from '@/utils/permission/index'
|
||||
import NProgress from 'nprogress'
|
||||
import {
|
||||
createRouter,
|
||||
|
|
@ -42,6 +42,7 @@ router.beforeEach(
|
|||
await user.profile()
|
||||
}
|
||||
}
|
||||
set_next_route(to)
|
||||
// 判断是否有菜单权限
|
||||
if (to.meta.permission ? hasPermission(to.meta.permission as any, 'OR') : true) {
|
||||
next()
|
||||
|
|
|
|||
|
|
@ -45,8 +45,11 @@ const hasPermissionChild = (
|
|||
const roleOk = roleList.some((r) =>
|
||||
role.includes(isFunction(r) ? (r as CRF)().toString() : r.toString()),
|
||||
)
|
||||
const editionList= permission.editionList
|
||||
const editionOK = permission.editionList.length>0?editionList.some(e=>edition.toString()==e.toString()):true
|
||||
const editionList = permission.editionList
|
||||
const editionOK =
|
||||
permission.editionList.length > 0
|
||||
? editionList.some((e) => edition.toString() == e.toString())
|
||||
: true
|
||||
|
||||
return permission.compare === 'AND'
|
||||
? permissionOk && roleOk && editionOK
|
||||
|
|
@ -84,3 +87,14 @@ export const hasPermission = (
|
|||
return hasPermissionChild(permission)
|
||||
}
|
||||
}
|
||||
|
||||
const R = {
|
||||
to: null,
|
||||
}
|
||||
export const get_next_route = () => {
|
||||
return R.to
|
||||
}
|
||||
|
||||
export const set_next_route = (to: any) => {
|
||||
R.to = to
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue