动态菜单和动态路由的 antd pro

index.d.ts 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import * as React from 'react';
  2. import { RouteProps } from 'react-router';
  3. type authorityFN = (currentAuthority?: string) => boolean;
  4. type authority = string | Array<string> | authorityFN | Promise<any>;
  5. export type IReactComponent<P = any> =
  6. | React.StatelessComponent<P>
  7. | React.ComponentClass<P>
  8. | React.ClassicComponentClass<P>;
  9. interface Secured {
  10. (authority: authority, error?: React.ReactNode): <T extends IReactComponent>(target: T) => T;
  11. }
  12. export interface AuthorizedRouteProps extends RouteProps {
  13. authority: authority;
  14. }
  15. export class AuthorizedRoute extends React.Component<AuthorizedRouteProps, any> {}
  16. interface check {
  17. <T extends IReactComponent, S extends IReactComponent>(
  18. authority: authority,
  19. target: T,
  20. Exception: S
  21. ): T | S;
  22. }
  23. interface AuthorizedProps {
  24. authority: authority;
  25. noMatch?: React.ReactNode;
  26. }
  27. export class Authorized extends React.Component<AuthorizedProps, any> {
  28. static Secured: Secured;
  29. static AuthorizedRoute: typeof AuthorizedRoute;
  30. static check: check;
  31. }
  32. declare function renderAuthorize(currentAuthority: string): typeof Authorized;
  33. export default renderAuthorize;