index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import React, { useContext, useEffect, useState } from "react"
  2. import './index.less'
  3. import gameIcon from '../assets/favicon.ico'
  4. import { Link, useLocation } from "react-router-dom"
  5. import { DispatchApp } from "../App";
  6. const noShow = ['/gameIntroduction', '/systemIntroduction', '/gameplayIntroduction', '/commonInformation']
  7. interface Props {
  8. children?: React.ReactNode;
  9. }
  10. const Layout: React.FC<Props> = ({ children }) => {
  11. /************************************/
  12. const location = useLocation(); // 获取当前路由位置
  13. const { scrollY, scrollDirection } = useContext(DispatchApp)!;
  14. const [active, setActive] = useState<boolean>(false)
  15. /************************************/
  16. useEffect(() => {
  17. const bodyHeader = document.getElementById('bodyHeader');
  18. if (noShow.includes(location.pathname)) {
  19. if (scrollDirection === 'down' && scrollY > 200) {
  20. bodyHeader?.classList.add('notshow');
  21. } else {
  22. bodyHeader?.classList.remove('notshow');
  23. }
  24. } else {
  25. bodyHeader?.classList?.remove('notshow')
  26. }
  27. }, [scrollY, scrollDirection, location])
  28. return <>
  29. <header id="bodyHeader">
  30. <div className='header-box'>
  31. <img className="game-icon" src={gameIcon} alt="" />
  32. <div className="game-title"></div>
  33. <div className={`btn-menu ${active ? 'active' : ''}`} onClick={() => { setActive(!active) }}></div>
  34. </div>
  35. <ul className={`${active ? 'active' : ''}`} onClick={() => {
  36. setActive(!active)
  37. window.scrollTo({ top: 0 })
  38. }}>
  39. <li><Link to="/">官网首页</Link></li>
  40. <li><Link to="/gameIntroduction">游戏介绍</Link></li>
  41. <li><Link to="/systemIntroduction">系统介绍</Link></li>
  42. <li><Link to="/gameplayIntroduction">玩法介绍</Link></li>
  43. <li><Link to="/commonInformation">常用信息</Link></li>
  44. <li><Link to="/news">新闻中心</Link></li>
  45. <li><Link to="/strategy">游戏攻略</Link></li>
  46. </ul>
  47. </header>
  48. {/* 主内容 */}
  49. {children}
  50. <footer>
  51. <a style={{ opacity: 0, height: 0, overflow: 'hidden' }}></a>
  52. <div className="inner">
  53. <div className="copyright-con">
  54. <p>
  55. <a href="https://xjqxz.gaeamobile.net/privacy.html" target="_blank">隐私政策</a>
  56. |
  57. <a href="https://xjqxz.gaeamobile.net/service.html" target="_blank">用户服务协议</a>
  58. |
  59. <a href="https://xjqxz.gaeamobile.net/childProtection.html" target="_blank">儿童个人信息保护及监护人须知</a></p>
  60. <p>温馨提示:本游戏产品适合16岁(含)以上用户</p>
  61. <p>
  62. <a href="http://beian.miit.gov.cn/">粤ICP备14092178号-1</a> |
  63. <a href="https://image.gaeamobile.net/image/20210617/172839/GAEAICP.pdf" target="_blank">粤B2-20160276</a>
  64. |
  65. <a href="https://beian.miit.gov.cn/#/Integrated/index">粤ICP备14092178号-20A</a>
  66. </p>
  67. <p>著作权人:天津帕格索斯网络科技有限公司</p>
  68. <p>
  69. 新广出审[2016]1432 | ISBN 978-7-7979-0252-6
  70. |
  71. <a href="http://sq.ccm.gov.cn:80/ccnt/sczr/service/business/emark/gameNetTag/4028c08c54dc801e0154dcac5eec0532" target="_blank">
  72. 文网游进字[2016]0073号
  73. <img src="https://image.gaeamobile.net/image/20180712/141506/1.png" alt="" className="wen" />
  74. </a>
  75. </p>
  76. <p>出版单位:北京伯通电子出版社</p>
  77. <p>客服邮箱:kf-service@gaea.com</p>
  78. <p>健康游戏忠告:抵制不良游戏,拒绝盗版游戏。注意自我保护,谨防受骗上当。适度游戏益脑,沉迷游戏伤身。合理安排时间,享受健康生活。</p>
  79. </div>
  80. </div>
  81. </footer>
  82. </>
  83. }
  84. export default React.memo(Layout)