This commit is contained in:
2026-08-05 10:28:44 +08:00
commit 0bacf2e0a4
103 changed files with 9415 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import { useAuthStore } from '../stores/auth.js'
const routes = [
{
path: '/login',
name: 'Login',
component: () => import('../views/Login.vue')
},
{
path: '/',
component: () => import('../views/Layout.vue'),
redirect: '/datasets',
children: [
{
path: 'datasets',
name: 'DatasetList',
meta: { title: '数据集' },
component: () => import('../views/DatasetList.vue')
},
{
path: 'datasets/:id',
name: 'DatasetDetail',
meta: { title: '数据集详情' },
component: () => import('../views/DatasetDetail.vue')
},
{
path: 'chat',
name: 'Chat',
meta: { title: '问答' },
component: () => import('../views/Chat.vue')
},
{
path: 'kg',
name: 'KgGraph',
meta: { title: '知识图谱' },
component: () => import('../views/KgGraph.vue')
},
{
path: 'settings',
name: 'Settings',
meta: { title: '设置' },
component: () => import('../views/Settings.vue')
}
]
}
]
const router = createRouter({
// hash 路由:前后端合并部署后 SPA 路由与后端 API 前缀重叠,
// history 模式刷新会命中 API 路由;hash 模式页面始终请求 /,由后端静态服务返回 index.html
history: createWebHashHistory(),
routes
})
router.beforeEach((to, from, next) => {
const auth = useAuthStore()
if (to.path !== '/login' && !auth.isLoggedIn) {
next('/login')
return
}
if (to.path === '/login' && auth.isLoggedIn) {
next('/')
return
}
next()
})
export default router