index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { useParams } from '@umijs/max';
  2. import { useState } from 'react';
  3. import styles from './index.less';
  4. import { UnityAction } from '@/utils/utils';
  5. const menuList = [
  6. {
  7. name: '首页',
  8. path: (projectId) => `/home/${projectId}`,
  9. },
  10. {
  11. name: '工况管理',
  12. path: (projectId) => `/smart/work/${projectId}`,
  13. },
  14. {
  15. name: '系统自检',
  16. path: (projectId) => `/self-inspection/${projectId}`,
  17. },
  18. {
  19. name: '设备管理',
  20. path: (projectId) => `/device/${projectId}`,
  21. },
  22. {
  23. name: '安全管理',
  24. path: (projectId) => `/safety/${projectId}`,
  25. },
  26. {
  27. name: '任务管理',
  28. path: (projectId) => `/task-manage/${projectId}`,
  29. },
  30. {
  31. name: '智能监控',
  32. path: (projectId) => `/hardware-controller/${projectId}`,
  33. },
  34. {
  35. name: '数字孪生',
  36. },
  37. ];
  38. function Menu() {
  39. const { projectId } = useParams();
  40. const [active, setActive] = useState('首页');
  41. const handleClick = (item) => {
  42. setActive(item.name);
  43. const path = item?.path(projectId);
  44. // history.push(path);
  45. console.log(path);
  46. UnityAction.sendMsg("menuItem", item.name)
  47. };
  48. return (
  49. <div className={styles.menu}>
  50. {menuList.map((item) => (
  51. <div
  52. key={item.name}
  53. className={`${styles.menuItem} ${
  54. active == item.name ? styles.active : ''
  55. }`}
  56. onClick={() => handleClick(item)}
  57. >
  58. {item.name}
  59. </div>
  60. ))}
  61. </div>
  62. );
  63. }
  64. export default Menu;