From b8ced8ec593ad002e06173952acf73f405926bd9 Mon Sep 17 00:00:00 2001
From: AliooWang <64893838+AliooWang@users.noreply.github.com>
Date: 星期一, 14 四月 2025 16:56:43 +0800
Subject: [PATCH] Merge pull request #60 from zhitan-cloud/jiayu1.0

---
 zhitan-vue/src/layout/components/Sidebar/SidebarItem.vue |  220 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 169 insertions(+), 51 deletions(-)

diff --git a/zhitan-vue/src/layout/components/Sidebar/SidebarItem.vue b/zhitan-vue/src/layout/components/Sidebar/SidebarItem.vue
index 7b468d2..8e38476 100644
--- a/zhitan-vue/src/layout/components/Sidebar/SidebarItem.vue
+++ b/zhitan-vue/src/layout/components/Sidebar/SidebarItem.vue
@@ -84,65 +84,169 @@
   if (e.target.closest('.el-sub-menu__title')) {
     // 鎸夌収姝g‘鐨勮矾寰勬瀯寤哄眰绾�
     let currentNode = props.item;
-    let pathSegments = [];
     
-    // 棣栧厛娣诲姞褰撳墠鑺傜偣鐨勮矾寰�
-    if (currentNode.path) {
-      pathSegments.push(currentNode.path);
+    console.log('褰撳墠鐐瑰嚮鐨勮彍鍗曢」:', JSON.stringify(currentNode, null, 2));
+    console.log('basePath:', props.basePath);
+    
+    // 鑾峰彇绗竴涓彲瑙佸瓙鑿滃崟锛屽鏋滄病鏈夊彲瑙佸瓙鑿滃崟锛屼笉杩涜璺宠浆
+    if (!currentNode.children || currentNode.children.length === 0) {
+      return;
     }
     
-    // 閫愬眰娣诲姞瀛愯矾寰�
-    while (currentNode.children && currentNode.children.length > 0) {
-      const firstChild = currentNode.children.find(child => !child.hidden);
-      if (!firstChild) break;
-      
-      // 璺宠繃ParentView绫诲瀷鐨勪腑闂磋妭鐐�
-      if (firstChild.component === 'ParentView' || firstChild.component.name === 'ParentView') {
-        currentNode = firstChild;
-        pathSegments.push(firstChild.path);
-        continue;
-      }
-      
-      // 鏅�氳妭鐐瑰鐞�
-      currentNode = firstChild;
-      // 濡傛灉璺緞涓嶆槸浠�/寮�澶达紝鍒欐坊鍔犲埌璺緞鐗囨涓�
-      if (!firstChild.path.startsWith('/')) {
-        pathSegments.push(firstChild.path);
-      } else {
-        // 濡傛灉鏄粷瀵硅矾寰勶紝鍒欐浛鎹箣鍓嶆墍鏈夎矾寰�
-        pathSegments = [firstChild.path];
-      }
-      
-      // 濡傛灉鍒拌揪鍙跺瓙鑺傜偣锛屽垯缁撴潫鏌ユ壘
-      if (!firstChild.children || firstChild.children.length === 0) {
-        break;
-      }
+    const firstVisibleChild = currentNode.children.find(child => !child.hidden);
+    if (!firstVisibleChild) {
+      return;
     }
     
-    // 鏋勫缓鏈�缁堣矾寰�
-    if (pathSegments.length > 0) {
-      // 濡傛灉绗竴娈典笉鏄互/寮�澶达紝娣诲姞/
-      if (!pathSegments[0].startsWith('/')) {
-        pathSegments[0] = '/' + pathSegments[0];
-      }
+    console.log('绗竴涓彲瑙佸瓙鑿滃崟:', JSON.stringify(firstVisibleChild, null, 2));
+    
+    // 鏃ュ織绠$悊绛変笁绾ц彍鍗曠壒娈婂鐞�
+    // 妫�鏌ユ槸鍚︽湁棰勫厛鍐欏叆鐨勫畬鏁磋矾寰勶紝濡傛灉鏈夊垯鐩存帴浣跨敤
+    if (firstVisibleChild.fullPath) {
+      console.log('浣跨敤棰勫厛璁剧疆鐨勫畬鏁磋矾寰�:', firstVisibleChild.fullPath);
+      router.push({ path: firstVisibleChild.fullPath });
+      return;
+    }
+    
+    // 鍒ゆ柇鏄惁鏄郴缁�/鏃ュ織绠$悊绫诲瀷鐨勪笁绾ц彍鍗曪紙渚嬪锛�/system/log/operlog锛�
+    // 杩欑鎯呭喌涓嬶紝鐩存帴璺宠浆鍒扮涓�涓瓙鑿滃崟鐨勫畬鏁磋矾寰�
+    if (firstVisibleChild.component === 'ParentView' || 
+        (typeof firstVisibleChild.component === 'object' && 
+         firstVisibleChild.component.name === 'ParentView')) {
+      console.log('妫�娴嬪埌ParentView缁勪欢锛屽鐞嗕笁绾ц彍鍗�');
       
-      // 缁勫悎璺緞
-      const targetPath = pathSegments.reduce((fullPath, segment, index) => {
-        if (segment.startsWith('/')) {
-          return segment;
-        } else if (index === 0) {
-          return segment;
-        } else {
-          return `${fullPath}/${segment}`;
+      // 鏄湁涓夌骇鑿滃崟鐨勬儏鍐�
+      if (firstVisibleChild.children && firstVisibleChild.children.length > 0) {
+        const grandChild = firstVisibleChild.children.find(child => !child.hidden);
+        if (grandChild) {
+          console.log('鎵惧埌绗笁绾ц彍鍗�:', JSON.stringify(grandChild, null, 2));
+          
+          // 鍒ゆ柇鏄惁搴旇浣跨敤parentPath
+          if (firstVisibleChild.parentPath && grandChild.path.startsWith('/')) {
+            console.log('浣跨敤parentPath灞炴��:', firstVisibleChild.parentPath);
+            // 濡傛灉瀛愯彍鍗曟槸缁濆璺緞锛屼絾鏈塸arentPath锛屽垯搴旇浣跨敤parentPath浣滀负鍩虹
+            let fullPath = firstVisibleChild.parentPath;
+            if (!fullPath.startsWith('/')) {
+              fullPath = '/' + fullPath;
+            }
+            
+            // 绗簩绾ц矾寰勫熀浜庢牴璺緞
+            if (firstVisibleChild.path.startsWith('/')) {
+              // 绗簩绾у凡缁忔槸缁濆璺緞锛屾埅鍙栨渶鍚庨儴鍒�
+              const pathParts = firstVisibleChild.path.split('/');
+              const lastPart = pathParts[pathParts.length - 1];
+              fullPath = fullPath + '/' + lastPart;
+            } else {
+              fullPath = buildFullPath(fullPath, firstVisibleChild.path);
+            }
+            console.log('浜岀骇璺緞:', fullPath);
+            
+            // 绗笁绾ц矾寰勫熀浜庝簩绾ц矾寰�
+            if (grandChild.path.startsWith('/')) {
+              // 绗笁绾ф槸缁濆璺緞锛屾埅鍙栨渶鍚庨儴鍒�
+              const pathParts = grandChild.path.split('/');
+              const lastPart = pathParts[pathParts.length - 1];
+              fullPath = fullPath + '/' + lastPart;
+            } else {
+              fullPath = buildFullPath(fullPath, grandChild.path);
+            }
+            console.log('涓夌骇璺緞 (鏈�缁�):', fullPath);
+            
+            // 瀵艰埅鍒扮涓夌骇鑿滃崟
+            if (grandChild.query) {
+              router.push({ path: fullPath, query: grandChild.query });
+            } else {
+              router.push({ path: fullPath });
+            }
+            return;
+          }
+          
+          // 甯歌璺緞鏋勫缓
+          let fullPath;
+          
+          // 绗竴绾ц矾寰勫繀椤绘槸瀹屾暣鐨勶紙渚嬪/system锛�
+          if (currentNode.path.startsWith('/')) {
+            fullPath = currentNode.path;
+          } else {
+            fullPath = '/' + currentNode.path;
+          }
+          console.log('涓�绾ц矾寰�:', fullPath);
+          
+          // 绗簩绾ц矾寰勫繀椤诲熀浜庣涓�绾ц矾寰勶紙渚嬪/system/log锛�
+          fullPath = buildFullPath(fullPath, firstVisibleChild.path);
+          console.log('浜岀骇璺緞:', fullPath);
+          
+          // 绗笁绾ц矾寰勫繀椤诲熀浜庝簩绾ц矾寰勶紙渚嬪/system/log/operlog锛�
+          fullPath = buildFullPath(fullPath, grandChild.path);
+          console.log('涓夌骇璺緞 (鏈�缁�):', fullPath);
+          
+          // 瀵艰埅鍒扮涓夌骇鑿滃崟
+          if (grandChild.query) {
+            console.log('璺宠浆鍒�:', fullPath, '甯﹀弬鏁�:', grandChild.query);
+            router.push({ path: fullPath, query: grandChild.query });
+          } else {
+            console.log('璺宠浆鍒�:', fullPath);
+            router.push({ path: fullPath });
+          }
+          return;
         }
-      });
-      
-      // 瀵艰埅鍒扮洰鏍囪矾鐢憋紝濡傛灉鏈夋煡璇㈠弬鏁板垯娣诲姞
-      if (currentNode.query) {
-        router.push({ path: targetPath, query: currentNode.query });
-      } else {
-        router.push({ path: targetPath });
       }
+    }
+    
+    console.log('澶勭悊鏍囧噯浜岀骇鑿滃崟');
+    
+    // 妫�鏌ユ槸鍚﹂渶瑕佷娇鐢╬arentPath
+    if (firstVisibleChild.parentPath && firstVisibleChild.path.startsWith('/')) {
+      console.log('浣跨敤parentPath灞炴��:', firstVisibleChild.parentPath);
+      // 濡傛灉瀛愯彍鍗曟槸缁濆璺緞锛屼絾鏈塸arentPath锛屽垯搴旇浣跨敤parentPath浣滀负鍩虹
+      let fullPath = firstVisibleChild.parentPath;
+      if (!fullPath.startsWith('/')) {
+        fullPath = '/' + fullPath;
+      }
+      
+      // 鏋勫缓瀹屾暣璺緞
+      if (firstVisibleChild.path.startsWith('/')) {
+        // 鎴彇瀛愯矾寰勭殑鏈�鍚庨儴鍒�
+        const pathParts = firstVisibleChild.path.split('/');
+        const lastPart = pathParts[pathParts.length - 1];
+        fullPath = fullPath + '/' + lastPart;
+      } else {
+        fullPath = buildFullPath(fullPath, firstVisibleChild.path);
+      }
+      console.log('鏋勫缓鐨勬渶缁堣矾寰�:', fullPath);
+      
+      // 瀵艰埅鍒扮洰鏍囪矾鐢�
+      if (firstVisibleChild.query) {
+        router.push({ path: fullPath, query: firstVisibleChild.query });
+      } else {
+        router.push({ path: fullPath });
+      }
+      return;
+    }
+    
+    // 鏍囧噯鐨勪簩绾ц彍鍗曞鐞�
+    // 鏋勫缓姝g‘鐨勮矾寰�
+    let fullPath;
+    
+    // 澶勭悊绗竴绾ц矾寰勶紙渚嬪/system锛�- 蹇呴』鏄畬鏁寸殑璺緞
+    if (currentNode.path.startsWith('/')) {
+      fullPath = currentNode.path;
+    } else {
+      fullPath = '/' + currentNode.path;
+    }
+    console.log('涓�绾ц矾寰�:', fullPath);
+    
+    // 澶勭悊绗簩绾ц矾寰勶紙渚嬪/system/user锛�- 蹇呴』鍩轰簬绗竴绾ц矾寰�
+    fullPath = buildFullPath(fullPath, firstVisibleChild.path);
+    console.log('浜岀骇璺緞 (鏈�缁�):', fullPath);
+    
+    // 瀵艰埅鍒扮洰鏍囪矾鐢�
+    if (firstVisibleChild.query) {
+      console.log('璺宠浆鍒�:', fullPath, '甯﹀弬鏁�:', firstVisibleChild.query);
+      router.push({ path: fullPath, query: firstVisibleChild.query });
+    } else {
+      console.log('璺宠浆鍒�:', fullPath);
+      router.push({ path: fullPath });
     }
   }
 }
@@ -202,6 +306,20 @@
   return getNormalPath(props.basePath + '/' + routePath)
 }
 
+// 姝g‘鏋勫缓璺緞
+function buildFullPath(base, segment) {
+  // 濡傛灉segment鏄粷瀵硅矾寰勶紝鐩存帴杩斿洖
+  if (segment.startsWith('/')) {
+    return segment;
+  }
+  
+  // 纭繚base鏈夋纭殑寮�澶存枩鏉�
+  const normalizedBase = base.startsWith('/') ? base : '/' + base;
+  
+  // 鎷兼帴璺緞锛岄伩鍏嶅弻鏂滄潬
+  return normalizedBase.endsWith('/') ? normalizedBase + segment : normalizedBase + '/' + segment;
+}
+
 function hasTitle(title){
   if (title.length > 5) {
     return title;

--
Gitblit v1.9.3