index.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import React, { useEffect, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import MenuSider from '@/components/MenuSider'
  4. import Discover from './conponents/Discover'
  5. import Shuxing from './conponents/Shuxing'
  6. import { isPc } from '@/utils/http'
  7. import classNames from 'classnames'
  8. import { useSelector } from 'react-redux'
  9. import { RootState } from '@/store'
  10. import Weijie from './conponents/Weijie'
  11. import { isUnitySta, lodingUnityFu } from '../A0base/data'
  12. import Zloding from '@/components/Zloding'
  13. function A7Wjwj() {
  14. const { myData, unityKey, myLangue } = useSelector((state: RootState) => state.A0Layout)
  15. const [currentTab, setCurrentTab] = useState(0)
  16. // 判断是 返回 属性之辨 上一级 还是说 返回上级页面
  17. const tab2Ref = useRef<any>(null)
  18. const gotoBack = () => {
  19. const flag = tab2Ref.current?.sonGetStaFu()
  20. if (flag) tab2Ref.current?.sonSetStaFu()
  21. else window.location.replace('#/base?t=2')
  22. }
  23. // 监听unity是否被销毁了
  24. const [unitySta, setUnitySta] = useState(false)
  25. useEffect(() => {
  26. const flag = isUnitySta()
  27. if (flag) {
  28. lodingUnityFu()
  29. }
  30. setUnitySta(flag)
  31. }, [unityKey])
  32. return (
  33. <div className={classNames(styles.A7Wjwj, isPc ? '' : styles.A7WjwjMo)}>
  34. {unitySta ? (
  35. <Zloding
  36. isShow={unitySta}
  37. bacNum={4}
  38. callBackFu={() => {
  39. setTimeout(() => {
  40. setUnitySta(false)
  41. const search = new URLSearchParams(window.location.hash.split('?')[1] || '')
  42. const to = search.get('to')
  43. console.log(to)
  44. if (to === 'yblm') window.location.replace('#/yblm')
  45. }, 400)
  46. }}
  47. />
  48. ) : null}
  49. {/* 发现之谜 */}
  50. <Discover style={{ display: currentTab === 0 ? 'flex' : 'none' }} />
  51. {/* 属性之辨 */}
  52. <Shuxing ref={tab2Ref} style={{ display: currentTab === 1 ? 'flex' : 'none' }} />
  53. {/* 未解之思 */}
  54. {currentTab === 2 ? <Weijie txt={myData.weijie} myLang={myLangue} /> : null}
  55. <div className={classNames('back', isPc ? '' : 'moBack')} onClick={() => gotoBack()}>
  56. <img src={require(`@/assets/img/btn_back${myLangue === 'EN' ? 'En' : ''}.png`)} alt='' />
  57. </div>
  58. <div className='topBar'>
  59. <div
  60. className={`tab songFont ${currentTab === 0 ? 'active' : ''}`}
  61. onClick={() => setCurrentTab(0)}
  62. >
  63. {myLangue === 'EN' ? 'Discover' : '发现之谜'}
  64. </div>
  65. <div
  66. className={`tab songFont ${currentTab === 1 ? 'active' : ''}`}
  67. onClick={() => setCurrentTab(1)}
  68. >
  69. {myLangue === 'EN' ? 'Distinction' : '属性之辨'}
  70. </div>
  71. <div
  72. className={`tab songFont ${currentTab === 2 ? 'active' : ''}`}
  73. onClick={() => setCurrentTab(2)}
  74. >
  75. {myLangue === 'EN' ? 'Unresolved' : '未解之思'}
  76. </div>
  77. </div>
  78. <MenuSider activeTab={2} />
  79. </div>
  80. )
  81. }
  82. const MemoA7Wjwj = React.memo(A7Wjwj)
  83. export default MemoA7Wjwj