26-7-31-1

This commit is contained in:
shuai
2026-07-31 12:27:41 +08:00
commit 9b8b8b57b3
142 changed files with 22408 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
import { createRouter, createWebHistory } from 'vue-router'
import { useUserStore } from '@/stores/user'
const routes = [
{
path: '/login',
name: 'Login',
component: () => import('@/views/Login.vue'),
meta: { public: true }
},
{
path: '/',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/dashboard',
children: [
{
path: 'dashboard',
name: 'Dashboard',
component: () => import('@/views/Dashboard.vue'),
meta: { title: '仪表盘' }
},
{
path: 'patients',
name: 'Patients',
component: () => import('@/views/Patients.vue'),
meta: { title: '患者管理' }
},
{
path: 'imaging',
name: 'Imaging',
component: () => import('@/views/Imaging.vue'),
meta: { title: '影像诊断' }
},
{
path: 'emrs',
name: 'Emrs',
component: () => import('@/views/Emrs.vue'),
meta: { title: '电子病历' }
},
{
path: 'appointments',
name: 'Appointments',
component: () => import('@/views/Appointments.vue'),
meta: { title: '预约挂号' }
},
{
path: 'ai-assistant',
name: 'AiAssistant',
component: () => import('@/views/AiAssistant.vue'),
meta: { title: 'AI 助手' }
},
{
path: 'ai-settings',
name: 'AiSettings',
component: () => import('@/views/AiSettings.vue'),
meta: { title: 'AI 配置', roles: ['ADMIN'] }
},
{
path: 'ai-yolo',
name: 'AiYolo',
component: () => import('@/views/AiYolo.vue'),
meta: { title: 'YOLO 权重', roles: ['ADMIN'] }
},
{
path: 'ai-knowledge',
name: 'AiKnowledge',
component: () => import('@/views/AiKnowledge.vue'),
meta: { title: '知识库' }
},
{
path: 'users',
name: 'Users',
component: () => import('@/views/Users.vue'),
meta: { title: '用户管理', roles: ['ADMIN'] }
},
{
path: '403',
name: 'Forbidden',
component: () => import('@/views/Forbidden.vue'),
meta: { title: '无权访问' }
}
]
},
{ path: '/:pathMatch(.*)*', redirect: '/dashboard' }
]
const router = createRouter({
history: createWebHistory(),
routes
})
router.beforeEach((to) => {
const store = useUserStore()
// 已登录访问登录页,直接进首页
if (to.path === '/login' && store.token) {
return { path: '/dashboard' }
}
if (to.meta.public) return true
if (!store.token) {
return { path: '/login', query: { redirect: to.fullPath } }
}
if (to.meta.roles && !to.meta.roles.includes(store.role)) {
return { path: '/403' }
}
return true
})
export default router