index.js 1.46 KB
Newer Older
dengxiaofeng's avatar
dengxiaofeng committed
1 2 3
import React from 'react';
import { Helmet } from 'react-helmet';
import { renderRoutes } from 'react-router-config';
张烨's avatar
张烨 committed
4
import { BrowserRouter as Router, Switch } from 'react-router-dom';
5
import { appConnector } from './store';
张烨's avatar
张烨 committed
6 7 8
import Authozed from '@/utils/authority';
import UserLogin from '@/pages/user/login';
import UserLayout from '@/layouts/UserLayout';
张烨's avatar
张烨 committed
9
import { AUTHORITY, BASENAME } from '@/utils/constants';
皮倩雯's avatar
皮倩雯 committed
10
import { Modal } from 'antd';
11
import { PictureWallProvider } from '@/components/Upload/context';
12
export default appConnector(function App(props) {
13
  const { routesConfig } = props;
皮倩雯's avatar
皮倩雯 committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27
  const getConfirmation = (msg, callBack) => {
    Modal.confirm({
      title: '确认',
      content: msg,
      okText: '确认',
      cancelText: '取消',
      onOk() {
        callBack(true);
      },
      onCancel() {
        callBack(false);
      },
    });
  };
dengxiaofeng's avatar
dengxiaofeng committed
28 29
  return (
    <>
30 31
      <Helmet titleTemplate="%s - 熊猫智慧水务运维平台" defaultTitle="熊猫智慧水务运维平台">
        <meta name="description" content="熊猫智慧水务运维平台" />
dengxiaofeng's avatar
dengxiaofeng committed
32
      </Helmet>
皮倩雯's avatar
皮倩雯 committed
33
      <Router basename={BASENAME} getUserConfirmation={getConfirmation}>
34 35 36 37 38 39 40 41
        <Authozed
          noMatch={
            <UserLayout>
              <UserLogin />
            </UserLayout>
          }
          authority={[AUTHORITY.LOGIN]}
        >
42
          <PictureWallProvider>{renderRoutes(routesConfig.routes)}</PictureWallProvider>
43 44
        </Authozed>
      </Router>
dengxiaofeng's avatar
dengxiaofeng committed
45 46
    </>
  );
47
});