feat: scaffold mediai admin
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: () => import('@/views/LoginView.vue'),
|
||||
meta: { title: '登录' }
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: () => import('@/layouts/AdminLayout.vue'),
|
||||
redirect: '/dashboard',
|
||||
children: [
|
||||
{ path: 'dashboard', name: 'Dashboard', component: () => import('@/views/DashboardView.vue'), meta: { title: '数据驾驶舱' } },
|
||||
{ path: 'cases', name: 'Cases', component: () => import('@/views/CasesView.vue'), meta: { title: '病例中心' } },
|
||||
{ path: 'training', name: 'Training', component: () => import('@/views/TrainingView.vue'), meta: { title: '训练管理' } },
|
||||
{ path: 'institutions', name: 'Institutions', component: () => import('@/views/InstitutionsView.vue'), meta: { title: '机构管理' } },
|
||||
{ path: 'users', name: 'Users', component: () => import('@/views/UsersView.vue'), meta: { title: '用户权限' } },
|
||||
{ path: 'settings', name: 'Settings', component: () => import('@/views/SettingsView.vue'), meta: { title: '系统配置' } },
|
||||
{ path: 'module/:page', name: 'Module', component: () => import('@/views/ModuleView.vue'), meta: { title: '业务模块' } }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
scrollBehavior: () => ({ top: 0 })
|
||||
})
|
||||
|
||||
router.beforeEach(to => {
|
||||
document.title = `${to.meta.title ? `${String(to.meta.title)} - ` : ''}MediAI`
|
||||
const appStore = useAppStore()
|
||||
|
||||
if (to.path !== '/login' && !appStore.isLoggedIn) {
|
||||
return { path: '/login', query: { redirect: to.fullPath } }
|
||||
}
|
||||
|
||||
if (to.path === '/login' && appStore.isLoggedIn) {
|
||||
return '/'
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user