Merge branch 'main' of https://git.light120.com/zc/admin_core
This commit is contained in:
@@ -29,7 +29,7 @@ import components ,{ registerGlobalComponents, registerComponents} from './compo
|
||||
|
||||
import pages from './views/index'
|
||||
|
||||
const { LoginPage, Page401, Page404, Page500, setupComponentMap } = pages
|
||||
const { LoginPage, Page401, Page404, Page500, setupComponentMap, HomePage } = pages
|
||||
|
||||
|
||||
// 导入页面组件
|
||||
@@ -182,6 +182,7 @@ class AdminFramework {
|
||||
Main: framework.Main,
|
||||
ParentView: framework.ParentView,
|
||||
Page404: framework.Page404,
|
||||
HomePage: framework.HomePage,
|
||||
authorityMenus: authorityMenus
|
||||
})
|
||||
console.log('Menu restored')
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
|
||||
@@ -24,8 +24,14 @@ import Page500 from './error-page/500.vue'
|
||||
|
||||
// 设置组件映射的方法
|
||||
export function setupComponentMap(customMap = {}, uiTool) {
|
||||
|
||||
|
||||
if (!customMap["home/index"]) {
|
||||
customMap["home/index"] = HomePage
|
||||
}
|
||||
|
||||
|
||||
const componentMap = {
|
||||
'home/index': HomePage,
|
||||
'system/sys_log': SysLog,
|
||||
'system/sys_param_setup': SysParamSetup,
|
||||
'system/sys_role': SysRole,
|
||||
@@ -48,7 +54,6 @@ export function setupComponentMap(customMap = {}, uiTool) {
|
||||
}
|
||||
|
||||
export default {
|
||||
HomePage,
|
||||
SysLog,
|
||||
SysLogOperate,
|
||||
SysParamSetup,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user