bandeng-frontend
v1.0.3
Published
Frontend public dependencies
Readme
bandeng-frontend
简介
这是一个Bandeng前端公共逻辑依赖包,提供基于角色与权限点的客户端权限判断辅助函数。
安装
npm install bandeng-frontend快速使用(TypeScript)
import { useAuthority } from 'bandeng-frontend';
const userInfo = {
// ...用户信息
};
const { isHasAuthority } = useAuthority(userInfo);
console.log(isHasAuthority('1002/2001', 'edit'));公开 API(简要)
useAuthority(userInfo)— 命名导出,传入用户信息,返回包含isHasAuthority的对象。isHasAuthority(code, actionType)— 判断权限,actionType∈ {'copy','add','del','edit','view'},返回 boolean。getAllAuthorityMenus(agentType?)— 返回用于构建权限菜单/树的TreeNode[]。getAuthorityMenusByUser(userInfo)— 返回该用户可见的权限菜单(TreeNode[])。getDefaultAuthorityRulesByUser(userInfo)— 返回基于用户角色/配置的默认权限码数组(string[])。mergeAuthoritys(selectedAuthoritys)— 将所选权限项合并为便于存储/传输的权限码集合(string[])。demergeAuthoritys(authority)— 将合并的权限集合拆解为单项列表(string[])。
