1
This commit is contained in:
@@ -100,6 +100,23 @@ export default {
|
||||
|
||||
if (mainMenu && mainMenu.children) {
|
||||
commit('setMenuList', mainMenu.children)
|
||||
|
||||
// 动态添加路由(重要!解决登录后点击菜单空白的问题)
|
||||
if (window.rootVue && window.rootVue.$router) {
|
||||
// 先移除旧的主路由(如果存在)
|
||||
const router = window.rootVue.$router
|
||||
const routes = router.options.routes
|
||||
|
||||
// 查找并移除旧的主路由
|
||||
const mainRouteIndex = routes.findIndex(r => r.path === '/')
|
||||
if (mainRouteIndex !== -1) {
|
||||
routes.splice(mainRouteIndex, 1)
|
||||
}
|
||||
|
||||
// 添加新的主路由
|
||||
router.addRoute(mainMenu)
|
||||
console.log('动态路由已添加')
|
||||
}
|
||||
}
|
||||
},
|
||||
async handleLogin({ state, commit, dispatch }, { userFrom, Main, ParentView, Page404 }) {
|
||||
|
||||
Reference in New Issue
Block a user