birt
2025-04-13 9888eb4278a2c74f8533b468bba958cfffb7b125
折叠
已修改3个文件
37 ■■■■■ 文件已修改
zhitan-vue/src/components/TopNav/index.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-vue/src/layout/index.vue 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-vue/src/router/index.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhitan-vue/src/components/TopNav/index.vue
@@ -167,12 +167,7 @@
    return;
  } 
  
  if (key === '/index' || key === '/') {
    // 首页时显示折叠的侧边栏,而不是隐藏
    router.push({ path: key });
    appStore.showCollapsedSidebar();
    return;
  }
  
  // 检查是否有子路由
  if (route && route.children && route.children.length > 0) {
@@ -258,11 +253,7 @@
function activeRoutes(key) {
  let routes = [];
  if (key === '/index' || key === '/') {
    // 首页时显示折叠的侧边栏,而不是隐藏
    appStore.showCollapsedSidebar();
    return [];
  }
  
  // 查找匹配的路由
  if (childrenMenus.value && childrenMenus.value.length > 0) {
zhitan-vue/src/layout/index.vue
@@ -119,21 +119,25 @@
// 监听路由变化,处理首页的侧边栏显示
watchEffect(() => {
  // 检查是否是首页路由
  if (route.path === '/index' || route.path === '/') {
  // 检查是否是首页路由,但排除/index/index子路由
  if ((route.path === '/index' || route.path === '/') && route.path !== '/index/index') {
    // 首页路由,确保侧边栏不隐藏,但状态是折叠的
    appStore.showCollapsedSidebar()
    appStore.toggleSideBarHide(false) // 改为不隐藏侧边栏
  } else if (route.meta && route.meta.showSidebar === false) {
    // 如果路由明确指定隐藏侧边栏
    appStore.toggleSideBarHide(true)
  } else {
    // 其他路由,确保侧边栏可见
    appStore.toggleSideBarHide(false)
  }
})
// 组件挂载时,确保首页侧边栏状态正确
onMounted(() => {
  // 如果当前是首页,确保侧边栏是折叠的而不是隐藏的
  if (route.path === '/index' || route.path === '/') {
    appStore.showCollapsedSidebar()
  // 如果当前是首页,确保侧边栏可见
  if (route.path === '/index/index') {
    appStore.toggleSideBarHide(false)
    appStore.sidebar.opened = true
  }
})
zhitan-vue/src/router/index.js
@@ -67,13 +67,7 @@
        path: '/index',
        component: () => import('@/views/index'),
        name: 'Index',
        meta: { title: '首页', icon: 'dashboard', affix: true, showSidebar: true, breadcrumb: false },
        beforeEnter: (to, from, next) => {
          // 获取app store并设置侧边栏为折叠状态
          const appStore = useAppStore()
          appStore.showCollapsedSidebar()
          next()
        }
        meta: { title: '首页', icon: 'dashboard', affix: true, showSidebar: true, breadcrumb: false }
      }
    ]
  },