feat: align frontend document and rule management flows
This commit is contained in:
@@ -95,9 +95,25 @@ export function usePermission() {
|
||||
return [];
|
||||
};
|
||||
|
||||
// 优先使用 permissionMap 中的权限,如果没有则使用交叉评查默认权限
|
||||
const currentPermissions = permissionMap[currentPath]?.length > 0
|
||||
? permissionMap[currentPath]
|
||||
const getInheritedRoutePermissions = (): string[] => {
|
||||
if (permissionMap[currentPath]?.length > 0) {
|
||||
return permissionMap[currentPath];
|
||||
}
|
||||
|
||||
const segments = currentPath.split('/').filter(Boolean);
|
||||
for (let i = segments.length - 1; i >= 1; i -= 1) {
|
||||
const candidate = `/${segments.slice(0, i).join('/')}`;
|
||||
if (permissionMap[candidate]?.length > 0) {
|
||||
return permissionMap[candidate];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
// 优先使用当前路由权限,其次继承父级导航权限,再降级到交叉评查默认权限
|
||||
const currentPermissions = getInheritedRoutePermissions().length > 0
|
||||
? getInheritedRoutePermissions()
|
||||
: getCrossCheckingPermissions();
|
||||
|
||||
// 向后兼容:如果存在旧的permissions数组,也要支持
|
||||
|
||||
Reference in New Issue
Block a user