afc163 8 лет назад
Родитель
Сommit
34e69e55ee
1 измененных файлов с 7 добавлено и 13 удалено
  1. 7 13
      src/common/menu.js

+ 7 - 13
src/common/menu.js

@@ -115,22 +115,16 @@ const menuData = [{
 }];
 
 function formatter(data, parentPath = '') {
-  const list = [];
-  data.forEach((item) => {
+  return data.map((item) => {
+    const result = {
+      ...item,
+      path: `${parentPath}${item.path}`,
+    };
     if (item.children) {
-      list.push({
-        ...item,
-        path: `${parentPath}${item.path}`,
-        children: formatter(item.children, `${parentPath}${item.path}/`),
-      });
-    } else {
-      list.push({
-        ...item,
-        path: `${parentPath}${item.path}`,
-      });
+      result.children = formatter(item.children, `${parentPath}${item.path}/`);
     }
+    return result;
   });
-  return list;
 }
 
 export const getMenuData = () => formatter(menuData);