| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import pinia, { useAccountStore } from '@/stores';
- import { createRouter, createWebHistory } from 'vue-router';
- const router = createRouter({
- history: createWebHistory(import.meta.env.BASE_URL),
- routes: [
- { path: '/login', component: () => import('@/pages/login.vue') },
- {
- path: '/',
- component: () => import(`@/pages/index.vue`),
- children: [
- { path: 'patient/history', component: () => import(`@/pages/index/patient/history.vue`) },
- {
- path: 'patient/room', components: {
- default: () => import(`@/pages/index/patient/room@default.vue`),
- aside: () => import(`@/pages/index/patient/room@aside.vue`),
- },
- },
- {
- path: 'system', children: [
- { path: 'user', component: () => import(`@/pages/index/system/user.vue`) },
- { path: 'role', component: () => import(`@/pages/index/system/role.vue`) },
- { path: 'tag', component: () => import(`@/pages/index/system/tag.vue`) },
- ],
- },
- { path: '', redirect: '/patient/history' },
- {
- path: 'follow', children: [
- { path: 'plan', component: () => import(`@/pages/index/follow/plan.vue`) },
- { path: 'task', component: () => import(`@/pages/index/follow/task.vue`) },
- { path: 'assessment', component: () => import(`@/pages/index/follow/assessment.vue`) },
- ],
- },
- {
- path: 'tcmRecuperation', children: [
- { path: 'preserve', component: () => import(`@/pages/index/tcmRecuperation/preserve.vue`) },
- { path: 'system', component: () => import(`@/pages/index/tcmRecuperation/system.vue`) },
- { path: 'institution', component: () => import(`@/pages/index/tcmRecuperation/institution.vue`) },
- ],
- },
- ],
- beforeEnter(to, from, next) {
- if ( useAccountStore(pinia).token ) {
- next();
- } else {
- next({ path: '/login' });
- }
- },
- },
- ],
- });
- export default router;
|