import "./index.css"
import {useEffect} from 'react';
import {useLocation,useNavigate} from "react-router-dom";
function LDPage() {
  const navigate = useNavigate();
  const {state} = useLocation();
  console.log("LDPage被加载了")
useEffect(() => {
  const handleKeyDown = (event:any) => {
    if (event.key === 'ArrowUp') {
      console.log('LDPage向上键被按下');
      navigate(`/TP/${state.LineID}`);
      // 执行向上键的逻辑
    } else if (event.key === 'ArrowDown') {
      console.log('LDPage向下键被按下');
      // 执行向下键的逻辑
    }
  };

  window.addEventListener('keydown', handleKeyDown);

  return () => {
    window.removeEventListener('keydown', handleKeyDown);
  };
}, []); 

  return (
    <>
      <div className="main-box">LDPage{state.LineID}</div>
      <div className="main-box" style={{display:'none'}}>3434</div>
    </>
  );
}

export default LDPage;