diff --git a/src/components/Authorized/demo/secured.md b/src/components/Authorized/demo/secured.md new file mode 100644 index 0000000000000000000000000000000000000000..2ff7c2de0a0366d0286014d8f7f3cd8e8434b962 --- /dev/null +++ b/src/components/Authorized/demo/secured.md @@ -0,0 +1,73 @@ +--- +order: 1 +title: + zh-CN: 注解 + en-US: secured +--- + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const { Secured } = RenderAuthorized('user'); +const noMatch = ; + +const havePermission = () => { + return false; +}; + +const havePermissionAsync = new Promise((resolve, reject) => { + // Call reslove on behalf of passed + setTimeout(() => reslove(), 1000); +}); + +@Secured('admin', noMatch) +class TestSecuredString extends React.Component { + render() { + ; + } +} + +@Secured(['user', 'admin'], noMatch) +class TestSecuredArray extends React.Component { + render() { + ; + } +} + +@Secured(havePermission, noMatch) +class TestSecuredFunction extends React.Component { + render() { + ; + } +} + +@Secured(havePermissionAsync, noMatch) +class TestSecuredPromise extends React.Component { + render() { + ; + } +} + +ReactDOM.render( +
+ + + + +
, + mountNode, +); +```