2019-02-28 13:36:32 +08:00
|
|
|
import React, { PureComponent } from 'react';
|
2019-03-01 18:15:12 +08:00
|
|
|
import UrlsContext from '../../layouts/UrlsContext';
|
2019-02-28 13:36:32 +08:00
|
|
|
|
|
|
|
// 用于控制权限
|
|
|
|
class AuthorityControl extends PureComponent {
|
|
|
|
render() {
|
|
|
|
const { authKey, children } = this.props;
|
|
|
|
return (
|
2019-03-01 18:15:12 +08:00
|
|
|
<UrlsContext.Consumer>
|
2019-02-28 13:36:32 +08:00
|
|
|
{context => {
|
|
|
|
const { authList } = context;
|
|
|
|
return <div>{authList[authKey] ? children : '无权限'}</div>;
|
|
|
|
}}
|
2019-03-01 18:15:12 +08:00
|
|
|
</UrlsContext.Consumer>
|
2019-02-28 13:36:32 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AuthorityControl;
|