feat(router): 优化 Agent路由加载策略
- 移除静态路由中的占位组件- 删除动态路由加载逻辑 - 在路由守卫中实现 Agent路由的动态加载 - 更新路由元信息和结构
This commit is contained in:
@ -4,31 +4,12 @@ import { MENU_GROUP_IDS } from '@/router/constants';
|
||||
import IconRepository from '@/assets/svg/icon-repository.svg';
|
||||
|
||||
const COMPONENTS: AppRouteRecordRaw[] = [
|
||||
// {
|
||||
// path: '/agent',
|
||||
// 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: '/agent',
|
||||
name: 'AgentPlaceholder',
|
||||
component: () => Promise.resolve({ template: '<router-view />' }), // 占位组件
|
||||
|
||||
},
|
||||
];
|
||||
|
||||
export default COMPONENTS;
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
import { getCategoriesMenus } from '@/api/all/agent';
|
||||
import type { AppRouteRecordRaw } from '../types';
|
||||
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||
import IconRepository from '@/assets/svg/icon-repository.svg';
|
||||
import { IconBookmark } from '@arco-design/web-vue/es/icon';
|
||||
|
||||
export const loadDynamicMenus = async (routerInstance) => {
|
||||
try {
|
||||
const { code, data } = await getCategoriesMenus();
|
||||
|
||||
let router = [
|
||||
{
|
||||
path: '/repository233',
|
||||
name: 'Repository',
|
||||
redirect: 'repository/brandMaterials',
|
||||
meta: {
|
||||
locale: '品牌资产管理',
|
||||
icon: IconRepository,
|
||||
requiresAuth: true,
|
||||
requireLogin: true,
|
||||
roles: ['*'],
|
||||
id: MENU_GROUP_IDS.PROPERTY_ID,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'brandMaterials',
|
||||
name: 'RepositoryBrandMaterials',
|
||||
meta: {
|
||||
locale: '品牌信息',
|
||||
requiresAuth: true,
|
||||
requireLogin: true,
|
||||
roles: ['*'],
|
||||
},
|
||||
component: () => import('@/views/property-marketing/brands/brand-materials/index.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
// 添加子路由到名为 Agent 的父路由下
|
||||
router.forEach(route => {
|
||||
routerInstance.addRoute('Agent', route);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to load dynamic menus:', error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user