index.ts 2.1 KB
Newer Older
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
import Router from 'vue-router';
import { AuthGuard } from '../guard';
import RouterShell from '@/components/router-shell/router-shell';
import appRedirectView from '@/views/app-redirect-view/app-redirect-view';
import todoRedirect from '@/views/todo-redirect/todo-redirect';

const router = new Router({
  routes: [
    {
      path: '/',
      redirect: '/index',
    },
    {
      path: '/login',
      name: 'loginView',
      component: () => import('../views/login-view/login-view'),
    },
    {
      path: '/404',
      name: '404View',
      component: () => import('../views/404-view/404-view'),
    },
    {
      path: '/appredirectview',
      name: 'appRedirectView',
      beforeEnter: async (_to, _from, next) => {
        const authority = await AuthGuard();
        if (authority) {
          next();
        } else {
          next(false);
        }
      },
      component: appRedirectView,
    },
    {
      path: '/todoredirect',
      name: 'todoRedirect',
      beforeEnter: async (_to, _from, next) => {
        const authority = await AuthGuard();
        if (authority) {
          next();
        } else {
          next(false);
        }
      },
      component: todoRedirect,
    },
    {
      path: '/:view1([^=/]+)/:params1([^/]+=[^/]+)?',
      props: {
        level: 1,
      },
      beforeEnter: async (_to, _from, next) => {
        const authority = await AuthGuard();
        if (authority) {
          next();
        } else {
          next(false);
        }
      },
      component: RouterShell,
      children: [
        {
          path: '404',
          name: '404View',
          component: () => import('../views/404-view/404-view'),
        },
        {
          path: ':view2([^=/]+)/:params2([^/]+=[^/]+)?',
          props: {
            level: 2,
          },
          component: RouterShell,
          children: [
            {
              path: ':view3([^=/]+)/:params3([^/]+=[^/]+)?',
              props: {
                level: 3,
              },
              component: RouterShell,
            },
          ],
        },
      ],
    },
    {
      path: '*',
      redirect: '/404',
    },
  ],
});

export default router;