index.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import pinia, { useAccountStore } from '@/stores';
  2. import { createRouter, createWebHistory } from 'vue-router';
  3. const router = createRouter({
  4. history: createWebHistory(import.meta.env.BASE_URL),
  5. routes: [
  6. { path: '/login', component: () => import('@/pages/login.vue') },
  7. {
  8. path: '/',
  9. component: () => import(`@/pages/index.vue`),
  10. children: [
  11. { path: 'patient/history', component: () => import(`@/pages/index/patient/history.vue`) },
  12. {
  13. path: 'patient/room', components: {
  14. default: () => import(`@/pages/index/patient/room@default.vue`),
  15. aside: () => import(`@/pages/index/patient/room@aside.vue`),
  16. },
  17. },
  18. {
  19. path: 'system', children: [
  20. { path: 'user', component: () => import(`@/pages/index/system/user.vue`) },
  21. { path: 'role', component: () => import(`@/pages/index/system/role.vue`) },
  22. { path: 'tag', component: () => import(`@/pages/index/system/tag.vue`) },
  23. ],
  24. },
  25. { path: '', redirect: '/patient/history' },
  26. {
  27. path: 'follow', children: [
  28. { path: 'plan', component: () => import(`@/pages/index/follow/plan.vue`) },
  29. { path: 'task', component: () => import(`@/pages/index/follow/task.vue`) },
  30. { path: 'assessment', component: () => import(`@/pages/index/follow/assessment.vue`) },
  31. ],
  32. },
  33. {
  34. path: 'tcmRecuperation', children: [
  35. { path: 'preserve', component: () => import(`@/pages/index/tcmRecuperation/preserve.vue`) },
  36. { path: 'system', component: () => import(`@/pages/index/tcmRecuperation/system.vue`) },
  37. { path: 'institution', component: () => import(`@/pages/index/tcmRecuperation/institution.vue`) },
  38. ],
  39. },
  40. ],
  41. beforeEnter(to, from, next) {
  42. if ( useAccountStore(pinia).token ) {
  43. next();
  44. } else {
  45. next({ path: '/login' });
  46. }
  47. },
  48. },
  49. ],
  50. });
  51. export default router;