|
@@ -1,24 +1,50 @@
|
|
|
import React from 'react'
|
|
import React from 'react'
|
|
|
import { LocaleProvider } from 'antd'
|
|
import { LocaleProvider } from 'antd'
|
|
|
-import { Router, Route, Switch } from 'dva/router'
|
|
|
|
|
|
|
+import { Router, Route, Switch, Redirect } from 'dva/router'
|
|
|
import MainLayout from './mainLayout'
|
|
import MainLayout from './mainLayout'
|
|
|
import ChartDesigner from '../components/chartDesigner/layout'
|
|
import ChartDesigner from '../components/chartDesigner/layout'
|
|
|
import DashboardDesigner from '../components/dashboardDesigner/layout'
|
|
import DashboardDesigner from '../components/dashboardDesigner/layout'
|
|
|
// 由于 antd 组件的默认文案是英文,所以需要修改为中文
|
|
// 由于 antd 组件的默认文案是英文,所以需要修改为中文
|
|
|
import zhCN from 'antd/lib/locale-provider/zh_CN'
|
|
import zhCN from 'antd/lib/locale-provider/zh_CN'
|
|
|
|
|
+import Demo from '../demo';
|
|
|
|
|
+import Login from '../components/common/login';
|
|
|
|
|
+
|
|
|
|
|
+window.localStorage.setItem("isAuthenticated", "false");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+const PrivateRoute = ({ component: Component, ...rest }) => (
|
|
|
|
|
+ <Route
|
|
|
|
|
+ {...rest}
|
|
|
|
|
+ render={props =>
|
|
|
|
|
+ (window.localStorage.getItem("isAuthenticated") === "true"? true: false) ? (
|
|
|
|
|
+ <Component {...props} />
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <Redirect
|
|
|
|
|
+ to={{
|
|
|
|
|
+ pathname: "/login",
|
|
|
|
|
+ state: { from: props.location }
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ />
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
function RouterConfig({ history }) {
|
|
function RouterConfig({ history }) {
|
|
|
- return (
|
|
|
|
|
- <LocaleProvider locale={zhCN}>
|
|
|
|
|
- <Router history={history}>
|
|
|
|
|
- <Switch>
|
|
|
|
|
- <Route sensitive path='/chart/:code' component={ChartDesigner}/>
|
|
|
|
|
- <Route sensitive path='/dashboard/:id/' component={DashboardDesigner}/>
|
|
|
|
|
- <Route path='/' component={MainLayout}/>
|
|
|
|
|
- </Switch>
|
|
|
|
|
- </Router>
|
|
|
|
|
- </LocaleProvider>
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ <LocaleProvider locale={zhCN}>
|
|
|
|
|
+ <Router history={history}>
|
|
|
|
|
+ <Switch>
|
|
|
|
|
+ <PrivateRoute sensitive path='/chart/:code' component={ChartDesigner} />
|
|
|
|
|
+ <PrivateRoute sensitive path='/dashboard/:id/' component={DashboardDesigner} />
|
|
|
|
|
+ <Route sensitive path='/login/' component={Login} />
|
|
|
|
|
+ <PrivateRoute path='/' component={MainLayout} />
|
|
|
|
|
+ </Switch>
|
|
|
|
|
+ </Router>
|
|
|
|
|
+ </LocaleProvider>
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export default RouterConfig;
|
|
export default RouterConfig;
|