export default function App() { return ( <Router> <div className="layout-wrapper"> <Switch> <Route path="/register" exact component={loadable(() => import('../containers/RegisterPage'))} /> <Route path="/login" exact component={loadable(() => import('../containers/LogInPage'))} /> <Route exact path={FUNCTION_ROUTERS}> <Route path={FUNCTION_ROUTERS} exact component={MainView} /> <Route path={FUNCTION_ROUTERS} exact component={RightView} /> </Route> <Route component={loadable(() => import('../components/NotFound'))} /> </Switch> </div> </Router> ); }
function MainView(props) { const { pathname } = props.location; if (AUTH_ROUTERS.indexOf(pathname) < 0 && !localStorage.getItem('userInfo')) { sessionStorage.setItem('originalLink', window.location.href); props.history.push('/login'); } let MainViewClassName; if (pathname === '/' || pathname === '/setting') { MainViewClassName = 'layout-left'; } else { MainViewClassName = 'layout-left-mobile'; } return ( <div className={MainViewClassName}> <Route component={loadable(() => import('../containers/Tabs'))} /> <Route path={['/', '/robot_chat', '/group_chat/:to_group_id', '/private_chat/:user_id']} exact component={loadable(() => import('../containers/HomePageList'))} /> <Route path="/setting" exact component={loadable(() => import('../containers/SettingPage'))} /> </div> ); }
<Route path="/robot_chat" component={loadable(() => import('../containers/RobotPage'))} /> <Route path="/group_chat/:to_group_id" component={loadable(() => import('../containers/GroupChatPage'))} /> <Route path="/private_chat/:user_id" component={loadable(() => import('../containers/PrivateChatPage'))} /> {['/', '/setting'].map((path, index) => ( path={path} exact component={loadable(() => import('../containers/WelcomePage'))} key={index} />
loadable(() => import('../containers/auth/LoginContainer'))
loadable(() => import('../containers/dashboard/DashboardContainer'))
loadable(() => import('../containers/auth/SignUpContainer'))
loadable(() => import('@/scenes/Private'), LoadableComp)
loadable(() => import('@/scenes/Home'), LoadableComp)
loadable(() => import('@/scenes/Login'), LoadableComp)
loadable(() => import("./views/Home"))
loadable(() => import(/* webpackChunkName: "Continent" */ './pages/Continent'))
loadable(() => import('./pdf/PdfContainer'))
loadable(() => import("./Dashboard/Dashboard"))
loadable(() => import(/* webpackChunkName: "Home" */ './pages/Home'))
loadable(() => import("./views/NotFound"))