From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 17 八月 2023 16:22:15 +0800 Subject: [PATCH] 2023-08-17 --- src/router/index.js | 82 +++++++++++++++++++++++++++++------------ 1 files changed, 58 insertions(+), 24 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index dc89810..b66adb6 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,37 +1,71 @@ import React, {Component} from 'react' import {HashRouter, Switch, Route, Redirect} from 'react-router-dom' import asyncComponent from '@/utils/asyncComponent' -const personal = asyncComponent(() => import('@/views/personal/personal')) +import asyncLoadComponent from '@/utils/asyncLoadComponent' + +const Login = asyncLoadComponent(() => import('@/views/login')) +const Main = asyncLoadComponent(() => import('@/views/main')) +const Sso = asyncLoadComponent(() => import('@/views/sso')) +const Pay = asyncLoadComponent(() => import('@/views/pay')) +const MainParams = asyncLoadComponent(() => import('@/views/mainparams')) +const Design = asyncLoadComponent(() => import('@/views/design')) +const NotFound = asyncComponent(() => import('@/views/404')) +const AppManage = asyncLoadComponent(() => import('@/views/appmanage')) +const AppCheck = asyncLoadComponent(() => import('@/views/appcheck')) +const PCDesign = asyncLoadComponent(() => import('@/views/pcdesign')) +const MobDesign = asyncLoadComponent(() => import('@/views/mobdesign')) +const ImDesign = asyncLoadComponent(() => import('@/views/imdesign')) +const MenuDesign = asyncLoadComponent(() => import('@/views/menudesign')) +const BaseDesign = asyncLoadComponent(() => import('@/views/basedesign')) +const TableDesign = asyncLoadComponent(() => import('@/views/tabledesign')) +const BillPrint = asyncLoadComponent(() => import('@/views/billprint')) +const PrintT = asyncLoadComponent(() => import('@/views/printTemplate')) +const Interface = asyncLoadComponent(() => import('@/views/interface')) +const RoleManage = asyncLoadComponent(() => import('@/views/rolemanage')) +const SystemFunc = asyncLoadComponent(() => import('@/views/systemfunc')) +const SystemProc = asyncLoadComponent(() => import('@/views/systemproc')) +const MkIframe = asyncLoadComponent(() => import('@/views/mkiframe')) + +const routers = [ + {path: '/login', name: 'login', component: Login}, + {path: '/main', name: 'main', component: Main}, + {path: '/pay/:param', name: 'pay', component: Pay}, + {path: '/print/:param', name: 'print', component: PrintT}, + {path: '/ssologin/:param', name: 'ssologin', component: Sso}, + {path: '/design', name: 'design', component: Design}, + {path: '/appmanage', name: 'appmanage', component: AppManage}, + {path: '/appcheck', name: 'appcheck', component: AppCheck}, + {path: '/pcdesign/:param', name: 'pcdesign', component: PCDesign}, + {path: '/mobdesign/:param', name: 'mobdesign', component: MobDesign}, + {path: '/imdesign/:param', name: 'imdesign', component: ImDesign}, + {path: '/menudesign/:param', name: 'menudesign', component: MenuDesign}, + {path: '/basedesign/:param', name: 'basedesign', component: BaseDesign}, + {path: '/tabledesign/:param', name: 'tabledesign', component: TableDesign}, + {path: '/billprint/:param', name: 'billprint', component: BillPrint}, + {path: '/docprint/:menuId', name: 'docprint', component: BillPrint}, + {path: '/docprint/:menuId/:id', name: 'docprint', component: BillPrint}, + {path: '/tab/:menuId', name: 'tab', component: MainParams}, + {path: '/role/:param', name: 'role', component: RoleManage}, + {path: '/hs', name: 'hs', component: SystemFunc}, + {path: '/proc', name: 'proc', component: SystemProc}, + {path: '/proc/:func', name: 'proc', component: SystemProc}, + {path: '/iframe/:menuId/:loginUid', name: 'iframe', component: MkIframe}, + {path: '/iframe/:menuId/:loginUid/:bid', name: 'iframe', component: MkIframe}, + {path: '/view/:menuId', name: 'iframe', component: MkIframe}, + {path: '/view/:menuId/:bid', name: 'iframe', component: MkIframe}, + {path: '/interface', name: 'interface', component: Interface} +] export default class RouteConfig extends Component { render () { return ( <HashRouter> <Switch> - <Route path="/main" exact component={personal}/> - <Route path="/main/:param" exact component={personal}/> - <Redirect exact from="/" to="main"/> - <Route component= {personal}/> + {routers.map((item, index) => <Route key={index} path={item.path} name={item.name} exact render={ props => <item.component {...props}/>}/>)} + <Redirect exact from="/" to="login"/> + <Route component= {NotFound}/> </Switch> </HashRouter> ) } -} - -// import React, { lazy } from 'react'; -// import { Route } from 'react-router-dom'; - -// const RouteLis = [ -// { -// component: lazy(() => import ('../views/home')), -// path: '/' -// } -// ]; - -// const RouterList = () => ( -// RouteLis.map((item, key) => { -// return <Route key={key} exact path={item.path} component={item.component}/>; -// }) -// ); - -// export default RouterList; \ No newline at end of file +} \ No newline at end of file -- Gitblit v1.8.0