12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 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')
- 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: '/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',
- name: 'evTwoLevelMenu',
- component: EvTwoLevelMenu
- }
- ]
- })
- router.beforeEach(async (to, from, next) => {
- const token = query().token || sessionStorage.getItem('token')
- 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 ssoServer = 'http://sso.sagacloud.cn'
- let redirectUrl = window.location.protocol + '//' + window.location.host + '/strategy'
- window.location.href = `${ssoServer}/login?redirectUrl=${redirectUrl}`
- }
- })
- export default router
|