Commit c5929815 authored by afc163's avatar afc163

Merge branch 'master' of github.com:ant-design/ant-design-pro

parents cf41067c 57767505
......@@ -6,8 +6,8 @@
"scripts": {
"precommit": "npm run lint-staged",
"start": "cross-env DISABLE_ESLINT=true roadhog dev",
"start:no-proxy": "cross-env NO_PROXY=true roadhog dev",
"build": "roadhog build",
"start:no-proxy": "cross-env NO_PROXY=true DISABLE_ESLINT=true roadhog dev",
"build": "cross-env DISABLE_ESLINT=true roadhog build",
"site": "roadhog-api-doc static && gh-pages -d dist",
"analyze": "roadhog build --analyze",
"lint:style": "stylelint \"src/**/*.less\" --syntax less",
......
......@@ -36,7 +36,7 @@ ReactDOM.render(
<Authorized authority={havePermissionAsync} noMatch={noMatch}>
<Alert message="Use Promise as a parameter passed!" type="success" showIcon />
</Authorized>
</div>
mountNode,
</div>,
mountNode
);
```
---
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 = <Alert message="No permission." type="error" showIcon />;
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() {
<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,
);
```
......@@ -171,7 +171,7 @@ export default class Ellipsis extends Component {
<div id={id} className={cls} {...restProps}>
<style>{style}</style>
{
tooltip ? (<Tooltip title={text}>{children}</Tooltip>) : children
tooltip ? (<Tooltip title={children}>{children}</Tooltip>) : children
}
</div>);
}
......
......@@ -15,7 +15,7 @@ const links = [{
title: '帮助',
href: '',
}, {
key: 'github'
key: 'github',
title: <Icon type="github" />,
href: 'https://github.com/ant-design/ant-design-pro',
blankTarget: true,
......
import React from 'react';
import { Link, Route } from 'dva/router';
import { Link, Redirect, Switch, Route } from 'dva/router';
import DocumentTitle from 'react-document-title';
import { Icon } from 'antd';
import GlobalFooter from '../components/GlobalFooter';
......@@ -47,8 +47,8 @@ class UserLayout extends React.PureComponent {
</div>
<div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
</div>
{
getRoutes(match.path, routerData).map(item =>
<Switch>
{getRoutes(match.path, routerData).map(item =>
(
<Route
key={item.key}
......@@ -57,8 +57,9 @@ class UserLayout extends React.PureComponent {
exact={item.exact}
/>
)
)
}
)}
<Redirect exact from="/user" to="/user/login" />
</Switch>
<GlobalFooter className={styles.footer} links={links} copyright={copyright} />
</div>
</DocumentTitle>
......
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