123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- import Vue from 'vue'
- import Router from 'vue-router'
- const Main = () => import('@/views/main/index')
- const Strategy = () => import('@/views/strategy/index')
- const Appeal = () => import('@/views/appeal/index')
- const AppealDetail = () => import('@/views/appeal/appealDetail')
- const AppealDetails = () => import('@/views/appeal/appealDetails')
- const Audit = () => import('@/views/audit/index')
- const DoBusiness = () => import('@/views/doBusiness/index')
- const Evaluate = () => import('@/views/evaluate/index')
- const EvTwoLevelMenu = () => import('@/views/evaluate/evTwoLevelMenu')
- const Auth = () => import('@/views/auth/index')
- import store from '../store'
- import {
- query
- } from '../utils/query'
- Vue.use(Router)
- const router = new Router({
- mode: 'history',
- routes: [{
- path: '/',
- name: 'main',
- component: Main
- },
- {
- path: '/auth',
- name: 'auth',
- component: Auth
- },
- {
- path: '/strategy',
- name: 'strategy',
- component: Strategy
- },
- {
- path: '/appeal',
- name: 'appeal',
- component: Appeal
- },
- {
- path: '/appeal/appealDetail',
- name: 'appealDetail',
- component: AppealDetail
- },
- {
- path: '/appeal/appealDetails',
- name: 'appealDetails',
- component: AppealDetails
- },
- {
- path: '/audit',
- name: 'audit',
- component: Audit
- },
- {
- path: '/doBusiness',
- name: 'doBusiness',
- component: DoBusiness
- },
- {
- path: '/evaluate',
- name: 'evaluate',
- component: Evaluate
- },
- {
- path: '/evaluate/evTwoLevelMenu/:date/:name',
- name: 'evTwoLevelMenu',
- component: EvTwoLevelMenu
- }
- ]
- })
- router.beforeEach(async (to, from, next) => {
- const token = query().token || sessionStorage.getItem('token')
- if(query().loginFromlz||store.state.formLz){
- store.commit('setFromLz',true);
- next()
- }else{
- if (store.state.token && Object.keys(store.state.userInfo).length > 0) {
- next()
- } else if (token) {
- store.commit('setSsoToken', token)
- await store.dispatch('loadUserInfo', {
- token
- })
- // 去除浏览器地址栏token
- if (query().token) {
- router.replace(location.pathname + location.search.replace(/(&?token=\w+&?)/, ''))
- }
- next()
- } else {
- let lastRoute = {
- path: to.path,
- params: to.params,
- query: to.query
- }
- store.commit('setLastRoute', lastRoute)
- let ssoServer = 'http://10.199.143.85:7003'
- let redirectUrl = window.location.protocol + '//' + window.location.host + '/auth'
- window.location.href = `${ssoServer}/login?redirectUrl=${redirectUrl}`
- }
- }
- })
- export default router
|