feat(agent): 重构智能体页面样式和路由配置,优化历史对话组件
This commit is contained in:
@ -18,75 +18,8 @@ function setupPageGuard(router: Router) {
|
||||
});
|
||||
}
|
||||
|
||||
// 动态加载 agent 路由
|
||||
let isAgentRouteLoaded = false; // 标志位
|
||||
|
||||
async function loadAgentRoute(router: Router) {
|
||||
if (isAgentRouteLoaded) return; // 防止重复加载
|
||||
try {
|
||||
const agentRouter = {
|
||||
path: '/agent',
|
||||
name: 'Agent',
|
||||
redirect: 'agent/index', // 默认重定向到第一个子路由
|
||||
meta: {
|
||||
locale: '扣子智能体',
|
||||
requiresAuth: true,
|
||||
requireLogin: true,
|
||||
id: MENU_GROUP_IDS.AGENT,
|
||||
roles: ['*'],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
name: 'AgentIndex',
|
||||
component: () => import('@/views/agent/index'),
|
||||
meta: {
|
||||
title: '首页', // 菜单标题
|
||||
icon: 'home', // 菜单图标(可选)
|
||||
requiresAuth: false,
|
||||
requireLogin: true,
|
||||
id: MENU_GROUP_IDS.AGENT,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'settings',
|
||||
name: 'AgentSettings',
|
||||
component: () => import('@/views/agent/index'),
|
||||
meta: {
|
||||
title: '设置', // 菜单标题
|
||||
icon: 'settings', // 菜单图标(可选)
|
||||
requiresAuth: true,
|
||||
requireLogin: true,
|
||||
id: MENU_GROUP_IDS.AGENT,
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'dashboard',
|
||||
name: 'AgentDashboard',
|
||||
component: () => import('@/views/agent/index'),
|
||||
meta: {
|
||||
title: '仪表盘', // 菜单标题
|
||||
icon: 'dashboard', // 菜单图标(可选)
|
||||
requiresAuth: true,
|
||||
requireLogin: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
router.addRoute(agentRouter); // 使用传递进来的 router 实例
|
||||
isAgentRouteLoaded = true; // 标记路由已加载
|
||||
} catch (error) {
|
||||
console.error('Error loading agent route:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default function createRouteGuard(router: Router) {
|
||||
loadAgentRoute(router).then(() => {
|
||||
// 路由加载完成后通知菜单更新
|
||||
setRouteEmitter(router.currentRoute.value);
|
||||
});
|
||||
|
||||
setupPageGuard(router);
|
||||
setupUserLoginInfoGuard(router);
|
||||
|
||||
@ -6,9 +6,36 @@ import IconRepository from '@/assets/svg/icon-repository.svg';
|
||||
const COMPONENTS: AppRouteRecordRaw[] = [
|
||||
{
|
||||
path: '/agent',
|
||||
name: 'AgentPlaceholder',
|
||||
component: () => Promise.resolve({ template: '<router-view />' }), // 占位组件
|
||||
|
||||
name: 'Agent',
|
||||
redirect: 'agent/index',
|
||||
meta: {
|
||||
locale: '扣子智能体',
|
||||
icon: IconRepository,
|
||||
requiresAuth: true,
|
||||
requireLogin: true,
|
||||
roles: ['*'],
|
||||
id: MENU_GROUP_IDS.AGENT,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
name: 'AgentIndex',
|
||||
component: () => import('@/views/agent/index'),
|
||||
meta: {
|
||||
requiresAuth: false,
|
||||
requireLogin: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'index',
|
||||
name: 'AgentIndex',
|
||||
component: () => import('@/views/agent/index'),
|
||||
meta: {
|
||||
requiresAuth: false,
|
||||
requireLogin: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user