app.tsx 4.1 KB

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