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 NProgress from 'nprogress'
|
||||||
import {
|
import {
|
||||||
createRouter,
|
createRouter,
|
||||||
@ -42,6 +42,7 @@ router.beforeEach(
|
|||||||
await user.profile()
|
await user.profile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set_next_route(to)
|
||||||
// 判断是否有菜单权限
|
// 判断是否有菜单权限
|
||||||
if (to.meta.permission ? hasPermission(to.meta.permission as any, 'OR') : true) {
|
if (to.meta.permission ? hasPermission(to.meta.permission as any, 'OR') : true) {
|
||||||
next()
|
next()
|
||||||
|
|||||||
@ -45,8 +45,11 @@ const hasPermissionChild = (
|
|||||||
const roleOk = roleList.some((r) =>
|
const roleOk = roleList.some((r) =>
|
||||||
role.includes(isFunction(r) ? (r as CRF)().toString() : r.toString()),
|
role.includes(isFunction(r) ? (r as CRF)().toString() : r.toString()),
|
||||||
)
|
)
|
||||||
const editionList= permission.editionList
|
const editionList = permission.editionList
|
||||||
const editionOK = permission.editionList.length>0?editionList.some(e=>edition.toString()==e.toString()):true
|
const editionOK =
|
||||||
|
permission.editionList.length > 0
|
||||||
|
? editionList.some((e) => edition.toString() == e.toString())
|
||||||
|
: true
|
||||||
|
|
||||||
return permission.compare === 'AND'
|
return permission.compare === 'AND'
|
||||||
? permissionOk && roleOk && editionOK
|
? permissionOk && roleOk && editionOK
|
||||||
@ -84,3 +87,14 @@ export const hasPermission = (
|
|||||||
return hasPermissionChild(permission)
|
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
Block a user