This commit is contained in:
张成
2025-10-20 18:18:27 +08:00
parent 0047086013
commit fd3c1a5563
8 changed files with 479 additions and 107 deletions

View File

@@ -104,9 +104,11 @@ export default {
commit('setMenuList', mainMenu.children)
// 动态添加路由(重要!解决登录后点击菜单空白的问题)
if (this.router) {
const routes =this.router.options.routes
// 从 window.framework 获取 router 实例
const router = window.framework && window.framework.router
if (router) {
const routes = router.options.routes
// 查找并移除旧的主路由
const mainRouteIndex = routes.findIndex(r => r.path === '/')
if (mainRouteIndex !== -1) {
@@ -116,6 +118,11 @@ export default {
// 添加新的主路由
router.addRoute(mainMenu)
console.log('动态路由已添加redirect 设置为:', mainMenu.redirect)
// 等待路由更新完成
await new Promise(resolve => setTimeout(resolve, 100))
} else {
console.warn('未找到 router 实例,动态路由添加失败')
}
}
},