app.tsx 3.9 KB

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