init
This commit is contained in:
@@ -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 实例,动态路由添加失败')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user