| | |
| | | import React, {Component} from 'react' |
| | | import {HashRouter, Switch, Route, Redirect} from 'react-router-dom' |
| | | import md5 from 'md5' |
| | | import moment from 'moment' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncLoadComponent from '@/utils/asyncLoadComponent' |
| | | |
| | |
| | | const SystemProc = asyncLoadComponent(() => import('@/views/systemproc')) |
| | | |
| | | const routers = [ |
| | | {path: '/login', name: 'login', component: Login, auth: false}, |
| | | {path: '/main', name: 'main', component: Main, auth: true}, |
| | | {path: '/pay/:param', name: 'pay', component: Pay, auth: false}, |
| | | {path: '/print/:param', name: 'print', component: PrintT, auth: false}, |
| | | {path: '/ssologin/:param', name: 'ssologin', component: Sso, auth: false}, |
| | | {path: '/design', name: 'design', component: Design, auth: true}, |
| | | {path: '/appmanage', name: 'appmanage', component: AppManage, auth: true}, |
| | | {path: '/appcheck', name: 'appcheck', component: AppCheck, auth: true}, |
| | | {path: '/pcdesign/:param', name: 'pcdesign', component: PCDesign, auth: true}, |
| | | {path: '/mobdesign/:param', name: 'mobdesign', component: MobDesign, auth: true}, |
| | | {path: '/imdesign/:param', name: 'imdesign', component: ImDesign, auth: true}, |
| | | {path: '/menudesign/:param', name: 'menudesign', component: MenuDesign, auth: true}, |
| | | {path: '/basedesign/:param', name: 'basedesign', component: BaseDesign, auth: true}, |
| | | {path: '/tabledesign/:param', name: 'tabledesign', component: TableDesign, auth: true}, |
| | | {path: '/billprint/:param', name: 'billprint', component: BillPrint, auth: true}, |
| | | {path: '/docprint/:menuId', name: 'docprint', component: BillPrint, auth: false}, |
| | | {path: '/docprint/:menuId/:id', name: 'docprint', component: BillPrint, auth: false}, |
| | | {path: '/tab/:menuId', name: 'tab', component: MainParams, auth: false}, |
| | | {path: '/role/:param', name: 'role', component: RoleManage, auth: true}, |
| | | {path: '/hs', name: 'hs', component: SystemFunc, auth: true}, |
| | | {path: '/proc', name: 'proc', component: SystemProc, auth: true}, |
| | | {path: '/interface', name: 'interface', component: Interface, 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: '/interface', name: 'interface', component: Interface} |
| | | ] |
| | | |
| | | export default class RouteConfig extends Component { |
| | | controlRoute (item, props) { |
| | | if (!item.auth) { // 不需要授权,直接跳转 |
| | | return (<item.component {...props}/>) |
| | | } |
| | | |
| | | let userId = sessionStorage.getItem('UserID') // 判断登录信息是否存在,注用户可能保存主页链接 |
| | | let authCode = localStorage.getItem(window.location.href.split('#')[0] + 'AuthCode') // 判断系统是否在授权期限内 |
| | | let _s = md5('mksoft' + moment().format('YYYYMMDD')) |
| | | let isauth = authCode && authCode.includes(_s) |
| | | let key = md5(window.GLOB.appId + 'minke_software' + window.GLOB.appkey).toUpperCase().substr(-6) |
| | | let key1 = window.GLOB.licenseKey ? window.GLOB.licenseKey.substring(0, 6) : '' |
| | | |
| | | if (key1 === key) { |
| | | isauth = true |
| | | } |
| | | |
| | | if (userId && isauth) { |
| | | return (<item.component {...props}/>) |
| | | } else { |
| | | return (<Redirect to={{ pathname: '/login'}}/>) |
| | | } |
| | | } |
| | | |
| | | render () { |
| | | return ( |
| | | <HashRouter> |
| | | <Switch> |
| | | {routers.map((item, index) => <Route key={index} path={item.path} name={item.name} exact render={ props => 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> |