6c6f690788
- 移除冗余依赖包 - 新增账号禁用校验与用户管理能力 - 新增文档下载与管理页面文件展示 - 新增API文档页面与用户管理前端页面 - 重构时区处理与docker-compose部署配置 - 完善测试用例与项目文档
108 lines
2.8 KiB
JavaScript
108 lines
2.8 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useAuthStore } from '@/stores/useAuthStore'
|
|
|
|
const routes = [
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
component: () => import('@/views/Login.vue'),
|
|
meta: { title: '登录', requiresAuth: false }
|
|
},
|
|
{
|
|
path: '/',
|
|
component: () => import('@/layouts/MainLayout.vue'),
|
|
redirect: '/overview',
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{
|
|
path: 'overview',
|
|
name: 'overview',
|
|
component: () => import('@/views/Overview.vue'),
|
|
meta: { title: '概览', requiresAuth: true }
|
|
},
|
|
{
|
|
path: 'documents',
|
|
name: 'documents',
|
|
component: () => import('@/views/Documents.vue'),
|
|
meta: { title: '文档管理', requiresAuth: true }
|
|
},
|
|
{
|
|
path: 'ingest',
|
|
name: 'ingest',
|
|
component: () => import('@/views/Ingest.vue'),
|
|
meta: { title: '文档入库', requiresAuth: true }
|
|
},
|
|
{
|
|
path: 'search',
|
|
name: 'search',
|
|
component: () => import('@/views/Search.vue'),
|
|
meta: { title: '检索测试台', requiresAuth: true }
|
|
},
|
|
{
|
|
path: 'categories',
|
|
name: 'categories',
|
|
component: () => import('@/views/Categories.vue'),
|
|
meta: { title: '类目列表', requiresAuth: true }
|
|
},
|
|
{
|
|
path: 'settings',
|
|
name: 'settings',
|
|
component: () => import('@/views/Settings.vue'),
|
|
meta: { title: '设置', requiresAuth: true }
|
|
},
|
|
{
|
|
path: 'api-docs',
|
|
name: 'api-docs',
|
|
component: () => import('@/views/ApiDocs.vue'),
|
|
meta: { title: 'API 说明', requiresAuth: true }
|
|
},
|
|
{
|
|
path: 'users',
|
|
name: 'users',
|
|
component: () => import('@/views/Users.vue'),
|
|
meta: { title: '用户管理', requiresAuth: true, requiresAdmin: true }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/:pathMatch(.*)*',
|
|
name: 'not-found',
|
|
redirect: '/overview'
|
|
}
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory('/admin/'),
|
|
routes,
|
|
scrollBehavior() {
|
|
return { top: 0 }
|
|
}
|
|
})
|
|
|
|
// 全局前置守卫:未登录跳 /login;已登录访问 /login 跳 /overview
|
|
router.beforeEach((to) => {
|
|
const authStore = useAuthStore()
|
|
const title = to.meta?.title
|
|
if (title) {
|
|
document.title = `${title} - QMDSearch 知识库后台`
|
|
} else {
|
|
document.title = 'QMDSearch 知识库后台'
|
|
}
|
|
|
|
if (to.meta?.requiresAuth && !authStore.isAuthenticated) {
|
|
return { name: 'login', query: { redirect: to.fullPath } }
|
|
}
|
|
|
|
if (to.meta?.requiresAdmin && !authStore.isAdmin) {
|
|
return { name: 'overview' }
|
|
}
|
|
|
|
if (to.name === 'login' && authStore.isAuthenticated) {
|
|
return { name: 'overview' }
|
|
}
|
|
|
|
return true
|
|
})
|
|
|
|
export default router
|