From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/router/index.js | 102 +++++++++++++++++++++++++++----------------------- 1 files changed, 55 insertions(+), 47 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index a28c284..a1bc174 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,63 +1,71 @@ import React, {Component} from 'react' import {HashRouter, Switch, Route, Redirect} from 'react-router-dom' -import moment from 'moment' -import md5 from 'md5' import asyncComponent from '@/utils/asyncComponent' -const main = asyncComponent(() => import('@/views/main')) -const login = asyncComponent(() => import('@/views/login')) +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 SystemCheck = asyncLoadComponent(() => import('@/views/syscheck')) +const MkIframe = asyncLoadComponent(() => import('@/views/mkiframe')) +// const MkAi = asyncLoadComponent(() => import('@/views/mkai')) const routers = [ - {path: '/login', name: 'login', component: login, auth: false}, - {path: '/main', name: 'main', component: main, auth: true}, - {path: '/main/:param', name: 'pmain', component: main, auth: true} + {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}, + // {path: '/ai', name: 'ai', component: MkAi}, + // {path: '/syscheck', name: 'syscheck', component: SystemCheck} ] export default class RouteConfig extends Component { - controlRoute (item, props) { - if (!item.auth) { // 涓嶉渶瑕佹巿鏉冿紝鐩存帴璺宠浆锛堢櫥褰曢〉锛� - return (<item.component {...props}/>) - } - - if (item.name === 'pmain') { // 鏂扮獥鍙f墦寮�锛屽彇url鍙傛暟鏀惧叆sessionStorage - let _param = window.atob(props.match.params.param) - sessionStorage.setItem('view_param', _param) - return (<Redirect to={{ pathname: '/main'}}/>) - } - - let userId = sessionStorage.getItem('UserID') // 鍒ゆ柇鏄惁瀛樺湪userid - - let authCode = localStorage.getItem('AuthCode') // 鍒ゆ柇绯荤粺鏄惁鍦ㄦ巿鏉冩湡闄愬唴 - let _s = md5('mksoft' + moment().format('YYYYMMDD')) - let isauth = authCode && authCode.includes(_s) - - if (userId && isauth) { - return (<item.component {...props}/>) - } else { - let param = sessionStorage.getItem('view_param') - if (param) { - param = param.split('&') - sessionStorage.setItem('UserID', param[3]) - return (<item.component {...props}/>) - } else { - return (<Redirect to={{ pathname: '/login', state: {from: props.location}}}/>) - } - } - } - render () { return ( <HashRouter> <Switch> - { - routers.map((item, index) => { - return ( - <Route key={index} path={item.path} name={item.name} exact render={ props => { - return this.controlRoute(item, props) - }}/> - ) - }) - } + {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> -- Gitblit v1.8.0