ant-design-pro 1.0.0 V4
最近需要项目需要用扫码登录,因此就使用antd pro提供的鉴权能力来做
Authorized.ts
提供初始化路由组件和重载路由的函数
import RenderAuthorize from '@/components/Authorized';
import { getAuthority } from'./authority';/*eslint-disable eslint-comments/disable-enable-pair*/
/*eslint-disable import/no-mutable-exports*/let Authorized=RenderAuthorize(getAuthority());//Reload the rights component
const reloadAuthorized = (): void =>{
Authorized=RenderAuthorize(getAuthority());
};
export { reloadAuthorized };
exportdefault Authorized;
这里调用 RenderAuthorize(getAuthority()),如果我当前localStorage存的是antd-pro-authority:["admin"] ,则调用实际是 RenderAuthorize(["admin"]) ,直接导至执行以下函数,返回权限组件components/Authorized/Authorized,其中 CURRENT 返回的是当前权限,