index.js 2.14 KB
import Vue from 'vue'
import VueRouter from 'vue-router'

// 解决 vue-router 重复路由访问报错
const originPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originPush.call(this, location).catch(err => err)
}

// layout
import { PageLayout, BasicLayout } from '../layouts'

Vue.use(VueRouter)

/**
 * 基础路由
 */
export const constantRoutes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index')
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404')
  },
  {
    path: '/',
    component: BasicLayout,
    redirect: '/account',
    children: [
      {
        path: 'account',
        name: 'Account',
        component: () => import('@/views/report/account/index'),
        meta: {}
      }
    ]
  },
  {
    path: '/analysis',
    component: PageLayout,
    redirect: '/analysis/seqasis',
    children: [
      {
        path: 'seqasis',
        name: 'Seqasis',
        component: () => import('@/views/analysis/seqasis/index'),
        meta: {}
      }
    ]
  },
  {
    path: '/behavior',
    component: PageLayout,
    redirect: '/behavior/mallgroup',
    children: [
      {
        path: 'mallgroup',
        name: 'mallgroup',
        component: () => import('@/views/behavior/mallgroup/index'),
        meta: {}
      }
    ]
  },
  {
    path: '/dataasis',
    component: BasicLayout,
    redirect: '/dataasis/trafficasis',
    children: [
      {
        path: 'trafficasis',
        name: 'trafficasis',
        component: () => import('@/views/dataasis/analysis-report/index'),
        meta: {}
      }
    ]
  },
  {
    path: '/manage',
    component: PageLayout,
    redirect: '/manage/blocmanage',
    children: [
      {
        path: 'blocmanage',
        name: 'blocmanage',
        component: () => import('@/views/manage/bloc-manage/index'),
        meta: {}
      }
    ]
  }
]

export const asyncRoutes = [
  {
    //
  },
  { path: '*', redirect: '/404' }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

export default router