派生自 wuyushui/SewerAndRainNetwork

wangqi
2021-03-12 523e053e73f7f9c4cfb5e69e9d07844a8ac4d99c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Vue from 'vue'
import Router from 'vue-router'
import { routes } from './routes'
import 'nprogress/nprogress.css'
const appConfig = require('@/app.config')
const { routeMode } = appConfig
 
Vue.use(Router)
const baseName = process.env.NODE_ENV === 'production' ? `/${appConfig.projectName}/` : '/'
const router = new Router({
  base: baseName,
  mode: routeMode || 'hash',
  routes: routes
})
router.beforeEach((to, from, next) => {
  Vue.prototype.$cancels.forEach((cancel) => {
    cancel()
  })
  Vue.prototype.$cancels = []
  // 不需要登录认证的路由
  if (Object.hasOwnProperty.call(to.meta, 'noLoginIdentify') && to.meta.noLoginIdentify) {
    next()
    return
  }
  next()
})
router.beforeResolve((to, from, next) => {
  next()
})
router.afterEach((to, from) => {
})
export default router