Bläddra i källkod

fix: 修改一级菜单也会有下拉箭头问题

xyh 2 år sedan
förälder
incheckning
e9201c9edf
2 ändrade filer med 10 tillägg och 7 borttagningar
  1. 1 1
      packages/app/src/utils/constants.ts
  2. 9 6
      packages/app/src/utils/sortMenu/index.tsx

+ 1 - 1
packages/app/src/utils/constants.ts

@@ -32,7 +32,7 @@ export const MODAL_PAGE_SIZE_LIST = ['5', ...PAGE_SIZE_LIST];
 /** 请求域名 */
 export const NETWORK_URL
   = process.env.NODE_ENV === 'development'
-    ? 'https://7cb7b084.r6.cpolar.top'
+    ? 'http://192.168.0.142:9560'
     : 'http://10.2.111.91:9560';
 export const E2E_NETWORK_URL = 'http://e2e.test.cn';
 /** 导出错误提示 */

+ 9 - 6
packages/app/src/utils/sortMenu/index.tsx

@@ -30,19 +30,22 @@ export function sortMenu(menus: TreeRoleMenuData[]) {
       // 是一级菜单找是否在临时区域有保存的二级菜单
       const tempList = tempAreaMap.get(id);
 
-      result.push({...tempValue, children: tempList ? [...tempList] : []});
+      tempList && (tempValue.children = [...tempList]);
+
+      result.push(tempValue);
     } else {
       // 二级菜单判断是否有对应的一级菜单 如果有加到父组件的children里
       // 如果没有放在临时Map中
       const idx = result.findIndex(val => val.key === pId);
 
       if (idx >= 0) {
-        result[idx].children!.push(tempValue);
+        result[idx].children
+          ? result[idx].children!.push(tempValue)
+          : (result[idx].children = [tempValue]);
       } else {
-        if (tempAreaMap.has(pId))
-          tempAreaMap.get(pId)!.push(tempValue);
-        else
-          tempAreaMap.set(pId, [tempValue]);
+        tempAreaMap.has(pId)
+          ? tempAreaMap.get(pId)!.push(tempValue)
+          : tempAreaMap.set(pId, [tempValue]);
       }
     }
   });