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