import { MenuType, tabsType } from "./menu";

// 通过url获取菜单类型
export const getMenuType = (url: string) => {
  for (const key in MenuType) {
    const menuItems = MenuType[key];
    for (const item of menuItems) {
      if (item.url === url || (item.data && item.data.some(dataItem => dataItem.url === url))) {
        return key;
      }
    }
  }
  return null;
}

// 通过菜单名称获取到下拉框的key值
export const getTabKey = (name: string) => {
  for (const [key, items] of Object.entries(tabsType)) {
    if (items.some((item: { name: string; }) => item.name === name)) {
      return key;
    }
  }
  return null;
}

// 设置表格行样式颜色
export const rowClassName = (record: any, index: any) => {
  return index % 2 === 0 ? 'even-row' : 'odd-row';
};