diff --git a/package.json b/package.json index 7c8395da156446bea93bc4c243f7d17f4e46566e..ab41cfbda3072baf8a3e01099732a1c01457d209 100755 --- a/package.json +++ b/package.json @@ -23,9 +23,7 @@ "dependencies": { "@antv/data-set": "^0.8.0", "@babel/polyfill": "^7.0.0-beta.36", - "antd": "^3.4.3", - "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-runtime": "^6.9.2", + "antd": "3.6.4", "bizcharts": "^3.1.10", "bizcharts-plugin-slider": "^2.0.1", "classnames": "^2.2.5", @@ -53,11 +51,12 @@ "babel-eslint": "^8.1.2", "babel-plugin-dva-hmr": "^0.4.1", "babel-plugin-import": "^1.6.7", + "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-module-resolver": "^3.1.1", "cross-env": "^5.1.1", "cross-port-killer": "^1.0.1", "enzyme": "^3.1.0", - "eslint": "^4.14.0", + "eslint": "^5.0.0", "eslint-config-airbnb": "^17.0.0", "eslint-config-prettier": "^2.9.0", "eslint-plugin-babel": "^5.1.0", @@ -73,7 +72,7 @@ "prettier": "1.13.5", "pro-download": "^1.0.1", "redbox-react": "^1.5.0", - "regenerator-runtime": "^0.11.1", + "regenerator-runtime": "^0.12.0", "roadhog": "^2.4.2", "roadhog-api-doc": "^1.0.3", "stylelint": "^9.2.1", diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index 06dc0ab9dba7e7073391e24ba4fd281901dd3b1f..a79e28591eb7440c586d1c04ff83eb7b38702cba 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -1,6 +1,6 @@ import React from 'react'; import PromiseRender from './PromiseRender'; -import { CURRENT } from './index'; +import { CURRENT } from './renderAuthorize'; function isPromise(obj) { return ( diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js index b18bcbece1db86bf6bf1198dad5eb859f1b6408d..292d3b1ae826d13983988cd38d47cfb95a4ec060 100644 --- a/src/components/Authorized/PromiseRender.js +++ b/src/components/Authorized/PromiseRender.js @@ -44,7 +44,7 @@ export default class PromiseRender extends React.PureComponent { }; render() { - const Component = this.state.component; + const { component: Component } = this.state; return Component ? ( ) : ( diff --git a/src/components/Authorized/index.js b/src/components/Authorized/index.js index 48d1b2b843d31b503b5fa8da8616ff5cdfaa9040..91eabf87f8debff26808ad2bb07588356dea03a1 100644 --- a/src/components/Authorized/index.js +++ b/src/components/Authorized/index.js @@ -2,31 +2,10 @@ import Authorized from './Authorized'; import AuthorizedRoute from './AuthorizedRoute'; import Secured from './Secured'; import check from './CheckPermissions.js'; - -/* eslint-disable import/no-mutable-exports */ -let CURRENT = 'NULL'; +import renderAuthorize from './renderAuthorize'; Authorized.Secured = Secured; Authorized.AuthorizedRoute = AuthorizedRoute; Authorized.check = check; -/** - * use authority or getAuthority - * @param {string|()=>String} currentAuthority - */ -const renderAuthorize = currentAuthority => { - if (currentAuthority) { - if (currentAuthority.constructor.name === 'Function') { - CURRENT = currentAuthority(); - } - if (currentAuthority.constructor.name === 'String') { - CURRENT = currentAuthority; - } - } else { - CURRENT = 'NULL'; - } - return Authorized; -}; - -export { CURRENT }; -export default renderAuthorize; +export default renderAuthorize(Authorized); diff --git a/src/components/Authorized/renderAuthorize.js b/src/components/Authorized/renderAuthorize.js new file mode 100644 index 0000000000000000000000000000000000000000..8e34c6942a2977b9d0a183c9ba277e9cb1ca4ddc --- /dev/null +++ b/src/components/Authorized/renderAuthorize.js @@ -0,0 +1,24 @@ +/* eslint-disable import/no-mutable-exports */ +let CURRENT = 'NULL'; +/** + * use authority or getAuthority + * @param {string|()=>String} currentAuthority + */ +const renderAuthorize = Authorized => { + return currentAuthority => { + if (currentAuthority) { + if (currentAuthority.constructor.name === 'Function') { + CURRENT = currentAuthority(); + } + if (currentAuthority.constructor.name === 'String') { + CURRENT = currentAuthority; + } + } else { + CURRENT = 'NULL'; + } + return Authorized; + }; +}; + +export { CURRENT }; +export default Authorized => renderAuthorize(Authorized);