Commit 34e69e55 authored by afc163's avatar afc163

refactor formatter

parent 60a768de
......@@ -115,22 +115,16 @@ const menuData = [{
}];
function formatter(data, parentPath = '') {
const list = [];
data.forEach((item) => {
if (item.children) {
list.push({
...item,
path: `${parentPath}${item.path}`,
children: formatter(item.children, `${parentPath}${item.path}/`),
});
} else {
list.push({
return data.map((item) => {
const result = {
...item,
path: `${parentPath}${item.path}`,
});
};
if (item.children) {
result.children = formatter(item.children, `${parentPath}${item.path}/`);
}
return result;
});
return list;
}
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