From cafec890b8aaf9657ded377b70d6f90aac5117d8 Mon Sep 17 00:00:00 2001 From: jim Date: Tue, 30 Jan 2018 18:07:48 +0800 Subject: [PATCH] fix #843 Modify permissions component logic --- src/components/Authorized/CheckPermissions.js | 4 +--- src/components/Authorized/PromiseRender.js | 6 +++--- src/components/Authorized/Secured.js | 2 +- src/router.js | 7 +++---- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index 0a7dbaed..7a8239c2 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -38,9 +38,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { // Promise 处理 if (isPromise(authority)) { - return () => ( - - ); + return ; } // Function 处理 diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js index 78f762d9..06975f8a 100644 --- a/src/components/Authorized/PromiseRender.js +++ b/src/components/Authorized/PromiseRender.js @@ -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, }); }); } diff --git a/src/components/Authorized/Secured.js b/src/components/Authorized/Secured.js index 1dc6fb17..c6d7468c 100644 --- a/src/components/Authorized/Secured.js +++ b/src/components/Authorized/Secured.js @@ -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 diff --git a/src/router.js b/src/router.js index 54eefd17..23fdae17 100644 --- a/src/router.js +++ b/src/router.js @@ -1,5 +1,5 @@ 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 }) { - } - redirectPath="/" + component={UserLayout} />