github.com/covergates/covergates@v0.2.2-0.20201009050117-42ef8a19fb95/web/src/router/index.ts (about)

     1  import Vue from 'vue';
     2  import VueRouter, { RouteConfig } from 'vue-router';
     3  import {
     4    fetchReportSource,
     5    fetchCurrentRepository,
     6    fetchUserSCM,
     7    fetchNewRepository,
     8    fetchUserSettings
     9  } from './fetchers';
    10  import store from '@/store';
    11  
    12  Vue.use(VueRouter);
    13  
    14  const routes: Array<RouteConfig> = [
    15    {
    16      path: '/',
    17      name: 'Main',
    18      component: () => import('@/views/Main.vue'),
    19      children: [
    20        {
    21          path: '/',
    22          name: 'Home',
    23          component: () => import('@/views/Home.vue')
    24        },
    25        {
    26          path: '/user',
    27          name: 'User',
    28          meta: { requiresAuth: true },
    29          component: () => import('@/views/User.vue'),
    30          beforeEnter: fetchUserSCM(store)
    31        },
    32        {
    33          path: '/repo',
    34          name: 'Repo',
    35          meta: { requiresAuth: true },
    36          component: () => import('@/views/Repo.vue')
    37        },
    38        {
    39          path: '/report/:scm/:namespace/:name',
    40          name: 'Report',
    41          meta: { requiresAuth: true },
    42          component: () => import('@/views/Report.vue'),
    43          beforeEnter: fetchCurrentRepository(store),
    44          children: [
    45            {
    46              path: '/report/:scm/:namespace/:name',
    47              name: 'report-overview',
    48              meta: { checkRenew: true },
    49              component: () => import('@/components/ReportOverview.vue')
    50            },
    51            {
    52              path: 'history',
    53              name: 'report-history',
    54              meta: { checkRenew: true },
    55              component: () => import('@/components/ReportHistory.vue')
    56            },
    57            {
    58              path: 'code',
    59              name: 'report-code',
    60              meta: { requiresAuth: false, checkRenew: true },
    61              component: () => import('@/components/ReportFiles.vue')
    62            },
    63            {
    64              path: 'code/:path+',
    65              name: 'report-source',
    66              meta: { requiresAuth: true, checkRenew: true },
    67              component: () => import('@/components/ReportSource.vue'),
    68              beforeEnter: fetchReportSource(store)
    69            },
    70            {
    71              path: 'setting',
    72              name: 'report-setting',
    73              meta: { requiresAuth: true },
    74              component: () => import('@/components/ReportSetting.vue'),
    75              beforeEnter: fetchUserSettings(store)
    76            }
    77          ]
    78        }
    79      ]
    80    },
    81    {
    82      path: '/login',
    83      name: 'Login',
    84      component: () => import('@/views/Login.vue')
    85    },
    86    {
    87      path: '*',
    88      name: 'NoRoute',
    89      redirect: '/'
    90    }
    91  ];
    92  
    93  const router = new VueRouter({
    94    mode: 'history',
    95    base: process.env.NODE_ENV === 'production' ? VUE_BASE : process.env.BASE_URL,
    96    routes
    97  });
    98  router.beforeEach(fetchNewRepository(store));
    99  
   100  export default router;