Commit cafec890 authored by jim's avatar jim

fix #843 Modify permissions component logic

parent c2d19798
...@@ -38,9 +38,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { ...@@ -38,9 +38,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
// Promise 倄理 // Promise 倄理
if (isPromise(authority)) { if (isPromise(authority)) {
return () => ( return <PromiseRender ok={target} error={Exception} promise={authority} />;
<PromiseRender ok={target} error={Exception} promise={authority} />
);
} }
// Function 倄理 // Function 倄理
......
...@@ -3,9 +3,9 @@ import { Spin } from 'antd'; ...@@ -3,9 +3,9 @@ import { Spin } from 'antd';
export default class PromiseRender extends React.PureComponent { export default class PromiseRender extends React.PureComponent {
state = { state = {
component: false, component: null,
}; };
async componentDidMount() { componentDidMount() {
this.props.promise this.props.promise
.then(() => { .then(() => {
this.setState({ this.setState({
...@@ -14,7 +14,7 @@ export default class PromiseRender extends React.PureComponent { ...@@ -14,7 +14,7 @@ export default class PromiseRender extends React.PureComponent {
}) })
.catch(() => { .catch(() => {
this.setState({ this.setState({
component: this.props.error, component: () => this.props.error,
}); });
}); });
} }
......
...@@ -38,7 +38,7 @@ const authorize = (authority, error) => { ...@@ -38,7 +38,7 @@ const authorize = (authority, error) => {
throw new Error('authority is required'); throw new Error('authority is required');
} }
return function decideAuthority(targer) { return function decideAuthority(targer) {
return CheckPermissions( return () => CheckPermissions(
authority, authority,
targer, targer,
classError || Exception403 classError || Exception403
......
import React from 'react'; import React from 'react';
import { routerRedux, Switch } from 'dva/router'; import { routerRedux, Route, Switch } from 'dva/router';
import { LocaleProvider, Spin } from 'antd'; import { LocaleProvider, Spin } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN'; import zhCN from 'antd/lib/locale-provider/zh_CN';
import dynamic from 'dva/dynamic'; import dynamic from 'dva/dynamic';
...@@ -21,10 +21,9 @@ function RouterConfig({ history, app }) { ...@@ -21,10 +21,9 @@ function RouterConfig({ history, app }) {
<LocaleProvider locale={zhCN}> <LocaleProvider locale={zhCN}>
<ConnectedRouter history={history}> <ConnectedRouter history={history}>
<Switch> <Switch>
<AuthorizedRoute <Route
path="/user" path="/user"
render={props => <UserLayout {...props} />} component={UserLayout}
redirectPath="/"
/> />
<AuthorizedRoute <AuthorizedRoute
path="/" path="/"
......
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