app.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Component, PropsWithChildren } from 'react'
  2. import './app.scss'
  3. import '@/context/locales/index'
  4. import { Provider } from 'react-redux'
  5. import store from './store/store'
  6. import { View } from '@tarojs/components'
  7. import GlobalModal from './components/layout/GlobalModal'
  8. import Taro from '@tarojs/taro'
  9. // import 'taro-ui/dist/style/index.scss'
  10. const App: React.FC<PropsWithChildren> = ({ children }) => {
  11. if (process.env.TARO_ENV == 'weapp') {
  12. global.isDebug = Taro.getStorageSync('isDebug')
  13. const updateManager = Taro.getUpdateManager()
  14. updateManager.onUpdateReady(function () {
  15. Taro.showModal({
  16. title: '更新提示',
  17. content: '新版本已经准备好,是否重启应用?',
  18. showCancel: false,
  19. success: function (res) {
  20. if (res.confirm) {
  21. updateManager.applyUpdate();
  22. }
  23. }
  24. });
  25. });
  26. updateManager.onUpdateFailed(function () {
  27. // 新版本下载失败
  28. Taro.showModal({
  29. title: '已经有新版本喽~',
  30. content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~',
  31. showCancel: false,
  32. });
  33. });
  34. }
  35. else {
  36. // Taro.getStorage({
  37. // key:'isDebug',
  38. // success:res=>{
  39. // // global.isDebug = res
  40. // }
  41. // })
  42. }
  43. return <Provider store={store}>
  44. {children}
  45. </Provider>
  46. }
  47. // class App extends Component<PropsWithChildren> {
  48. // componentDidMount () {}
  49. // componentDidShow () {}
  50. // componentDidHide () {}
  51. // // this.props.children 是将要会渲染的页面
  52. // render () {
  53. // return this.props.children
  54. // }
  55. // }
  56. export default App