优化
This commit is contained in:
@@ -69,7 +69,7 @@ export function summarizePermissionSelection(permissions: Permission[], selected
|
||||
const selectedPermissions = permissions.filter((permission) => selected.has(permission.id))
|
||||
|
||||
return {
|
||||
menuCount: selectedPermissions.filter((permission) => permission.type === '菜单').length,
|
||||
menuCount: selectedPermissions.filter((permission) => ['菜单', '页面'].includes(permission.type)).length,
|
||||
actionCount: selectedPermissions.filter((permission) => ['按钮', '接口'].includes(permission.type)).length,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,18 @@ describe('mapPlatformPermission', () => {
|
||||
status: 'ACTIVE',
|
||||
})).toMatchObject({ id: '2082813911786024962', parentId: '2082813911786024961', type: '按钮' })
|
||||
})
|
||||
|
||||
it.each([
|
||||
['MENU', '菜单'],
|
||||
['PAGE', '页面'],
|
||||
['BUTTON', '按钮'],
|
||||
['API', '接口'],
|
||||
] as const)('maps backend permission type %s without collapsing it', (permissionType, type) => {
|
||||
expect(mapPlatformPermission({
|
||||
id: '1', tenantId: '0', appCode: 'PLATFORM', permissionType, parentId: '0',
|
||||
permissionCode: `platform:test:${permissionType.toLowerCase()}`, permissionName: type,
|
||||
routePath: null, httpMethod: permissionType === 'API' ? 'GET' : null,
|
||||
sortNo: 10, status: 'ACTIVE',
|
||||
})).toMatchObject({ type })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ export function mapPlatformPermission(item: PlatformPermissionResource): Permiss
|
||||
parentId: parentId === '0' ? null : parentId,
|
||||
name: item.permissionName,
|
||||
code: item.permissionCode,
|
||||
type: item.permissionType === 'BUTTON' ? '按钮' : '菜单',
|
||||
type: ({ MENU: '菜单', PAGE: '页面', BUTTON: '按钮', API: '接口' } as const)[item.permissionType],
|
||||
path: item.routePath ?? '',
|
||||
method: item.httpMethod ?? '-',
|
||||
status: item.status === 'ACTIVE' ? '启用' : '停用',
|
||||
|
||||
Reference in New Issue
Block a user