Jelajahi Sumber

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

afc163 8 tahun lalu
induk
melakukan
c59298152c

+ 2 - 2
package.json

@@ -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",

+ 2 - 2
src/components/Authorized/demo/basic.md

@@ -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
 );
 ```

+ 73 - 0
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 = <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,
+);
+```

+ 1 - 1
src/components/Ellipsis/index.js

@@ -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>);
     }

+ 1 - 1
src/components/GlobalFooter/demo/basic.md

@@ -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,

+ 6 - 5
src/layouts/UserLayout.js

@@ -1,5 +1,5 @@
 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>