Files
xiaozhi-esp32-server/main/manager-web/src/router/index.js
T

262 lines
5.8 KiB
JavaScript
Raw Normal View History

2025-03-05 23:13:24 +08:00
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'welcome',
2025-03-14 23:48:59 +08:00
component: function () {
return import('../views/login.vue')
}
},
{
path: '/role-config',
name: 'RoleConfig',
component: function () {
return import('../views/roleConfig.vue')
}
2025-07-08 16:15:52 +08:00
},
2025-10-07 23:54:42 +08:00
{
2025-07-08 16:15:52 +08:00
path: '/voice-print',
name: 'VoicePrint',
component: function () {
return import('../views/VoicePrint.vue')
}
2025-03-05 23:13:24 +08:00
},
{
path: '/login',
name: 'login',
component: function () {
2025-03-14 23:48:59 +08:00
return import('../views/login.vue')
2025-03-05 23:13:24 +08:00
}
},
{
path: '/home',
name: 'home',
component: function () {
2025-03-14 23:48:59 +08:00
return import('../views/home.vue')
2025-03-05 23:13:24 +08:00
}
2025-03-12 13:38:44 +08:00
},
{
path: '/register',
name: 'Register',
component: function () {
2025-03-14 23:48:59 +08:00
return import('../views/register.vue')
2025-03-12 13:38:44 +08:00
}
},
2025-05-19 14:15:28 +08:00
{
path: '/retrieve-password',
name: 'RetrievePassword',
component: function () {
return import('../views/retrievePassword.vue')
}
},
2025-03-20 14:08:38 +08:00
// 设备管理页面路由
2025-03-18 21:49:57 +08:00
{
path: '/device-management',
name: 'DeviceManagement',
component: function () {
return import('../views/DeviceManagement.vue')
}
2025-03-20 14:08:38 +08:00
},
// 添加用户管理路由
{
path: '/user-management',
name: 'UserManagement',
component: function () {
return import('../views/UserManagement.vue')
}
2025-03-20 18:11:37 +08:00
},
{
2025-04-05 20:19:28 +08:00
path: '/model-config',
name: 'ModelConfig',
component: function () {
return import('../views/ModelConfig.vue')
}
2025-03-20 18:11:37 +08:00
},
2025-12-05 14:35:53 +08:00
{
path: '/params-management',
2025-04-09 13:36:59 +08:00
name: 'ParamsManagement',
component: function () {
return import('../views/ParamsManagement.vue')
},
meta: {
requiresAuth: true,
title: '参数管理'
}
},
2025-12-05 14:35:53 +08:00
{
path: '/knowledge-base-management',
2025-11-04 16:21:01 +08:00
name: 'KnowledgeBaseManagement',
component: function () {
return import('../views/KnowledgeBaseManagement.vue')
},
meta: {
requiresAuth: true,
title: '知识库管理'
}
},
2025-12-05 14:35:53 +08:00
{
path: '/knowledge-file-upload',
2025-11-04 16:21:01 +08:00
name: 'KnowledgeFileUpload',
component: function () {
return import('../views/KnowledgeFileUpload.vue')
},
meta: {
requiresAuth: true,
title: '文档上传管理'
}
},
{
path: '/server-side-management',
name: 'ServerSideManager',
component: function () {
return import('../views/ServerSideManager.vue')
},
meta: {
requiresAuth: true,
title: '服务端管理'
}
},
{
path: '/ota-management',
name: 'OtaManagement',
component: function () {
return import('../views/OtaManagement.vue')
},
meta: {
requiresAuth: true,
title: 'OTA管理'
}
},
2025-10-07 23:54:42 +08:00
{
path: '/voice-resource-management',
name: 'VoiceResourceManagement',
component: function () {
return import('../views/VoiceResourceManagement.vue')
},
meta: {
requiresAuth: true,
title: '音色资源开通'
}
},
{
path: '/voice-clone-management',
name: 'VoiceCloneManagement',
component: function () {
return import('../views/VoiceCloneManagement.vue')
},
meta: {
requiresAuth: true,
title: '音色克隆管理'
}
},
2025-05-01 16:57:58 +08:00
{
path: '/dict-management',
name: 'DictManagement',
component: function () {
return import('../views/DictManagement.vue')
}
},
{
path: '/provider-management',
name: 'ProviderManagement',
component: function () {
return import('../views/ProviderManagement.vue')
}
},
2025-09-17 15:38:23 +08:00
// 添加默认角色管理路由
{
path: '/agent-template-management',
name: 'AgentTemplateManagement',
component: function () {
return import('../views/AgentTemplateManagement.vue')
}
},
// 添加模板快速配置路由
{
path: '/template-quick-config',
name: 'TemplateQuickConfig',
component: function () {
return import('../views/TemplateQuickConfig.vue')
}
},
2025-12-05 14:35:53 +08:00
// 功能配置页面路由
{
path: '/feature-management',
name: 'FeatureManagement',
component: function () {
return import('../views/FeatureManagement.vue')
},
meta: {
requiresAuth: true,
title: '功能配置'
}
},
2026-04-23 17:50:57 +08:00
// 替换词管理
{
path: '/replacement-word-management',
name: 'ReplacementWordManagement',
component: function () {
return import('../views/ReplacementWordManagement.vue')
},
meta: {
requiresAuth: true,
title: '替换词管理'
}
},
2026-05-26 16:37:39 +08:00
// 通讯录管理页面路由
{
path: '/address-book-management',
name: 'AddressBookManagement',
component: function () {
return import('../views/AddressBookManagement.vue')
},
meta: {
requiresAuth: true,
title: '通讯录管理'
}
},
2025-03-05 23:13:24 +08:00
]
const router = new VueRouter({
2025-04-24 11:46:29 +08:00
base: process.env.VUE_APP_PUBLIC_PATH || '/',
2025-03-05 23:13:24 +08:00
routes
})
// 全局处理重复导航,改为刷新页面
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => {
if (err.name === 'NavigationDuplicated') {
// 如果是重复导航,刷新页面
window.location.reload()
} else {
// 其他错误正常抛出
throw err
}
})
}
2025-03-30 00:20:09 +08:00
// 需要登录才能访问的路由
2026-05-26 16:37:39 +08:00
const protectedRoutes = ['home', 'RoleConfig', 'DeviceManagement', 'UserManagement', 'ModelConfig', 'KnowledgeBaseManagement', 'KnowledgeFileUpload', 'AddressBookManagement']
2025-03-30 00:20:09 +08:00
// 路由守卫
router.beforeEach((to, from, next) => {
// 检查是否是需要保护的路由
2025-09-19 17:53:43 +08:00
if (protectedRoutes.includes(to.name)) {
2025-03-30 00:20:09 +08:00
// 从localStorage获取token
const token = localStorage.getItem('token')
if (!token) {
// 未登录,跳转到登录页
next({ name: 'login', query: { redirect: to.fullPath } })
return
}
}
next()
})
2025-03-05 23:13:24 +08:00
export default router