Commit ecef6259 authored by jim's avatar jim

Modify the document

parent 31b8213f
---
order: 1
title:
zh-CN: 使用数组作为参数
en-US: Use Array as a parameter
---
Use Array as a parameter
```jsx
import RenderAuthorized from 'ant-design-pro/lib/Authorized';
import { Alert } from 'antd';
const Authorized = RenderAuthorized('user');
const noMatch = <Alert message="No permission." type="error" showIcon />;
ReactDOM.render(
<Authorized authority={['user', 'admin']} noMatch={noMatch}>
<Alert message="Use Array as a parameter passed!" type="success" showIcon />
</Authorized>,
mountNode,
);
```
---
order: 2
title:
zh-CN: 使用方法作为参数
en-US: Use function as a parameter
---
Use Function as a parameter
```jsx
import RenderAuthorized from 'ant-design-pro/lib/Authorized';
import { Alert } from 'antd';
const Authorized = RenderAuthorized('user');
const noMatch = <Alert message="No permission." type="error" showIcon />;
const havePermission = () => {
return false;
};
ReactDOM.render(
<Authorized authority={havePermission} noMatch={noMatch}>
<Alert
message="Use Function as a parameter passed!"
type="success"
showIcon
/>
</Authorized>,
mountNode,
);
```
---
order: 0
title:
zh-CN:
en-US: Basic
zh-CN: 本使用
en-US: Basic use
---
Authorized demo used
Basic use
```jsx
import RenderAuthorized from 'ant-design-pro/lib/Authorized';
......@@ -14,31 +14,12 @@ import { Alert } from 'antd';
const Authorized = RenderAuthorized('user');
const noMatch = <Alert message="No permission." type="error" showIcon />;
const havePermission = () => {
return false;
};
const havePermissionAsync = new Promise((resolve,reject)=>{
// Call resolve on behalf of passed
setTimeout( ()=> resolve() , 1000)
});
ReactDOM.render(
<div>
<Authorized authority="admin" noMatch={noMatch}>
<Alert message="user Passed!" type="success" showIcon />
</Authorized>
<Authorized authority={['user','admin']} noMatch={noMatch}>
<Alert message="Use Array as a parameter passed!" type="success" showIcon />
</Authorized>
<Authorized authority={havePermission} noMatch={noMatch}>
<Alert message="Use function as a parameter passed!" type="success" showIcon />
</Authorized>
<Authorized authority={havePermissionAsync} noMatch={noMatch}>
<Alert message="Use Promise as a parameter passed!" type="success" showIcon />
</Authorized>
</div>,
mountNode
mountNode,
);
```
---
order: 1
order: 3
title:
zh-CN: 注解
en-US: secured
zh-CN: 注解基本使用
en-US: Basic use secured
---
secured demo used
......@@ -12,63 +12,16 @@ import RenderAuthorized from 'ant-design-pro/lib/Authorized';
import { Alert } from 'antd';
const { Secured } = RenderAuthorized('user');
const noMatch = <Alert message="No permission." type="error" showIcon />;
const havePermission = () => {
return false;
};
const havePermissionAsync = new Promise((resolve, reject) => {
// Call resolve on behalf of passed
setTimeout(() => resolve(), 1000);
});
@Secured('admin', noMatch)
@Secured('admin')
class TestSecuredString extends React.Component {
render() {
<Alert message="user Passed!" type="success" showIcon />;
}
}
@Secured(['user', 'admin'], noMatch)
class TestSecuredArray extends React.Component {
render() {
<Alert
message="Use Array as a parameter passed!"
type="success"
showIcon
/>;
}
}
@Secured(havePermission, noMatch)
class TestSecuredFunction extends React.Component {
render() {
<Alert
message="Use function as a parameter passed!"
type="success"
showIcon
/>;
}
}
@Secured(havePermissionAsync, noMatch)
class TestSecuredPromise extends React.Component {
render() {
<Alert
message="Use Promise as a parameter passed!"
type="success"
showIcon
/>;
}
}
ReactDOM.render(
<div>
<TestSecuredString />
<TestSecuredArray />
<TestSecuredFunction />
<TestSecuredPromise />
</div>,
mountNode,
);
......
......@@ -13,7 +13,12 @@ const { Secured } = Authorized;
const targetTime = new Date().getTime() + 3900000;
@Secured('admin')
// use permission as a parameter
const havePermissionAsync = new Promise((resolve) => {
// Call resolve on behalf of passed
setTimeout(() => resolve(), 1000);
});
@Secured(havePermissionAsync)
@connect(({ monitor, loading }) => ({
monitor,
loading: loading.models.monitor,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment