doum
2026-06-11 d9c657aa78cf0ebe31933a87e63ca92edd8a8da3
admin/src/store/index.js
@@ -31,7 +31,9 @@
  // tagsview标签显示隐藏
  isCollapse: false,
  // 顶部菜单索引
  currentIndex: 0
  currentIndex: 0,
  // 路由同步顶级菜单时跳过首页跳转
  skipTopMenuNavigation: false
}
const mutations = {
@@ -74,16 +76,27 @@
  // 设置首页路由信息
  setTopMenuCurrent (state, current) {
    console.log('setTopMenuCurrent', current)
    state.skipTopMenuNavigation = false
    if (current.id !== state.topMenuCurrent.id) {
      state.topMenuList.list.forEach(item => {
      state.topMenuList.list.forEach((item, index) => {
        console.log(item.id, item.id)
        if (current.id == item.id) {
          state.topMenuCurrent = current
          state.menuData.list = item.children
          state.currentIndex = index
        }
      })
    }
  },
  syncTopMenuFromRoute (state, { topMenu, topIndex }) {
    if (!topMenu || topMenu.id === state.topMenuCurrent.id) {
      return
    }
    state.skipTopMenuNavigation = true
    state.topMenuCurrent = topMenu
    state.menuData.list = topMenu.children || []
    state.currentIndex = topIndex
  },
  // 重置菜单
  resetMenus: (state) => {
    state.topMenuId = null