| | |
| | | createRouter, createWebHistory, RouteRecordRaw, |
| | | } from 'vue-router' |
| | | import { cancelRequest } from '@/utils/axios' |
| | | import { userInfoStore } from '@/stores/userInfo' |
| | | |
| | | |
| | | import { Session } from '@/utils/storage' |
| | | |
| | | const routes: Array<RouteRecordRaw> = [ |
| | | { path: '/HomeLoading', name: 'HomeLoading', component: () => import('views/HomeLoading/index.vue'),meta:{title:'胜透服务'}}, |
| | | { path: '/login', name: 'login', component: () => import('views/login/index.vue'),meta:{title:'登录'}}, |
| | | { path: '/', name: 'Home', component: () => import('views/home/index.vue'),meta:{title:'首页'}}, |
| | | { path: '/my', name: 'myMine', component: () => import('views/myMine/index.vue'),meta:{title:'我的'}}, |
| | | { path: '/jifenShangCheng', name: 'jifenShangCheng', component: () => import('views/jifenShangCheng/index.vue'),meta:{title:'积分商城'}}, |
| | | { path: '/paiban', name: 'paiban', component: () => import('views/paiban/index.vue'),meta:{title:'透析排班'}}, |
| | | { path: '/report', name: 'report', component: () => import('views/report/index.vue'),meta:{title:'检查报告'}}, |
| | | { path: '/reportItem', name: 'reportItem', component: () => import('views/report/item/index.vue'),meta:{title:'报告查看'}}, |
| | | { path: '/prescriptionDrug', name: 'prescriptionDrug', component: () => import('views/prescriptionDrug/index.vue'),meta:{title:'透析医嘱'}}, |
| | | { path: '/record', name: 'record', component: () => import('views/record/index.vue'),meta:{title:'透析记录'}}, |
| | | { path: '/xuanjiao', name: 'xuanjiao', component: () => import('views/xuanjiao/index.vue'),meta:{title:'宣教'}}, |
| | | { path: '/test', name: 'Test', component: () => import('views/test.vue')} |
| | | ] |
| | | |
| | |
| | | routes, |
| | | }) |
| | | |
| | | router.beforeEach((to, from, next) => { |
| | | router.beforeEach(async(to, from, next) => { |
| | | const userInfo = userInfoStore() |
| | | // 取消所有强求 |
| | | cancelRequest() |
| | | console.log(to,'路由。。。') |
| | | // 添加title |
| | | if (to.meta.title){ |
| | | document.title = to.meta.title |
| | | } |
| | | next() |
| | | // 看看有没有toke |
| | | const token = Session.get('token') |
| | | console.log(!token) |
| | | if (to.path === '/login') { |
| | | next() |
| | | |
| | | } else { |
| | | if (!token){ |
| | | next('/login') |
| | | } else { |
| | | console.log('---') |
| | | if (to.path === '/'){ |
| | | await userInfo.setPatientApi() |
| | | |
| | | await userInfo.setPatientApi() |
| | | } |
| | | next() |
| | | } |
| | | } |
| | | }) |
| | | |
| | | export default router |