Skip to content

Commit 01a4232

Browse files
authored
fix: route ui (#3371)
1 parent 2fe9530 commit 01a4232

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

ui/src/router/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { hasPermission } from '@/utils/permission/index'
1+
import { hasPermission, set_next_route } from '@/utils/permission/index'
22
import NProgress from 'nprogress'
33
import {
44
createRouter,
@@ -42,6 +42,7 @@ router.beforeEach(
4242
await user.profile()
4343
}
4444
}
45+
set_next_route(to)
4546
// 判断是否有菜单权限
4647
if (to.meta.permission ? hasPermission(to.meta.permission as any, 'OR') : true) {
4748
next()

ui/src/utils/permission/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ const hasPermissionChild = (
4545
const roleOk = roleList.some((r) =>
4646
role.includes(isFunction(r) ? (r as CRF)().toString() : r.toString()),
4747
)
48-
const editionList= permission.editionList
49-
const editionOK = permission.editionList.length>0?editionList.some(e=>edition.toString()==e.toString()):true
48+
const editionList = permission.editionList
49+
const editionOK =
50+
permission.editionList.length > 0
51+
? editionList.some((e) => edition.toString() == e.toString())
52+
: true
5053

5154
return permission.compare === 'AND'
5255
? permissionOk && roleOk && editionOK
@@ -84,3 +87,14 @@ export const hasPermission = (
8487
return hasPermissionChild(permission)
8588
}
8689
}
90+
91+
const R = {
92+
to: null,
93+
}
94+
export const get_next_route = () => {
95+
return R.to
96+
}
97+
98+
export const set_next_route = (to: any) => {
99+
R.to = to
100+
}

0 commit comments

Comments
 (0)