boss пре 1 дан
родитељ
комит
e2704916bd
1 измењених фајлова са 9 додато и 4 уклоњено
  1. 9 4
      src/layout/AdminLayout.vue

+ 9 - 4
src/layout/AdminLayout.vue

@@ -171,7 +171,7 @@ export default {
         .map(group => ({
           title: (group.meta && group.meta.title) || group.name || '',
           icon: (group.meta && group.meta.icon) || '',
-          children: this.buildSidebarItems(group.children)
+          children: this.buildSidebarItems(group.children, '/admin/' + (group.path || ''))
         }))
     },
     // 是否处于数据看板页面
@@ -203,19 +203,24 @@ export default {
   },
   methods: {
     // 将Vue Router子路由转换为侧边栏菜单项格式
-    buildSidebarItems(routes) {
+    // parentPath: 父级路径前缀,用于拼接 ParentView 分组的完整路径
+    buildSidebarItems(routes, parentPath) {
       if (!routes || !routes.length) return []
       return routes
         .filter(r => !r.hidden)
         .map(r => {
+          let fullPath = r.path || ''
+          if (!fullPath.startsWith('/')) {
+            fullPath = (parentPath ? parentPath + '/' : '/admin/') + fullPath
+          }
           const item = {
             title: (r.meta && r.meta.title) || r.name || '',
-            path: r.path && r.path.startsWith('/') ? r.path : '/admin/' + (r.path || ''),
+            path: fullPath,
             icon: (r.meta && r.meta.icon) || ''
           }
           // 如果有子路由且不是叶子菜单,递归构建子菜单
           if (r.children && r.children.length && !r.component) {
-            item.children = this.buildSidebarItems(r.children)
+            item.children = this.buildSidebarItems(r.children, fullPath)
           }
           return item
         })