Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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()
Expand Down
18 changes: 16 additions & 2 deletions ui/src/utils/permission/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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