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