/* list To Tree */

import { getMenuListResultModel } from '/@/api/sys/model/menuModel';
import { useI18n } from '/@/hooks/web/useI18n';

export function listToTree(lists: getMenuListResultModel): getMenuListResultModel {
  const { t } = useI18n(); //加载国际化
  lists.forEach((goods) => {
    goods['menuName'] = t(goods.meta.title); // 为goods添加属性menuName

    // console.log(goods.children?.length);
    if (goods.children?.length) {
      listToTree(goods.children);
      // goods.children.forEach((goodChildren) => {
      //   goodChildren['menuName'] = t(goodChildren.meta.title); // 为goodChildren添加属性menuName
      // });
    }
  });
  return lists;
}
