This commit is contained in:
张成
2025-11-19 22:26:36 +08:00
parent 3e40ab372b
commit ce7916c097
2 changed files with 17 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ export default {
menuList: state => state.menuList
},
actions: {
async setAuthorityMenus({ state, commit }, { Main, ParentView, Page404, authorityMenus, menuIds }) {
async setAuthorityMenus({ state, commit }, { Main, ParentView, Page404, HomePage, authorityMenus, menuIds }) {
// 如果传入了 authorityMenus直接使用否则从接口获取
let menus = authorityMenus
@@ -95,9 +95,9 @@ export default {
commit('setAuthorityMenus', JSON.stringify(menus))
// 生成路由菜单(传递 HomePage 组件)
// 从框架实例中获取 HomePage
const HomePage = (window.framework && window.framework.HomePage) || null
let mainMenu = uiTool.getRoutes(Main, ParentView, Page404, HomePage)
// 优先使用传入的 HomePage,如果没有则从框架实例中获取
const homePageComponent = HomePage || (window.framework && window.framework.HomePage) || null
let mainMenu = uiTool.getRoutes(Main, ParentView, Page404, homePageComponent)
console.log('生成的主菜单:', mainMenu)
if (mainMenu && mainMenu.children) {
@@ -182,10 +182,13 @@ export default {
// 调用 authorityMenus 接口获取完整菜单数据
// 如果接口失败,会使用默认菜单配置和 menuIds 进行过滤
// 从框架实例获取 HomePage
const HomePage = (window.framework && window.framework.HomePage) || null
await dispatch('setAuthorityMenus', {
Main,
ParentView,
Page404,
HomePage,
menuIds
})

View File

@@ -251,7 +251,16 @@ export default {
let menuTree = uiTool.transformTree(menuRows)
this.gridOption.menuData = this.mapTree(menuTree)
this.$store.dispatch('setAuthorityMenus')
// 菜单更新后重新加载权限菜单
const framework = this.$framework || window.framework
if (framework) {
this.$store.dispatch('user/setAuthorityMenus', {
Main: framework.components.Main,
ParentView: framework.components.ParentView,
Page404: framework.pages.Page404,
HomePage: framework.HomePage
})
}
},
async initCol() {