mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 04:54:58 +08:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useLoginStore } from '@/stores/user-info-store'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{ path: '/:pathMatch(.*)*', name: 'not-found', redirect: '/home' },
|
|
{
|
|
path: '/login',
|
|
name: '登录',
|
|
component: () => import('@/views/login/login.vue'),
|
|
},
|
|
{
|
|
path: '/',
|
|
redirect: '/home',
|
|
children: [
|
|
{
|
|
path: '/home',
|
|
name: '首页',
|
|
component: () => import('@/views/home/home.vue'),
|
|
},
|
|
{
|
|
path: '/remote-manage',
|
|
name: '远程管理',
|
|
component: () => import('@/views/remote-manage/remote-manage.vue'),
|
|
}
|
|
]
|
|
}
|
|
]
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
const loginInfo = useLoginStore().getlogin()
|
|
const isLogin = loginInfo.isLogin
|
|
if (to.fullPath !=='/login' && !isLogin) {
|
|
next('/login') // 重定向登录页
|
|
} else {
|
|
// 如果用户有权限,正常进行导航
|
|
next()
|
|
}
|
|
});
|
|
|
|
export default router
|