import { useParams } from '@umijs/max';
import { useState } from 'react';
import styles from './index.less';
import { UnityAction } from '@/utils/utils';

const menuList = [
  {
    name: '首页',
    path: (projectId) => `/home/${projectId}`,
  },
  {
    name: '工况管理',
    path: (projectId) => `/smart/work/${projectId}`,
  },
  {
    name: '系统自检',
    path: (projectId) => `/self-inspection/${projectId}`,
  },
  {
    name: '智能管控',
    path: (projectId) => `/hardware-controller/${projectId}`,
  },
  {
    name: '数字孪生',
  },
  {
    name: '安全管理',
    path: (projectId) => `/safety/${projectId}`,
  },
  {
    name: '任务管理',
    path: (projectId) => `/task-manage/${projectId}`,
  },
  {
    name: '设备管理',
    path: (projectId) => `/device/${projectId}`,
  },
];

function Menu() {
  const [active, setActive] = useState('首页');
  const handleClick = (item) => {
    setActive(item.name);
    
    UnityAction.sendMsg("menuItem", item.name)
  };

  return (
    <div className={styles.menu}>
      {menuList.map((item) => (
        <div
          key={item.name}
          className={`${styles.menuItem} ${
            active == item.name ? styles.active : ''
          }`}
          onClick={() => handleClick(item)}
        >
          {item.name}
        </div>
      ))}
    </div>
  );
}

export default Menu;
