Commit 34e69e55 authored by afc163's avatar afc163

refactor formatter

parent 60a768de
...@@ -115,22 +115,16 @@ const menuData = [{ ...@@ -115,22 +115,16 @@ const menuData = [{
}]; }];
function formatter(data, parentPath = '') { function formatter(data, parentPath = '') {
const list = []; return data.map((item) => {
data.forEach((item) => { const result = {
...item,
path: `${parentPath}${item.path}`,
};
if (item.children) { if (item.children) {
list.push({ result.children = formatter(item.children, `${parentPath}${item.path}/`);
...item,
path: `${parentPath}${item.path}`,
children: formatter(item.children, `${parentPath}${item.path}/`),
});
} else {
list.push({
...item,
path: `${parentPath}${item.path}`,
});
} }
return result;
}); });
return list;
} }
export const getMenuData = () => formatter(menuData); export const getMenuData = () => formatter(menuData);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment