index.jsx 1005 Bytes
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
import Authorized from './Authorized';
import AuthorizedRoute from './AuthorizedRoute';
import Secured from './Secured';
import check from './CheckPermissions';
import renderAuthorize from './renderAuthorize';
import React from "react";
import {connect} from "dva";
import {querySysCode, queryCheckPath} from "../utils/queryConfig";
import { unwatchFile } from 'fs';

Authorized.Secured = Secured;
Authorized.AuthorizedRoute = AuthorizedRoute;
Authorized.check = check;
const RenderAuthorize = renderAuthorize(Authorized);
export default RenderAuthorize;


@connect(({global}) => {
  const myPath = global.myPath || [];
  return {myPath: myPath};
})
class AuthorizedWarp extends React.PureComponent {
  
  render() {
    const isCheckPath = queryCheckPath();
    if(!isCheckPath){
      return this.props.children
    }
    const {myPath, ...props} = this.props;
   
    const MYAuthorized = RenderAuthorize(myPath);
    return (
      <MYAuthorized {...props}/>
    );
  }
}

export {AuthorizedWarp}