App.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import '@/assets/styles/base.css'
  2. // 关于路由
  3. import React from 'react'
  4. import { Router, Route, Switch } from 'react-router-dom'
  5. import history from './utils/history'
  6. import SpinLoding from './components/SpinLoding'
  7. import store, { RootState } from './store'
  8. import { useSelector } from 'react-redux'
  9. import NotFound from '@/components/NotFound'
  10. import TouchContainer from './components/TouchContainer'
  11. import AsyncSpinLoding from './components/AsyncSpinLoding'
  12. import { Image } from 'antd'
  13. import MessageCom from '@/components/Message'
  14. // import Vconsole from 'vconsole'
  15. // new Vconsole()
  16. // import { isLoc, myData } from './utils/http'
  17. const A0base = React.lazy(() => import('./pages/A0base'))
  18. const Home = React.lazy(() => import('./pages/A1home'))
  19. const Scene = React.lazy(() => import('./pages/A2scene'))
  20. const Architecture = React.lazy(() => import('./pages/A3architecture'))
  21. const Member = React.lazy(() => import('./pages/A4member'))
  22. const View = React.lazy(() => import('./pages/A5view'))
  23. const Life = React.lazy(() => import('./pages/A6life'))
  24. declare global {
  25. //设置全局属性
  26. interface Window {
  27. //window对象属性
  28. isHH: boolean //加入对象
  29. myDataTemp: MyDataType
  30. }
  31. }
  32. export default function App() {
  33. const lookBigImg = useSelector((state: RootState) => state.A0Layout.lookBigImg)
  34. return (
  35. <>
  36. {/* 关于路由 */}
  37. <Router history={history}>
  38. <React.Suspense fallback={<SpinLoding />}>
  39. <Switch>
  40. <Route path='/' component={A0base} exact />
  41. <Route path='/home' component={Home} exact />
  42. <Route path='/scene' component={Scene} exact />
  43. <Route path='/architecture' component={Architecture} exact />
  44. <Route path='/member' component={Member} exact />
  45. <Route path='/view' component={View} exact />
  46. <Route path='/life' component={Life} exact />
  47. <Route path='*' component={NotFound} />
  48. </Switch>
  49. </React.Suspense>
  50. </Router>
  51. {/* 发送请求的加载组件 */}
  52. <AsyncSpinLoding />
  53. {/* 所有图片点击预览查看大图 */}
  54. {lookBigImg.show ? (
  55. <Image
  56. preview={{
  57. imageRender: originalNode => (
  58. <div className='previewImage'>
  59. <TouchContainer className='Ori' zoom={lookBigImg.zoom}>
  60. {originalNode}
  61. </TouchContainer>
  62. <div className='ImgFromTxt'>{lookBigImg.fromTxt}</div>
  63. </div>
  64. ),
  65. visible: lookBigImg.show,
  66. src: lookBigImg.url,
  67. onVisibleChange: value => {
  68. // 清除仓库信息
  69. store.dispatch({
  70. type: 'layout/lookBigImg',
  71. payload: { url: '', show: false, fromTxt: '', zoom: 1 }
  72. })
  73. }
  74. }}
  75. />
  76. ) : null}
  77. <MessageCom />
  78. </>
  79. )
  80. }