app.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // import { Component, PropsWithChildren } from 'react'
  2. import './app.scss'
  3. // class App extends Component<PropsWithChildren> {
  4. // componentDidMount () {}
  5. // componentDidShow () {}
  6. // componentDidHide () {}
  7. // render () {
  8. // // this.props.children 是将要会渲染的页面
  9. // return this.props.children
  10. // }
  11. // }
  12. // export default App
  13. import { PropsWithChildren } from 'react';
  14. import { useRequest } from 'ahooks';
  15. import Taro from '@tarojs/taro';
  16. import AppContext from './context/appContext';
  17. import { Provider as ReduxProvider } from 'react-redux';
  18. import ReduxUtil from './utils/reduxUtil';
  19. import UserHelper from './helper/userHelper';
  20. interface IAppProps {
  21. }
  22. const App = (props: PropsWithChildren<IAppProps>) => {
  23. const result = useRequest(Taro.getSystemInfo);
  24. useRequest(() => {
  25. return UserHelper.cacheTabMenu();
  26. })
  27. return (
  28. // (appContext.systemInfo?.screenHeight || 0) - (appContext.systemInfo?.safeArea?.bottom || 0);
  29. <AppContext.Provider value={{
  30. systemInfo: result.data,
  31. screenSize: {
  32. width: result.data?.screenWidth || 0,
  33. height: result.data?.screenHeight || 0,
  34. },
  35. padding: {
  36. top: result.data?.safeArea?.top || 0,
  37. bottom: (result.data?.screenHeight || 0) - (result.data?.safeArea?.bottom || 0),
  38. }
  39. }} >
  40. <ReduxProvider store={ReduxUtil.store} >
  41. {props.children}
  42. </ReduxProvider>
  43. </AppContext.Provider>
  44. )
  45. }
  46. export default App;