|
|
@@ -23,37 +23,38 @@ if (!window.localStorage.getItem("isAuthenticated")) {
|
|
|
}
|
|
|
|
|
|
function RouterConfig({ history }) {
|
|
|
- return (
|
|
|
- <LocaleProvider locale={zhCN}>
|
|
|
- <Router history={history}>
|
|
|
- <Switch>
|
|
|
- <Route sensitive path='/login' component={Login}/>
|
|
|
- <Route sensitive path='/register' component={Register}/>
|
|
|
- <PrivateRoute sensitive path='/chart/:code' component={ChartDesigner}/>
|
|
|
- <PrivateRoute sensitive path='/dashboard/:id/' component={DashboardDesigner}/>
|
|
|
- <PrivateRoute path='/' component={MainLayout}/>
|
|
|
- </Switch>
|
|
|
- </Router>
|
|
|
- </LocaleProvider>
|
|
|
- );
|
|
|
+ return (
|
|
|
+ <LocaleProvider locale={zhCN}>
|
|
|
+ <Router history={history}>
|
|
|
+ <Switch>
|
|
|
+ <Route sensitive path='/login' component={Login} />
|
|
|
+ <Route sensitive path='/register' component={Register} />
|
|
|
+ <Route sensitive path='/demo' component={Demo} />
|
|
|
+ <PrivateRoute sensitive path='/chart/:code' component={ChartDesigner} />
|
|
|
+ <PrivateRoute sensitive path='/dashboard/:id/' component={DashboardDesigner} />
|
|
|
+ <PrivateRoute path='/' component={MainLayout} />
|
|
|
+ </Switch>
|
|
|
+ </Router>
|
|
|
+ </LocaleProvider>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
export default RouterConfig;
|
|
|
|
|
|
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 }
|
|
|
- }}
|
|
|
- />
|
|
|
- )
|
|
|
- }
|
|
|
- />
|
|
|
+ <Route
|
|
|
+ {...rest}
|
|
|
+ render={props =>
|
|
|
+ (window.localStorage.getItem("isAuthenticated") === "true" ? true : false) ? (
|
|
|
+ <Component {...props} />
|
|
|
+ ) : (
|
|
|
+ <Redirect
|
|
|
+ to={{
|
|
|
+ pathname: "/login",
|
|
|
+ state: { from: props.location }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ />
|
|
|
);
|