app.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 jgPush from './utils/push.rn'
  10. // import 'taro-ui/dist/style/index.scss'
  11. let LogBox;
  12. if (process.env.TARO_ENV == 'rn') {
  13. LogBox = require("react-native").LogBox
  14. }
  15. const App: React.FC<PropsWithChildren> = ({ children }) => {
  16. if (process.env.TARO_ENV == 'weapp') {
  17. global.isDebug = Taro.getStorageSync('isDebug')
  18. const updateManager = Taro.getUpdateManager()
  19. updateManager.onUpdateReady(function () {
  20. Taro.showModal({
  21. title: '更新提示',
  22. content: '新版本已经准备好,是否重启应用?',
  23. showCancel: false,
  24. success: function (res) {
  25. if (res.confirm) {
  26. updateManager.applyUpdate();
  27. }
  28. }
  29. });
  30. });
  31. updateManager.onUpdateFailed(function () {
  32. // 新版本下载失败
  33. Taro.showModal({
  34. title: '已经有新版本喽~',
  35. content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~',
  36. showCancel: false,
  37. });
  38. });
  39. }
  40. else {
  41. //关闭其中某些yellow警告
  42. LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message
  43. LogBox.ignoreAllLogs();//Ignore all log notifications
  44. const test = require('./utils/push').default
  45. test()
  46. // jgPush()
  47. // const JPush = require('jpush-react-native')
  48. // JPush.init({ appKey: "4fcc3e237eec4c4fb804ad49", channel: "dev", production: false });
  49. // //连接状态
  50. // JPush.addConnectEventListener(result => {
  51. // console.log(result)
  52. // debugger
  53. // })
  54. // console.log('rn jpush init')
  55. // //通知回调
  56. // var notificationListener = result => {
  57. // console.log("notificationListener:" + JSON.stringify(result))
  58. // alert(JSON.stringify(result))
  59. // };
  60. // JPush.addNotificationListener(notificationListener);
  61. // //本地通知回调
  62. // var localNotificationListener = result => {
  63. // console.log("localNotificationListener:" + JSON.stringify(result))
  64. // };
  65. // JPush.addLocalNotificationListener(localNotificationListener);
  66. // //自定义消息回调
  67. // var customMessageListener = result => {
  68. // console.log("customMessageListener:" + JSON.stringify(result))
  69. // };
  70. // JPush.addCustomMessageListener(customMessageListener);
  71. // //应用内消息回调
  72. // JPush.pageEnterTo("HomePage") // 进入首页,当页面退出时请调用 JPush.pageLeave('HomePage')
  73. // var inappMessageListener = result => {
  74. // console.log("inappMessageListener:" + JSON.stringify(result))
  75. // alert(JSON.stringify(result))
  76. // };
  77. // JPush.addInappMessageListener(inappMessageListener);
  78. // //tag alias事件回调
  79. // var tagAliasListener = result => {
  80. // console.log("tagAliasListener:" + JSON.stringify(result))
  81. // };
  82. // JPush.addTagAliasListener(tagAliasListener);
  83. // //手机号码事件回调
  84. // var mobileNumberListener = result => {
  85. // console.log("mobileNumberListener:" + JSON.stringify(result))
  86. // };
  87. // JPush.addMobileNumberListener(mobileNumberListener);
  88. }
  89. return <Provider store={store}>
  90. {children}
  91. </Provider>
  92. }
  93. // class App extends Component<PropsWithChildren> {
  94. // componentDidMount () {}
  95. // componentDidShow () {}
  96. // componentDidHide () {}
  97. // // this.props.children 是将要会渲染的页面
  98. // render () {
  99. // return this.props.children
  100. // }
  101. // }
  102. export default App