bea288e414
== 已部署上线 (9项) == - 代办事项真实数据源集成 (企微审批API 8bug修复链) - H5/坐席端 Logo样式统一+绿色背景 - 视频引导页修复 (localStorage key v2) - 坐席端 v9 Vue版本修复 (ElMessage._context) - 截图按钮 v10 修复 (getDisplayMedia user gesture) - 扫码样式恢复+H5扫码登录跳转修复 - H5截图快捷键提示 == 代码完成待部署 (3项) == - 知识迭代3Bug修复 (#8 POST端点/#7 MERGE幂等/#6 过期检查) - 会议室预定-小鱼易联终端 (40文件, 40/40测试通过) - IT资产升级审批推送 (asset_service.py) == 需求文档 (2项) == - 坐席端AI辅助消息框-PRD (4项新功能确认) - 坐席端布局优化建议 v2.0 (7天计划) == 新增文档 == - 日报-2026-07-11.md - 知识迭代Bug修复报告-20260711.md - 会议室预定-部署指南.md - CHANGELOG.md 更新 == 测试 == - test_todo_integration.py: 40/40 - test_meetingroom.py: 40/40 - test_bugfix_ki_suggestions.py: 21/21
281 lines
9.5 KiB
TypeScript
281 lines
9.5 KiB
TypeScript
// =============================================================================
|
||
// 企微IT智能服务台 — 管理后台路由配置
|
||
// =============================================================================
|
||
// 说明:定义管理后台页面路由映射,包含 admin 权限路由守卫
|
||
|
||
import { createRouter, createWebHistory } from 'vue-router'
|
||
|
||
// --------------------------------------------------------------------------
|
||
// 路由配置
|
||
// --------------------------------------------------------------------------
|
||
const routes = [
|
||
{
|
||
// 登录页面
|
||
path: '/login',
|
||
name: 'Login',
|
||
component: () => import('@/views/Login.vue'),
|
||
meta: { title: '管理员登录', requiresAuth: false },
|
||
},
|
||
// 账号绑定页(互联企业用户)
|
||
{
|
||
path: '/bind',
|
||
name: 'Bind',
|
||
component: () => import('@/views/Bind.vue'),
|
||
meta: { title: '账号绑定', requiresAuth: false },
|
||
},
|
||
{
|
||
// 管理后台主布局(需要认证)
|
||
path: '/',
|
||
component: () => import('@/layouts/AdminLayout.vue'),
|
||
meta: { requiresAuth: true },
|
||
children: [
|
||
{
|
||
// 根路径重定向到仪表盘
|
||
path: '',
|
||
redirect: '/dashboard',
|
||
},
|
||
{
|
||
path: 'dashboard',
|
||
name: 'Dashboard',
|
||
component: () => import('@/views/Dashboard.vue'),
|
||
meta: { title: '运营总览', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'configs',
|
||
name: 'Configs',
|
||
component: () => import('@/views/Configs.vue'),
|
||
meta: { title: '功能开关', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'agents',
|
||
name: 'Agents',
|
||
component: () => import('@/views/Agents.vue'),
|
||
meta: { title: '坐席管理', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'roles',
|
||
name: 'Roles',
|
||
component: () => import('@/views/Roles.vue'),
|
||
meta: { title: '角色管理', requiresAuth: true },
|
||
},
|
||
{
|
||
// v0.7.1 task #91 — RBAC 细粒度权限矩阵可视化
|
||
path: 'permissions-matrix',
|
||
name: 'PermissionsMatrix',
|
||
component: () => import('@/views/PermissionsMatrix.vue'),
|
||
meta: { title: '权限矩阵', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'integrations',
|
||
name: 'Integrations',
|
||
component: () => import('@/views/Integrations.vue'),
|
||
meta: { title: '系统集成', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'terminal-security',
|
||
name: 'TerminalSecurity',
|
||
component: () => import('@/views/TerminalSecurity.vue'),
|
||
meta: { title: '终端安全', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'quick-replies',
|
||
name: 'QuickReplies',
|
||
component: () => import('@/views/QuickReplies.vue'),
|
||
meta: { title: '快速回复', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'knowledge',
|
||
name: 'Knowledge',
|
||
component: () => import('@/views/Knowledge.vue'),
|
||
meta: { title: '知识库', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'assignment-mode',
|
||
name: 'AssignmentMode',
|
||
component: () => import('@/views/AssignmentMode.vue'),
|
||
meta: { title: '分配模式', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'monitor',
|
||
name: 'Monitor',
|
||
component: () => import('@/views/Monitor.vue'),
|
||
meta: { title: '会话监控', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'flowcharts',
|
||
name: 'Flowcharts',
|
||
component: () => import('@/views/Flowcharts.vue'),
|
||
meta: { title: '排查流程图', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'session-audit',
|
||
name: 'SessionAudit',
|
||
component: () => import('@/views/SessionAudit.vue'),
|
||
meta: { title: '会话审计', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'agent-performance',
|
||
name: 'AgentPerformance',
|
||
component: () => import('@/views/AgentPerformance.vue'),
|
||
meta: { title: '坐席绩效', requiresAuth: true },
|
||
},
|
||
{
|
||
path: 'system-logs',
|
||
name: 'SystemLogs',
|
||
component: () => import('@/views/SystemLogs.vue'),
|
||
meta: { title: '配置变更历史', requiresAuth: true },
|
||
},
|
||
{
|
||
// 安全审计日志(复用既有后端 GET /api/admin/audit-logs)
|
||
path: 'audit-logs',
|
||
name: 'AuditLogs',
|
||
component: () => import('@/views/AuditLogs.vue'),
|
||
meta: { title: '安全审计日志', requiresAuth: true },
|
||
},
|
||
{
|
||
// 运行期日志(新增后端 GET /api/admin/runtime-logs)
|
||
path: 'runtime-logs',
|
||
name: 'RuntimeLogs',
|
||
component: () => import('@/views/RuntimeLogs.vue'),
|
||
meta: { title: '运行期日志', requiresAuth: true },
|
||
},
|
||
{
|
||
// P2 占位页:主题模板
|
||
path: 'themes',
|
||
name: 'Themes',
|
||
component: () => import('@/views/Placeholder.vue'),
|
||
meta: { title: '主题模板', requiresAuth: true, comingSoon: true },
|
||
},
|
||
{
|
||
// P2 占位页:数据看板
|
||
path: 'reports',
|
||
name: 'Reports',
|
||
component: () => import('@/views/Placeholder.vue'),
|
||
meta: { title: '数据看板', requiresAuth: true, comingSoon: true },
|
||
},
|
||
{
|
||
// P2 占位页:知识库管理
|
||
path: 'knowledge',
|
||
name: 'Knowledge',
|
||
component: () => import('@/views/Placeholder.vue'),
|
||
meta: { title: '知识库管理', requiresAuth: true, comingSoon: true },
|
||
},
|
||
{
|
||
// Phase 2.4 task #20 — MFA 管理(管理员重置员工 MFA 绑定)
|
||
path: 'mfa-manage',
|
||
name: 'MfaManage',
|
||
component: () => import('@/views/MfaManage.vue'),
|
||
meta: { title: 'OTP 管理', requiresAuth: true },
|
||
},
|
||
{
|
||
// 满意度评价统计
|
||
path: 'evaluation-stats',
|
||
name: 'EvaluationStats',
|
||
component: () => import('@/views/EvaluationStats.vue'),
|
||
meta: { title: '满意度评价', requiresAuth: true },
|
||
},
|
||
{
|
||
// 知识库优化建议 (P2-13)
|
||
path: 'knowledge-suggestions',
|
||
name: 'KnowledgeSuggestions',
|
||
component: () => import('@/views/KnowledgeSuggestions.vue'),
|
||
meta: { title: '知识库建议', requiresAuth: true },
|
||
},
|
||
{
|
||
// 阶段5 自动化闭环 — 场景配置
|
||
path: 'automation-scenarios',
|
||
name: 'AutomationScenarios',
|
||
component: () => import('@/views/automation/ScenarioConfig.vue'),
|
||
meta: { title: '自动化场景', requiresAuth: true },
|
||
},
|
||
{
|
||
// 阶段5 自动化闭环 — 规则版本/灰度
|
||
path: 'automation-versions',
|
||
name: 'AutomationVersions',
|
||
component: () => import('@/views/automation/RuleVersion.vue'),
|
||
meta: { title: '规则版本', requiresAuth: true },
|
||
},
|
||
{
|
||
// 阶段5 自动化闭环 — 指标看板
|
||
path: 'automation-metrics',
|
||
name: 'AutomationMetrics',
|
||
component: () => import('@/views/dashboard/AutoMetrics.vue'),
|
||
meta: { title: '自动化指标', requiresAuth: true },
|
||
},
|
||
{
|
||
// Tier1 知识库迭代 — 提案管理(D7)
|
||
path: 'knowledge-iteration',
|
||
name: 'KnowledgeIteration',
|
||
component: () => import('@/views/KnowledgeIteration.vue'),
|
||
meta: { title: '知识迭代管理', requiresAuth: true },
|
||
},
|
||
{
|
||
// Tier1 知识库迭代 — RAGFlow 文档摄入(通道 C / P1-5)
|
||
path: 'ragflow-ingestion',
|
||
name: 'RagflowIngestion',
|
||
component: () => import('@/views/RagflowIngestion.vue'),
|
||
meta: { title: 'RAGFlow文档导入', requiresAuth: true },
|
||
},
|
||
],
|
||
},
|
||
{
|
||
// 404 页面:捕获所有未匹配路由
|
||
path: '/:pathMatch(.*)*',
|
||
name: 'NotFound',
|
||
component: () => import('@/views/Placeholder.vue'),
|
||
meta: { title: '页面未找到' },
|
||
},
|
||
]
|
||
|
||
// --------------------------------------------------------------------------
|
||
// 创建路由实例
|
||
// --------------------------------------------------------------------------
|
||
// createWebHistory: 使用 HTML5 History 模式,基础路径 /itadmin/(与IT数据平台共享域名)
|
||
const router = createRouter({
|
||
history: createWebHistory('/itadmin/'),
|
||
routes,
|
||
})
|
||
|
||
// --------------------------------------------------------------------------
|
||
// 路由守卫 — 检查管理员登录状态
|
||
// --------------------------------------------------------------------------
|
||
router.beforeEach((to, _from, next) => {
|
||
// 设置页面标题
|
||
if (to.meta.title) {
|
||
document.title = `${to.meta.title} - 智能IT服务平台`
|
||
}
|
||
|
||
// ===== 新增:处理 URL 中的 token 参数(从 Portal 跳转过来时) =====
|
||
const urlParams = new URLSearchParams(window.location.search)
|
||
const urlToken = urlParams.get('token')
|
||
if (urlToken) {
|
||
// 保存 token 到 localStorage
|
||
localStorage.setItem('admin_token', urlToken)
|
||
// 清除 URL 中的 token 参数,保持 URL 干净
|
||
window.history.replaceState({}, '', window.location.pathname)
|
||
}
|
||
// ===== token 处理结束 =====
|
||
|
||
// 检查是否需要认证
|
||
const requiresAuth = to.meta.requiresAuth !== false
|
||
const token = localStorage.getItem('admin_token')
|
||
|
||
// 账号绑定页不需要认证
|
||
if (to.name === 'Bind') {
|
||
next()
|
||
return
|
||
}
|
||
|
||
if (requiresAuth && !token) {
|
||
// 需要认证但没有 token,跳转到登录页
|
||
next({ path: '/login', query: { redirect: to.fullPath } })
|
||
} else if (to.path === '/login' && token) {
|
||
// 已登录用户访问登录页,跳转到仪表盘
|
||
next({ path: '/dashboard' })
|
||
} else {
|
||
next()
|
||
}
|
||
})
|
||
|
||
export default router
|