From c036c8626102b017c768082d18ee87c4eef8892c Mon Sep 17 00:00:00 2001 From: jim Date: Tue, 9 Jan 2018 16:11:56 +0800 Subject: [PATCH] add secured doc --- src/components/Authorized/demo/secured.md | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/components/Authorized/demo/secured.md diff --git a/src/components/Authorized/demo/secured.md b/src/components/Authorized/demo/secured.md new file mode 100644 index 00000000..2ff7c2de --- /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, +); +``` -- GitLab