fix: route ui (#3371)

This commit is contained in:
shaohuzhang1 2025-06-24 17:00:50 +08:00 committed by GitHub
parent 2fe953092f
commit 01a423235f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View File

@ -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()

View File

@ -46,7 +46,10 @@ const hasPermissionChild = (
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
}